Skip to content

Commit 257387c

Browse files
committed
Replace "open-api run" subcomands --port with --address. #22
1 parent dfe60da commit 257387c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

trailbase-cli/src/args.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ pub struct EmailArgs {
144144
pub enum OpenApiSubCommands {
145145
Print,
146146
Run {
147-
#[arg(long, default_value_t = 4004)]
148-
port: u16,
147+
/// Authority (<host>:<port>) the HTTP server binds to (Default: localhost:4000).
148+
#[arg(short, long, env, default_value = "localhost:4004")]
149+
address: String,
149150
},
150151
}
151152

trailbase-cli/src/bin/trail.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,11 @@ async fn async_main() -> Result<(), BoxError> {
9797
use utoipa::OpenApi;
9898
use utoipa_swagger_ui::SwaggerUi;
9999

100-
let run_server = |port: u16| async move {
100+
let run_server = |addr: String| async move {
101101
let router = axum::Router::new().merge(
102102
SwaggerUi::new("/docs").url("/api/openapi.json", trailbase::openapi::Doc::openapi()),
103103
);
104104

105-
let addr = format!("localhost:{port}");
106105
let listener = tokio::net::TcpListener::bind(addr.clone()).await.unwrap();
107106
log::info!("docs @ http://{addr}/docs 🚀");
108107

@@ -114,11 +113,11 @@ async fn async_main() -> Result<(), BoxError> {
114113
let json = trailbase::openapi::Doc::openapi().to_pretty_json()?;
115114
println!("{json}");
116115
}
117-
Some(OpenApiSubCommands::Run { port }) => {
118-
run_server(port).await;
116+
Some(OpenApiSubCommands::Run { address }) => {
117+
run_server(address).await;
119118
}
120119
None => {
121-
run_server(4004).await;
120+
run_server("localhost:4004".to_string()).await;
122121
}
123122
}
124123
}

0 commit comments

Comments
 (0)