diff --git a/unshell-server/Cargo.lock b/unshell-server/Cargo.lock index 80cf506..cf4a34d 100644 --- a/unshell-server/Cargo.lock +++ b/unshell-server/Cargo.lock @@ -31,6 +31,56 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -308,6 +358,46 @@ dependencies = [ "inout", ] +[[package]] +name = "clap" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + [[package]] name = "cmake" version = "0.1.54" @@ -317,6 +407,12 @@ dependencies = [ "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -493,6 +589,12 @@ dependencies = [ "http", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hex" version = "0.4.3" @@ -630,6 +732,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + [[package]] name = "itoa" version = "1.0.15" @@ -773,6 +881,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "parking_lot" version = "0.12.5" @@ -1125,6 +1239,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" @@ -1345,6 +1465,7 @@ dependencies = [ "axum-extra", "bcrypt", "chrono", + "clap", "jsonwebtoken", "serde", "serde_json", @@ -1366,6 +1487,12 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "version_check" version = "0.9.5" diff --git a/unshell-server/Cargo.toml b/unshell-server/Cargo.toml index 842f99c..58f455b 100644 --- a/unshell-server/Cargo.toml +++ b/unshell-server/Cargo.toml @@ -22,6 +22,7 @@ tokio = {version="1.48.0", features = ["full"] } bcrypt = "0.17.1" chrono = "0.4.42" static_init = "1.0.4" +clap = {version = "4.5.53", features = ["derive"]} # tracing = "0.1.43" # tracing-subscriber = {version="0.3.22", features = ["env-filter"] } diff --git a/unshell-server/src/api/app.rs b/unshell-server/src/api/app.rs index 014b0ba..513b0b7 100644 --- a/unshell-server/src/api/app.rs +++ b/unshell-server/src/api/app.rs @@ -29,7 +29,7 @@ pub async fn start_api(address: &str) { pub async fn protected( Path(path): Path, - Extension(_currentUser): Extension, + Extension(_): Extension, ) -> impl IntoResponse { info!("{}", path); // Json(UserResponse { diff --git a/unshell-server/src/database.rs b/unshell-server/src/database.rs new file mode 100644 index 0000000..cbfddc7 --- /dev/null +++ b/unshell-server/src/database.rs @@ -0,0 +1,5 @@ +// Calc 3 ends Tuesday next week + +pub struct Database { + // db: +} diff --git a/unshell-server/src/lib.rs b/unshell-server/src/lib.rs index 3f25ad4..f6fb759 100644 --- a/unshell-server/src/lib.rs +++ b/unshell-server/src/lib.rs @@ -1,4 +1,5 @@ // #![macro_use] mod api; +mod database; pub use api::app::start_api; diff --git a/unshell-server/src/main.rs b/unshell-server/src/main.rs index 2c83bf3..35c6475 100644 --- a/unshell-server/src/main.rs +++ b/unshell-server/src/main.rs @@ -1,8 +1,30 @@ use unshell_server::start_api; +use clap::Parser; +use static_init::dynamic; + +#[dynamic] +static DEFAULT_HOST: String = "localhost".to_string(); + +/// A fictional versioning CLI +#[derive(Debug, Parser)] +#[command(name = "unshell-server")] +#[command(about = "UnShell server", long_about = None)] +pub struct Args { + /// Host to listen on + #[clap(long, default_value_t = DEFAULT_HOST.clone())] + host: String, + + /// Port to listen + #[arg(short, long, default_value_t = 3000)] + port: usize, +} + #[tokio::main] async fn main() { + let args = Args::parse(); + unshell_lib::logger::PrettyLogger::init(); - start_api("localhost:3000").await; + start_api(&format!("{}:{}", args.host, args.port)).await; }