From 6392d589c6491d8e166aac00cf735fbc23aaec63 Mon Sep 17 00:00:00 2001 From: priks Date: Sun, 8 Jan 2023 09:59:26 +0530 Subject: [PATCH 1/8] Upgraded to clap v4 --- Cargo.lock | 10 +++++----- cargo-shuttle/Cargo.toml | 11 +++++++---- cargo-shuttle/src/args.rs | 19 ++++++------------- provisioner/Cargo.toml | 7 +++++-- provisioner/src/args.rs | 2 +- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c2959bc4..a482bbe37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1422,7 +1422,7 @@ dependencies = [ "cargo-edit", "cargo_metadata", "chrono", - "clap 3.2.23", + "clap 4.0.27", "clap_complete", "crossbeam-channel", "crossterm", @@ -1602,11 +1602,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" dependencies = [ - "clap 3.2.23", + "clap 4.0.27", ] [[package]] @@ -5922,7 +5922,7 @@ version = "0.8.0" dependencies = [ "aws-config", "aws-sdk-rds", - "clap 3.2.23", + "clap 4.0.27", "ctor", "fqdn", "mongodb", diff --git a/cargo-shuttle/Cargo.toml b/cargo-shuttle/Cargo.toml index 16148169d..d9218b2c0 100644 --- a/cargo-shuttle/Cargo.toml +++ b/cargo-shuttle/Cargo.toml @@ -15,8 +15,8 @@ cargo = "0.65.0" cargo-edit = { version = "0.11.6", features = ["cli"] } cargo_metadata = "0.15.2" chrono = { workspace = true } -clap = { version = "3.2.17", features = ["derive", "env"] } -clap_complete = "3.2.5" +clap = { version = "4.0.27", features = ["derive", "env"] } +clap_complete = "4.0.7" crossbeam-channel = "0.5.6" crossterm = "0.25.0" dialoguer = { version = "0.10.2", features = ["fuzzy-select"] } @@ -36,7 +36,10 @@ reqwest-middleware = "0.2.0" reqwest-retry = "0.2.0" serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -sqlx = { version = "0.6.2", features = ["runtime-tokio-native-tls", "postgres"] } +sqlx = { version = "0.6.2", features = [ + "runtime-tokio-native-tls", + "postgres", +] } strum = { version = "0.24.1", features = ["derive"] } tar = "0.4.38" tokio = { version = "1.22.0", features = ["macros"] } @@ -51,7 +54,7 @@ webbrowser = "0.8.2" [dependencies.shuttle-common] workspace = true -features= ["models"] +features = ["models"] [dependencies.shuttle-secrets] version = "0.8.0" diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index bae3db8ce..3406ae244 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -5,6 +5,7 @@ use std::{ path::PathBuf, }; +use clap::builder::PossibleValue; use clap::Parser; use clap_complete::Shell; use shuttle_common::project::ProjectName; @@ -18,10 +19,10 @@ use crate::init::Framework; about, // Cargo passes in the subcommand name to the invoked executable. Use a // hidden, optional positional argument to deal with it. - arg(clap::Arg::with_name("dummy") - .possible_value("shuttle") + arg(clap::Arg::new("dummy") + .value_parser([PossibleValue::new("shuttle")]) .required(false) - .hidden(true)) + .hide(true)) )] pub struct Args { /// run this command against the api at the supplied url @@ -38,12 +39,7 @@ pub struct Args { #[derive(Parser, Debug)] pub struct ProjectArgs { /// Specify the working directory - #[clap( - global = true, - long, - parse(try_from_os_str = parse_path), - default_value = ".", - )] + #[clap(global = true, long, value_parser, default_value = ".")] pub working_directory: PathBuf, /// Specify the name of the project (overrides crate name) #[clap(global = true, long)] @@ -186,10 +182,7 @@ pub struct InitArgs { #[clap(flatten)] pub login_args: LoginArgs, /// Path to initialize a new shuttle project - #[clap( - parse(try_from_os_str = parse_init_path), - default_value = ".", - )] + #[clap(value_parser, default_value = ".")] pub path: PathBuf, } diff --git a/provisioner/Cargo.toml b/provisioner/Cargo.toml index 91b1bff91..75cc480dc 100644 --- a/provisioner/Cargo.toml +++ b/provisioner/Cargo.toml @@ -10,12 +10,15 @@ publish = false [dependencies] aws-config = "0.51.0" aws-sdk-rds = "0.21.0" -clap = { version = "3.2.17", features = ["derive", "env"] } +clap = { version = "4.0.27", features = ["derive", "env"] } fqdn = "0.2.3" mongodb = "2.3.1" prost = "0.11.2" rand = "0.8.5" -sqlx = { version = "0.6.2", features = ["postgres", "runtime-tokio-native-tls"] } +sqlx = { version = "0.6.2", features = [ + "postgres", + "runtime-tokio-native-tls", +] } thiserror = { workspace = true } tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] } tonic = "0.8.3" diff --git a/provisioner/src/args.rs b/provisioner/src/args.rs index 85b5f875f..4e05ba467 100644 --- a/provisioner/src/args.rs +++ b/provisioner/src/args.rs @@ -26,7 +26,7 @@ pub struct Args { pub shared_mongodb_uri: String, /// Fully qualified domain name this provisioner instance is reachable at - #[clap(long, env = "PROVISIONER_FQDN", parse(try_from_str = parse_fqdn))] + #[clap(long, env = "PROVISIONER_FQDN", value_parser = parse_fqdn)] pub fqdn: FQDN, /// Address the provisioned PostgreSQL DB can be reached at on the internal network From 2773f71a8fcda5bb7644133c000f5c560fc4db8f Mon Sep 17 00:00:00 2001 From: priks Date: Mon, 9 Jan 2023 16:21:46 +0530 Subject: [PATCH 2/8] Upgraded to clap v4 --- cargo-shuttle/src/args.rs | 60 +++++++++++++++++++-------------------- provisioner/src/args.rs | 16 +++++------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index 3406ae244..5a02468c9 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -14,7 +14,7 @@ use uuid::Uuid; use crate::init::Framework; #[derive(Parser)] -#[clap( +#[command( version, about, // Cargo passes in the subcommand name to the invoked executable. Use a @@ -27,11 +27,11 @@ use crate::init::Framework; pub struct Args { /// run this command against the api at the supplied url /// (allows targeting a custom deployed instance for this command only) - #[clap(long, env = "SHUTTLE_API")] + #[arg(long, env = "SHUTTLE_API")] pub api_url: Option, - #[clap(flatten)] + #[command(flatten)] pub project_args: ProjectArgs, - #[clap(subcommand)] + #[command(subcommand)] pub cmd: Command, } @@ -39,10 +39,10 @@ pub struct Args { #[derive(Parser, Debug)] pub struct ProjectArgs { /// Specify the working directory - #[clap(global = true, long, value_parser, default_value = ".")] + #[arg(global = true, long)] pub working_directory: PathBuf, /// Specify the name of the project (overrides crate name) - #[clap(global = true, long)] + #[arg(global = true, long)] pub name: Option, } @@ -51,17 +51,17 @@ pub enum Command { /// deploy a shuttle service Deploy(DeployArgs), /// manage deployments of a shuttle service - #[clap(subcommand)] + #[command(subcommand)] Deployment(DeploymentCommand), /// create a new shuttle service Init(InitArgs), /// generate shell completions Generate { /// which shell - #[clap(short, long, env, default_value_t = Shell::Bash)] + #[arg(short, long, env, default_value_t = Shell::Bash)] shell: Shell, /// output to file or stdout by default - #[clap(short, long, env)] + #[arg(short, long, env)] output: Option, }, /// view the status of a shuttle service @@ -71,7 +71,7 @@ pub enum Command { /// Deployment ID to get logs for. Defaults to currently running deployment id: Option, - #[clap(short, long)] + #[arg(short, long)] /// Follow log output follow: bool, }, @@ -86,7 +86,7 @@ pub enum Command { /// run a shuttle service locally Run(RunArgs), /// manage a project on shuttle - #[clap(subcommand)] + #[command(subcommand)] Project(ProjectCommand), } @@ -111,7 +111,7 @@ pub enum ProjectCommand { Rm, /// show the status of this project's environment on shuttle Status { - #[clap(short, long)] + #[arg(short, long)] /// Follow status of project command follow: bool, }, @@ -120,69 +120,69 @@ pub enum ProjectCommand { #[derive(Parser, Clone, Debug)] pub struct LoginArgs { /// api key for the shuttle platform - #[clap(long)] + #[arg(long)] pub api_key: Option, } #[derive(Parser)] pub struct DeployArgs { /// allow dirty working directories to be packaged - #[clap(long)] + #[arg(long)] pub allow_dirty: bool, /// allows pre-deploy tests to be skipped - #[clap(long)] + #[arg(long)] pub no_test: bool, } #[derive(Parser, Debug)] pub struct RunArgs { /// port to start service on - #[clap(long, default_value = "8000")] + #[arg(long, default_value = "8000")] pub port: u16, } #[derive(Parser, Debug)] pub struct InitArgs { /// Initialize with actix-web framework - #[clap(long="actix-web", conflicts_with_all = &["axum", "rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long="actix-web", conflicts_with_all = &["axum", "rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub actix_web: bool, /// Initialize with axum framework - #[clap(long, conflicts_with_all = &["actix-web","rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub axum: bool, /// Initialize with rocket framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub rocket: bool, /// Initialize with tide framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub tide: bool, /// Initialize with tower framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub tower: bool, /// Initialize with poem framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "serenity", "warp", "salvo", "thruster", "no-framework"])] pub poem: bool, /// Initialize with salvo framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "thruster", "no-framework"])] pub salvo: bool, /// Initialize with serenity framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "thruster", "no-framework"])] pub serenity: bool, /// Initialize with warp framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "serenity", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "serenity", "salvo", "thruster", "no-framework"])] pub warp: bool, /// Initialize with thruster framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "no-framework"])] pub thruster: bool, /// Initialize without a framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "thruster"])] + #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "thruster"])] pub no_framework: bool, /// Whether to create the environment for this project on Shuttle - #[clap(long)] + #[arg(long)] pub new: bool, - #[clap(flatten)] + #[command(flatten)] pub login_args: LoginArgs, /// Path to initialize a new shuttle project - #[clap(value_parser, default_value = ".")] + #[arg()] pub path: PathBuf, } diff --git a/provisioner/src/args.rs b/provisioner/src/args.rs index 4e05ba467..e407acd1b 100644 --- a/provisioner/src/args.rs +++ b/provisioner/src/args.rs @@ -7,34 +7,34 @@ use clap::Parser; use fqdn::FQDN; #[derive(Parser, Debug)] -#[clap(author, version, about, long_about = None)] +#[command(author, version, about, long_about = None)] pub struct Args { /// Address to bind provisioner on - #[clap(long, env = "PROVISIONER_IP", default_value_t = Ipv4Addr::LOCALHOST.into())] + #[arg(long, env = "PROVISIONER_IP", default_value_t = Ipv4Addr::LOCALHOST.into())] pub ip: IpAddr, /// Port to start provisioner on - #[clap(long, env = "PROVISIONER_PORT", default_value_t = 5001)] + #[arg(long, env = "PROVISIONER_PORT", default_value_t = 5001)] pub port: u16, /// URI to connect to Postgres for managing shared DB resources - #[clap(long, env = "PROVISIONER_PG_URI", hide_env_values = true)] + #[arg(long, env = "PROVISIONER_PG_URI", hide_env_values = true)] pub shared_pg_uri: String, /// URI to connect to MongoDb for managing shared DB resources - #[clap(long, env = "PROVISIONER_MONGODB_URI", hide_env_values = true)] + #[arg(long, env = "PROVISIONER_MONGODB_URI", hide_env_values = true)] pub shared_mongodb_uri: String, /// Fully qualified domain name this provisioner instance is reachable at - #[clap(long, env = "PROVISIONER_FQDN", value_parser = parse_fqdn)] + #[arg(long, env = "PROVISIONER_FQDN", value_parser = parse_fqdn)] pub fqdn: FQDN, /// Address the provisioned PostgreSQL DB can be reached at on the internal network - #[clap(long, env = "PROVISIONER_PG_ADDRESS", default_value = "pg")] + #[arg(long, env = "PROVISIONER_PG_ADDRESS", default_value = "pg")] pub internal_pg_address: String, /// Address the provisioned MongoDB can be reached at on the internal network - #[clap(long, env = "PROVISIONER_MONGODB_ADDRESS", default_value = "mongodb")] + #[arg(long, env = "PROVISIONER_MONGODB_ADDRESS", default_value = "mongodb")] pub internal_mongodb_address: String, } From 91d476362c8be19eec93ec5327a4f967e9453e36 Mon Sep 17 00:00:00 2001 From: priks Date: Mon, 9 Jan 2023 19:14:07 +0530 Subject: [PATCH 3/8] Upgraded to clap v4 --- cargo-shuttle/src/args.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index 5a02468c9..a6da8be3c 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -42,7 +42,7 @@ pub struct ProjectArgs { #[arg(global = true, long)] pub working_directory: PathBuf, /// Specify the name of the project (overrides crate name) - #[arg(global = true, long)] + #[arg(global = true, long, default_value = ".")] pub name: Option, } @@ -144,37 +144,37 @@ pub struct RunArgs { #[derive(Parser, Debug)] pub struct InitArgs { /// Initialize with actix-web framework - #[arg(long="actix-web", conflicts_with_all = &["axum", "rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long="actix_web", conflicts_with_all = &["axum", "rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub actix_web: bool, /// Initialize with axum framework - #[arg(long, conflicts_with_all = &["actix-web","rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","rocket", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub axum: bool, /// Initialize with rocket framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "tide", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub rocket: bool, /// Initialize with tide framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tower", "poem", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub tide: bool, /// Initialize with tower framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "poem", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "poem", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub tower: bool, /// Initialize with poem framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "serenity", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "serenity", "warp", "salvo", "thruster", "no_framework"])] pub poem: bool, /// Initialize with salvo framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "thruster", "no_framework"])] pub salvo: bool, /// Initialize with serenity framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "thruster", "no_framework"])] pub serenity: bool, /// Initialize with warp framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "serenity", "salvo", "thruster", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "serenity", "salvo", "thruster", "no_framework"])] pub warp: bool, /// Initialize with thruster framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "no-framework"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "no_framework"])] pub thruster: bool, /// Initialize without a framework - #[arg(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "thruster"])] + #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "salvo", "serenity", "thruster"])] pub no_framework: bool, /// Whether to create the environment for this project on Shuttle #[arg(long)] @@ -182,7 +182,7 @@ pub struct InitArgs { #[command(flatten)] pub login_args: LoginArgs, /// Path to initialize a new shuttle project - #[arg()] + #[arg(default_value = ".")] pub path: PathBuf, } From 2d2c1933224f70b2db718009a8db57620cbc3107 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:02:03 +0100 Subject: [PATCH 4/8] feat: reimplement parse_path --- cargo-shuttle/src/args.rs | 30 +++++++++++++++--------------- cargo-shuttle/src/lib.rs | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index a6da8be3c..3396f981e 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -1,11 +1,11 @@ use std::{ - ffi::OsStr, + ffi::OsString, fs::{canonicalize, create_dir_all}, io::{self, ErrorKind}, path::PathBuf, }; -use clap::builder::PossibleValue; +use clap::builder::{OsStringValueParser, PossibleValue, TypedValueParser}; use clap::Parser; use clap_complete::Shell; use shuttle_common::project::ProjectName; @@ -39,10 +39,10 @@ pub struct Args { #[derive(Parser, Debug)] pub struct ProjectArgs { /// Specify the working directory - #[arg(global = true, long)] + #[arg(global = true, long, default_value = ".", value_parser = OsStringValueParser::new().try_map(parse_path))] pub working_directory: PathBuf, /// Specify the name of the project (overrides crate name) - #[arg(global = true, long, default_value = ".")] + #[arg(global = true, long)] pub name: Option, } @@ -182,7 +182,7 @@ pub struct InitArgs { #[command(flatten)] pub login_args: LoginArgs, /// Path to initialize a new shuttle project - #[arg(default_value = ".")] + #[arg(default_value = ".", value_parser = OsStringValueParser::new().try_map(parse_path) )] pub path: PathBuf, } @@ -217,21 +217,21 @@ impl InitArgs { } // Helper function to parse and return the absolute path -fn parse_path(path: &OsStr) -> Result { - canonicalize(path).map_err(|e| { - io::Error::new( - ErrorKind::InvalidInput, - format!("could not turn {path:?} into a real path: {e}"), - ) - }) +fn parse_path(path: OsString) -> Result { + canonicalize(&path).map_err(|e| format!("could not turn {path:?} into a real path: {e}")) } // Helper function to parse, create if not exists, and return the absolute path -pub(crate) fn parse_init_path(path: &OsStr) -> Result { +pub(crate) fn parse_init_path(path: OsString) -> Result { // Create the directory if does not exist - create_dir_all(path)?; + create_dir_all(&path)?; - parse_path(path) + parse_path(path.clone()).map_err(|e| { + io::Error::new( + ErrorKind::InvalidInput, + format!("could not turn {path:?} into a real path: {e}"), + ) + }) } #[cfg(test)] diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 4dc9ba980..c3a43b5ef 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -150,7 +150,7 @@ impl Shuttle { .default(".".to_owned()) .interact()?; println!(); - args::parse_init_path(&OsString::from(directory_str))? + args::parse_init_path(OsString::from(directory_str))? } else { args.path.clone() }; From 7559cf38160ab0a7c97b336f71bef40fc4be2faa Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:24:54 +0100 Subject: [PATCH 5/8] fix: framework conflict hyphens from merge --- cargo-shuttle/src/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index b54f23a05..4ac40b10c 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -171,7 +171,7 @@ pub struct InitArgs { #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "poise", "salvo", "thruster", "no_framework"])] pub serenity: bool, /// Initialize with poise framework - #[clap(long, conflicts_with_all = &["actix-web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "salvo", "thruster", "no-framework"])] + #[clap(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "warp", "serenity", "salvo", "thruster", "no_framework"])] pub poise: bool, /// Initialize with warp framework #[arg(long, conflicts_with_all = &["actix_web","axum", "rocket", "tide", "tower", "poem", "serenity", "poise", "salvo", "thruster", "no_framework"])] From 90bf1d9720708dfbf9ef1dd1368af9926a6abd9d Mon Sep 17 00:00:00 2001 From: priks Date: Fri, 3 Feb 2023 17:06:08 +0530 Subject: [PATCH 6/8] release-flag --- cargo-shuttle/src/args.rs | 5 ++++- cargo-shuttle/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cargo-shuttle/src/args.rs b/cargo-shuttle/src/args.rs index 15fc12b24..4663bb9b1 100644 --- a/cargo-shuttle/src/args.rs +++ b/cargo-shuttle/src/args.rs @@ -142,8 +142,11 @@ pub struct RunArgs { #[arg(long, default_value = "8000")] pub port: u16, /// use 0.0.0.0 instead of localhost (for usage with local external devices) - #[clap(long)] + #[arg(long)] pub external: bool, + /// Use release mode for building the project. + #[arg(long, short = 'r')] + pub release: bool, } #[derive(Parser, Debug)] diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 883106e94..811207675 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -390,7 +390,7 @@ impl Shuttle { "Building".bold().green(), working_directory.display() ); - let so_path = build_crate(id, working_directory, false, tx).await?; + let so_path = build_crate(id, working_directory, run_args.release, tx).await?; trace!("loading secrets"); let secrets_path = working_directory.join("Secrets.toml"); From b7a0eb9be95956463bbd28c6a262f68cdb985675 Mon Sep 17 00:00:00 2001 From: priks Date: Fri, 3 Feb 2023 17:31:08 +0530 Subject: [PATCH 7/8] release-flag --- cargo-shuttle/tests/integration/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo-shuttle/tests/integration/run.rs b/cargo-shuttle/tests/integration/run.rs index 3207d019c..cbc9bf374 100644 --- a/cargo-shuttle/tests/integration/run.rs +++ b/cargo-shuttle/tests/integration/run.rs @@ -16,7 +16,7 @@ async fn cargo_shuttle_run(working_directory: &str, external: bool) -> String { format!("http://0.0.0.0:{port}") }; - let run_args = RunArgs { port, external }; + let run_args = RunArgs { port, external, release: false }; let runner = Shuttle::new().unwrap().run(Args { api_url: Some("http://shuttle.invalid:80".to_string()), From 624cebe15a767ce7fd8bad8aba5cd7d272fdb919 Mon Sep 17 00:00:00 2001 From: priks Date: Fri, 3 Feb 2023 17:38:34 +0530 Subject: [PATCH 8/8] release-flag --- cargo-shuttle/tests/integration/run.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cargo-shuttle/tests/integration/run.rs b/cargo-shuttle/tests/integration/run.rs index cbc9bf374..e11dbe3dd 100644 --- a/cargo-shuttle/tests/integration/run.rs +++ b/cargo-shuttle/tests/integration/run.rs @@ -16,7 +16,11 @@ async fn cargo_shuttle_run(working_directory: &str, external: bool) -> String { format!("http://0.0.0.0:{port}") }; - let run_args = RunArgs { port, external, release: false }; + let run_args = RunArgs { + port, + external, + release: false, + }; let runner = Shuttle::new().unwrap().run(Args { api_url: Some("http://shuttle.invalid:80".to_string()),