Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/clap v4 wip #3514

Closed
wants to merge 10 commits into from
Closed
33 changes: 11 additions & 22 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions implementations/rust/ockam/ockam_command/Cargo.toml
Expand Up @@ -49,7 +49,7 @@ anyhow = "1"
async-recursion = { version = "1.0.0" }
async-trait = "0.1"
atty = "0.2"
clap = { version = "3.2.17", features = ["derive", "cargo", "wrap_help"] }
clap = { version = "4.0.0-rc.2", features = ["derive", "cargo", "wrap_help"] }
cli-table = "0.4"
const-str = "0.4.3"
crossbeam-channel = "0.5"
Expand Down Expand Up @@ -77,7 +77,7 @@ tracing-error = "0.2"
tracing-subscriber = "0.3.9"
validator = "0.15"
colorful = "0.2"
clap_complete = "3.2.4"
clap_complete = "4.0.0-rc.1"

ockam = { path = "../ockam", version = "^0.76.0", features = ["software_vault"] }
ockam_api = { path = "../ockam_api", version = "0.19.0", features = ["std", "authenticators"] }
Expand Down
8 changes: 4 additions & 4 deletions implementations/rust/ockam/ockam_command/src/admin/mod.rs
Expand Up @@ -8,18 +8,18 @@ mod subscription;
const HELP_DETAIL: &str = "";

#[derive(Clone, Debug, Args)]
#[clap(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
#[command(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
pub struct AdminCommand {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: AdminSubCommand,

#[clap(flatten)]
#[command(flatten)]
pub cloud_opts: CloudOpts,
}

#[derive(Clone, Debug, Subcommand)]
pub enum AdminSubCommand {
#[clap(display_order = 800)]
#[command(display_order = 800)]
Subscription(subscription::SubscriptionCommand),
}

Expand Down
Expand Up @@ -2,6 +2,7 @@ use anyhow::Context as _;
use std::path::PathBuf;

use clap::{Args, Subcommand};
use clap::builder::{NonEmptyStringValueParser};

use ockam::Context;
use ockam_api::cloud::subscription::{ActivateSubscription, Subscription};
Expand All @@ -17,12 +18,12 @@ use crate::{help, CommandGlobalOpts};
const HELP_DETAIL: &str = "";

#[derive(Clone, Debug, Args)]
#[clap(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
#[command(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
pub struct SubscriptionCommand {
#[clap(subcommand)]
#[command(subcommand)]
subcommand: SubscriptionSubcommand,

#[clap(flatten)]
#[command(flatten)]
cloud_opts: CloudOpts,
}

Expand All @@ -34,11 +35,11 @@ pub enum SubscriptionSubcommand {
json: PathBuf,

/// Space ID to attach the subscription to
#[clap(
name = "space",
#[arg(
id = "space",
value_name = "SPACE_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
space_id: String,
},
Expand All @@ -50,16 +51,16 @@ pub enum SubscriptionSubcommand {
/// You can use either the subscription ID or the space ID.
Unsubscribe {
/// Subscription ID
#[clap(group = "id")]
#[arg(group = "id")]
subscription_id: Option<String>,

/// Space ID
#[clap(
#[arg(
group = "id",
name = "space",
id = "space",
value_name = "SPACE_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
space_id: Option<String>,
},
Expand All @@ -70,7 +71,7 @@ pub enum SubscriptionSubcommand {

#[derive(Clone, Debug, Args)]
pub struct SubscriptionUpdate {
#[clap(subcommand)]
#[command(subcommand)]
subcommand: SubscriptionUpdateSubcommand,
}

Expand All @@ -83,22 +84,22 @@ enum SubscriptionUpdateSubcommand {
json: PathBuf,

/// Subscription ID
#[clap(
#[arg(
group = "id",
name = "subscription",
id = "subscription",
value_name = "SUBSCRIPTION_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
subscription_id: Option<String>,

/// Space ID
#[clap(
#[arg(
group = "id",
name = "space",
id = "space",
value_name = "SPACE_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
space_id: Option<String>,
},
Expand All @@ -107,22 +108,22 @@ enum SubscriptionUpdateSubcommand {
/// You can use either the subscription ID or the space ID.
Space {
/// Subscription ID
#[clap(
#[arg(
group = "id",
name = "subscription",
id = "subscription",
value_name = "SUBSCRIPTION_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
subscription_id: Option<String>,

/// Space ID
#[clap(
#[arg(
group = "id",
name = "current_space",
id = "current_space",
value_name = "SPACE_ID",
long,
forbid_empty_values = true
value_parser(NonEmptyStringValueParser::new())
)]
space_id: Option<String>,

Expand Down
13 changes: 7 additions & 6 deletions implementations/rust/ockam/ockam_command/src/authenticated.rs
Expand Up @@ -2,16 +2,17 @@ use crate::help;
use crate::util::embedded_node;
use anyhow::{anyhow, Result};
use clap::{Args, Subcommand};
use clap::builder::{NonEmptyStringValueParser};
use ockam::{Context, TcpTransport};
use ockam_api::auth;
use ockam_multiaddr::MultiAddr;

const HELP_DETAIL: &str = "";

#[derive(Clone, Debug, Args)]
#[clap(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
#[command(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
pub struct AuthenticatedCommand {
#[clap(subcommand)]
#[command(subcommand)]
subcommand: AuthenticatedSubcommand,
}

Expand All @@ -23,11 +24,11 @@ pub enum AuthenticatedSubcommand {
addr: MultiAddr,

/// Subject identifier
#[clap(long, forbid_empty_values = true)]
#[arg(long, value_parser(NonEmptyStringValueParser::new()))]
id: String,

/// Attribute key.
#[clap(forbid_empty_values = true)]
#[arg(value_parser(NonEmptyStringValueParser::new()))]
key: String,
},
/// Delete attribute
Expand All @@ -36,11 +37,11 @@ pub enum AuthenticatedSubcommand {
addr: MultiAddr,

/// Subject identifier
#[clap(long, forbid_empty_values = true)]
#[arg(long, value_parser(NonEmptyStringValueParser::new()))]
id: String,

/// Attribute key.
#[clap(forbid_empty_values = true)]
#[arg(value_parser(NonEmptyStringValueParser::new()))]
key: String,
},
}
Expand Down
Expand Up @@ -28,10 +28,10 @@ ABOUT:

/// Generate shell completion scripts
#[derive(Clone, Debug, Args)]
#[clap(arg_required_else_help = true, help_template = help::template(HELP_DETAIL))]
#[command(arg_required_else_help = true, help_template = help::template(HELP_DETAIL))]
pub struct CompletionCommand {
/// The type of shell (bash, zsh, fish)
#[clap(display_order = 900, long, short)]
#[arg(display_order = 900, long, short)]
shell: Shell,
}

Expand Down
Expand Up @@ -17,9 +17,9 @@ use clap::{Args, Subcommand};
const HELP_DETAIL: &str = "";

#[derive(Clone, Debug, Args)]
#[clap(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
#[command(hide = help::hide(), help_template = help::template(HELP_DETAIL))]
pub struct ConfigurationCommand {
#[clap(subcommand)]
#[command(subcommand)]
subcommand: ConfigurationSubcommand,
}

Expand Down
Expand Up @@ -8,10 +8,10 @@ use crate::CommandGlobalOpts;

#[derive(Clone, Debug, Args)]
pub struct GetCredentialCommand {
#[clap(flatten)]
#[command(flatten)]
pub node_opts: NodeOpts,

#[clap(long)]
#[arg(long)]
pub overwrite: bool,
}

Expand Down
Expand Up @@ -9,14 +9,14 @@ use crate::CommandGlobalOpts;
use clap::{Args, Subcommand};

#[derive(Clone, Debug, Args)]
#[clap(
#[command(
hide = help::hide(),
help_template = help::template(""),
arg_required_else_help = true,
subcommand_required = true
)]
pub struct CredentialCommand {
#[clap(subcommand)]
#[command(subcommand)]
subcommand: CredentialSubcommand,
}

Expand Down
Expand Up @@ -10,13 +10,13 @@ use crate::CommandGlobalOpts;

#[derive(Clone, Debug, Args)]
pub struct PresentCredentialCommand {
#[clap(flatten)]
#[command(flatten)]
pub node_opts: NodeOpts,

#[clap(long, display_order = 900, name = "ROUTE")]
#[arg(long, display_order = 900, id = "ROUTE")]
pub to: MultiAddr,

#[clap(short, long)]
#[arg(short, long)]
pub oneway: bool,
}

Expand Down
4 changes: 2 additions & 2 deletions implementations/rust/ockam/ockam_command/src/enroll.rs
Expand Up @@ -29,9 +29,9 @@ const HELP_DETAIL: &str = "";

/// Enroll with Ockam Orchestrator
#[derive(Clone, Debug, Args)]
#[clap(help_template = help::template(HELP_DETAIL))]
#[command(help_template = help::template(HELP_DETAIL))]
pub struct EnrollCommand {
#[clap(flatten)]
#[command(flatten)]
pub cloud_opts: CloudOpts,
}

Expand Down