This commit is contained in:
parent
22a01e0fa6
commit
4b8d5df83e
4 changed files with 48 additions and 8 deletions
|
@ -15,7 +15,8 @@ birl = ">= 1.8.0 and < 2.0.0"
|
|||
dot_env = ">= 1.2.0 and < 2.0.0"
|
||||
gleam_erlang = ">= 1.0.0 and < 2.0.0"
|
||||
gleam_otp = ">= 1.0.0 and < 2.0.0"
|
||||
spacetraders_sdk = ">= 1.2.0 and < 2.0.0"
|
||||
gleam_community_ansi = ">= 1.4.3 and < 2.0.0"
|
||||
spacetraders_sdk = ">= 1.3.0 and < 2.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
gleeunit = ">= 1.5.1 and < 2.0.0"
|
||||
|
|
|
@ -5,6 +5,8 @@ packages = [
|
|||
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
|
||||
{ name = "dot_env", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "simplifile"], otp_app = "dot_env", source = "hex", outer_checksum = "F2B4815F1B5AF8F20A6EADBB393E715C4C35203EBD5BE8200F766EA83A0B18DE" },
|
||||
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
|
||||
{ name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" },
|
||||
{ name = "gleam_community_colour", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "F0ACE69E3A47E913B03D3D0BB23A5563A91A4A7D20956916286068F4A9F817FE" },
|
||||
{ name = "gleam_erlang", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "7E6A5234F927C4B24F8054AB1E4572206C41F9E6D5C6C02273CB7531E7E5CED0" },
|
||||
{ name = "gleam_http", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "0A62451FC85B98062E0907659D92E6A89F5F3C0FBE4AB8046C99936BF6F91DBC" },
|
||||
{ name = "gleam_httpc", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C670EBD46FC1472AD5F1F74F1D3938D1D0AC1C7531895ED1D4DDCB6F07279F43" },
|
||||
|
@ -16,12 +18,13 @@ packages = [
|
|||
{ name = "gleeunit", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D33B7736CF0766ED3065F64A1EBB351E72B2E8DE39BAFC8ADA0E35E92A6A934F" },
|
||||
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
|
||||
{ name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" },
|
||||
{ name = "spacetraders_sdk", version = "1.2.0", build_tools = ["gleam"], requirements = ["birl", "gleam_http", "gleam_httpc", "gleam_json", "gleam_stdlib"], otp_app = "spacetraders_sdk", source = "hex", outer_checksum = "F014D4046FC25EBB83ADCCEBE539C511048CBA2B8A5014B6E568A6FEF7E79337" },
|
||||
{ name = "spacetraders_sdk", version = "1.3.0", build_tools = ["gleam"], requirements = ["birl", "gleam_http", "gleam_httpc", "gleam_json", "gleam_stdlib"], otp_app = "spacetraders_sdk", source = "hex", outer_checksum = "EA54B9259F1F9ACF5DC817140F526C87FA5D6D137B86AB69C629697CA99071AC" },
|
||||
]
|
||||
|
||||
[requirements]
|
||||
birl = { version = ">= 1.8.0 and < 2.0.0" }
|
||||
dot_env = { version = ">= 1.2.0 and < 2.0.0" }
|
||||
gleam_community_ansi = { version = ">= 1.4.3 and < 2.0.0" }
|
||||
gleam_erlang = { version = ">= 1.0.0 and < 2.0.0" }
|
||||
gleam_http = { version = ">= 4.0.0 and < 5.0.0" }
|
||||
gleam_httpc = { version = ">= 4.1.1 and < 5.0.0" }
|
||||
|
@ -29,4 +32,4 @@ gleam_json = { version = ">= 3.0.1 and < 4.0.0" }
|
|||
gleam_otp = { version = ">= 1.0.0 and < 2.0.0" }
|
||||
gleam_stdlib = { version = ">= 0.60.0 and < 1.0.0" }
|
||||
gleeunit = { version = ">= 1.5.1 and < 2.0.0" }
|
||||
spacetraders_sdk = { version = ">= 1.2.0 and < 2.0.0" }
|
||||
spacetraders_sdk = { version = ">= 1.3.0 and < 2.0.0" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import dot_env
|
||||
import dot_env/env
|
||||
import gleam/result
|
||||
import utils/auth.{type AccountToken, type AgentToken}
|
||||
import spacetraders_sdk/utils/auth.{type AccountToken, type AgentToken}
|
||||
|
||||
pub type Env {
|
||||
Env(account_token: AccountToken, agent_token: AgentToken)
|
||||
|
|
|
@ -1,13 +1,49 @@
|
|||
import birl
|
||||
import env
|
||||
import gleam/int
|
||||
import gleam/io
|
||||
import gleam/option
|
||||
import gleam_community/ansi
|
||||
import spacetraders_sdk
|
||||
import spacetraders_sdk/models/account_id
|
||||
import spacetraders_sdk/models/agent_symbol
|
||||
import spacetraders_sdk/models/faction_symbol
|
||||
import spacetraders_sdk/models/waypoint_symbol
|
||||
|
||||
pub fn main() -> Nil {
|
||||
let assert Ok(env.Env(agent_token:, ..)) = env.load_dotenv()
|
||||
let assert Ok(server_status) = spacetraders_sdk.get_server_status()
|
||||
echo server_status
|
||||
let assert Ok(account) = spacetraders_sdk.get_account(agent_token)
|
||||
echo account
|
||||
let assert Ok(agent) = spacetraders_sdk.get_agent(agent_token)
|
||||
echo agent
|
||||
Nil
|
||||
let now = birl.now()
|
||||
io.println("")
|
||||
io.println(ansi.bold(ansi.underline(ansi.blue("Account"))))
|
||||
io.println(ansi.bold("Id:\t\t") <> account_id.to_string(account.id))
|
||||
case account.email {
|
||||
option.Some(email) -> io.println(ansi.bold("Email:\t\t") <> email)
|
||||
option.None -> Nil
|
||||
}
|
||||
io.println(ansi.bold("Created At:\t") <> birl.to_iso8601(account.created_at))
|
||||
io.println("")
|
||||
io.println(ansi.bold(ansi.underline(ansi.magenta("Agent"))))
|
||||
io.println(ansi.bold("Symbol:\t\t") <> agent_symbol.to_string(agent.symbol))
|
||||
io.println(
|
||||
ansi.bold("Headquarters:\t")
|
||||
<> waypoint_symbol.to_string(agent.headquarters),
|
||||
)
|
||||
io.println(ansi.bold("Credits:\t") <> int.to_string(agent.credits))
|
||||
io.println(
|
||||
ansi.bold("Faction:\t") <> faction_symbol.to_string(agent.starting_faction),
|
||||
)
|
||||
io.println(ansi.bold("Ship Count:\t") <> int.to_string(agent.ship_count))
|
||||
io.println("")
|
||||
io.println(ansi.italic(
|
||||
"Server last reset "
|
||||
<> birl.legible_difference(now, server_status.reset_date),
|
||||
))
|
||||
io.println(ansi.italic(
|
||||
"Server will next reset "
|
||||
<> birl.legible_difference(now, server_status.server_resets.next),
|
||||
))
|
||||
io.println("")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue