diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e6722da..f0b0f73 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -24,6 +24,55 @@ dependencies = [ "version_check", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "async-trait" version = "0.1.68" @@ -157,6 +206,54 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.16", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "cpufeatures" version = "0.2.7" @@ -235,6 +332,27 @@ dependencies = [ "serde", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -475,6 +593,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -568,6 +692,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -615,6 +762,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + [[package]] name = "lock_api" version = "0.4.9" @@ -729,7 +882,7 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -750,6 +903,7 @@ name = "packager" version = "0.1.0" dependencies = [ "axum", + "clap", "futures", "hyper", "maud", @@ -928,6 +1082,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.20.8" @@ -1230,6 +1398,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.109" @@ -1545,6 +1719,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.3.3" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 9780ac5..e5253a9 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -3,6 +3,10 @@ name = "packager" version = "0.1.0" edition = "2021" +[dependencies.clap] +version = "4.3.0" +features = ["derive"] + [dependencies.axum] version = "0.6" features = ["headers"] diff --git a/rust/run-test-instance.sh b/rust/run-test-instance.sh new file mode 100755 index 0000000..acdfca9 --- /dev/null +++ b/rust/run-test-instance.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +sleep 100 +set -o nounset + +port="${1}" + +db="$(mktemp)" + +export SQLX_OFFLINE=true +export DATABASE_URL="sqlite://${db}" + +cargo run -- --port "${port}" diff --git a/rust/src/components/inventory.rs b/rust/src/components/inventory.rs index 5a87697..fbe8a26 100644 --- a/rust/src/components/inventory.rs +++ b/rust/src/components/inventory.rs @@ -46,6 +46,7 @@ impl InventoryCategoryList { html!( table + #category-list ."table" ."table-auto" ."border-collapse" diff --git a/rust/src/components/mod.rs b/rust/src/components/mod.rs index 4aa2ee8..99012ff 100644 --- a/rust/src/components/mod.rs +++ b/rust/src/components/mod.rs @@ -35,6 +35,7 @@ impl Root { hx-boost="true" { header + #header ."h-full" ."bg-gray-200" ."p-5" @@ -53,7 +54,7 @@ impl Root { ."gap-3" { img ."h-12" src="/assets/luggage.svg"; - a href="/" { "Packager" } + a #home href="/" { "Packager" } } nav ."grow" @@ -64,12 +65,14 @@ impl Root { ."content-stretch" { a href="/inventory/" + #header-link-inventory ."h-full" ."text-lg" ."font-bold"[matches!(active_page, TopLevelPage::Inventory)] ."underline"[matches!(active_page, TopLevelPage::Inventory)] { "Inventory" } a href="/trips/" + #header-link-trips ."h-full" ."text-lg" ."font-bold"[matches!(active_page, TopLevelPage::Trips)] diff --git a/rust/src/main.rs b/rust/src/main.rs index 1404592..9c960b5 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -42,6 +42,15 @@ pub struct AppState { client_state: ClientState, } +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + #[arg(long)] + port: Option, +} + #[derive(Clone)] pub struct ClientState { pub active_category_id: Option, @@ -140,7 +149,9 @@ async fn main() -> Result<(), sqlx::Error> { // ); .with_state(state); - let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); + let args = Args::parse(); + + let addr = SocketAddr::from(([127, 0, 0, 1], args.port.unwrap_or(3000))); tracing::debug!("listening on {}", addr); axum::Server::bind(&addr) .serve(app.into_make_service())