Skip to content

Commit

Permalink
deps(clap): migrate uses of structopt to clap in api (#256)
Browse files Browse the repository at this point in the history
* deps(clap): migrate uses of structopt to clap in api

* use doc comments for help text

* chore: update Cargo.lock

Co-authored-by: chesedo <pieter@chesedo.me>
  • Loading branch information
Xavientois and chesedo authored Jul 13, 2022
1 parent ab56385 commit e6a4f4f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 109 deletions.
91 changes: 11 additions & 80 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ base64 = "0.13.0"
cargo = "0.62.0"
cargo-util = "0.1.2"
chrono = "0.4.19"
clap = { version = "3.1.18", features = ["derive"] }
env_logger = "0.9.0"
fqdn = "0.1.9"
futures = "0.3.21"
Expand All @@ -25,7 +26,6 @@ rand = "0.8.5"
rocket = { version = "0.5.0-rc.2", features = ["uuid", "serde_json", "json"] }
serde = "1.0.137"
sqlx = { version = "0.5.13", features = ["runtime-tokio-native-tls", "postgres"] }
structopt = "0.3.26"
tokio = { version = "1.19.2", features = ["full"] }
toml = "0.5.9"
tonic = "0.7.2"
Expand Down
43 changes: 17 additions & 26 deletions api/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,33 @@ use std::net::IpAddr;
use std::path::PathBuf;
use std::str::FromStr;

use clap::Parser;
use fqdn::FQDN;
use shuttle_common::Port;
use structopt::StructOpt;

#[derive(StructOpt)]
#[structopt(name = "shuttle")]
#[derive(Parser)]
#[clap(name = "shuttle")]
pub struct Args {
#[structopt(long, about = "Override the default root path for shuttle")]
/// Override the default root path for shuttle
#[clap(long)]
pub(crate) path: Option<PathBuf>,
#[structopt(
long,
about = "Override the default port for the proxy",
default_value = "8000"
)]
/// Override the default port for the proxy
#[clap(long, default_value = "8000")]
pub(crate) proxy_port: Port,
#[structopt(
long,
about = "Override the default port for the api",
default_value = "8001"
)]
/// Override the default port for the api
#[clap(long, default_value = "8001")]
pub(crate) api_port: Port,
#[structopt(
long,
about = "Override the default bind address",
default_value = "127.0.0.1"
)]
/// Override the default bind address
#[clap(long, default_value = "127.0.0.1")]
pub(crate) bind_addr: IpAddr,
#[structopt(long, about = "Fully qualified domain name deployed services are reachable at", parse(try_from_str = parse_fqdn))]
/// Fully qualified domain name deployed services are reachable at
#[clap(long, parse(try_from_str = parse_fqdn))]
pub(crate) proxy_fqdn: FQDN,
#[structopt(long, about = "Address to connect to the provisioning service")]
/// Address to connect to the provisioning service
#[clap(long)]
pub(crate) provisioner_address: String,
#[structopt(
long,
about = "Port provisioner is reachable at",
default_value = "5001"
)]
/// Port provisioner is reachable at
#[clap(long, default_value = "5001")]
pub(crate) provisioner_port: Port,
}

Expand Down
4 changes: 2 additions & 2 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use std::net::IpAddr;
use std::sync::Arc;

use auth_admin::Admin;
use clap::Parser;
use deployment::MAX_DEPLOYS;
use factory::ShuttleFactory;
use rocket::serde::json::Json;
use rocket::{tokio, Build, Data, Rocket, State};
use shuttle_common::project::ProjectName;
use shuttle_common::{DeploymentApiError, DeploymentMeta, Port};
use shuttle_service::SecretStore;
use structopt::StructOpt;
use uuid::Uuid;

use crate::args::Args;
Expand Down Expand Up @@ -192,7 +192,7 @@ async fn rocket() -> Rocket<Build> {
.filter_module("shuttle_service", log::LevelFilter::Debug)
.init();

let args: Args = Args::from_args();
let args: Args = Args::parse();
let build_system = FsBuildSystem::initialise(args.path).unwrap();
let deployment_manager = Arc::new(
DeploymentSystem::new(
Expand Down

0 comments on commit e6a4f4f

Please sign in to comment.