Skip to content

Commit

Permalink
Merge pull request #1443 from Overflow0xFFFF/feature/1236-upgrade-clap
Browse files Browse the repository at this point in the history
Upgrade clap to v4
  • Loading branch information
utam0k authored Dec 30, 2022
2 parents 88d5d0e + a3bfc10 commit bcd90bb
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 65 deletions.
50 changes: 10 additions & 40 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 crates/libcgroups/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ libc = { version = "0.2.138", optional = true }
oci-spec = { version = "0.5.8", features = ["proptests", "runtime"] }
quickcheck = "1"
mockall = { version = "0.11.3", features = [] }
clap = "3.2.23"
clap = "4.0.32"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.10"
Expand Down
4 changes: 2 additions & 2 deletions crates/liboci-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ edition = "2021"
keywords = ["youki", "container", "oci"]

[dependencies.clap]
version = "3.2.23"
version = "4.0.32"
default-features = false
features = ["std", "suggestions", "derive", "cargo"]
features = ["std", "suggestions", "derive", "cargo", "help", "usage", "error-context"]
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;
/// Checkpoint a running container
#[derive(Parser, Debug)]
pub struct Checkpoint {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
/// Allow external unix sockets
#[clap(long)]
Expand Down
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ pub struct Create {
#[clap(long, default_value = "0")]
pub preserve_fds: i32,
/// name of the container instance to be started
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::Parser;
/// Release any resources held by the container
#[derive(Parser, Debug)]
pub struct Delete {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
/// forces deletion of the container if it is still running (using SIGKILL)
#[clap(short, long)]
Expand Down
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pub struct Events {
#[clap(long)]
pub stats: bool,
/// Name of the container instance
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
4 changes: 2 additions & 2 deletions crates/liboci-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Exec {
/// The file to which the pid of the container process should be written to
pub pid_file: Option<PathBuf>,
/// Environment variables that should be set in the container
#[clap(short, long, parse(try_from_str = parse_key_val), number_of_values = 1)]
#[clap(short, long, value_parser = parse_key_val::<String, String>, number_of_values = 1)]
pub env: Vec<(String, String)>,
/// Prevent the process from gaining additional privileges
#[clap(long)]
Expand All @@ -30,7 +30,7 @@ pub struct Exec {
#[clap(short, long)]
pub detach: bool,
/// Identifier of the container
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
/// Command that should be executed in the container
#[clap(required = false)]
Expand Down
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::Parser;
/// Send the specified signal to the container
#[derive(Parser, Debug)]
pub struct Kill {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
pub signal: String,
#[clap(short, long)]
Expand Down
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use clap::Parser;
/// Suspend the processes within the container
#[derive(Parser, Debug)]
pub struct Pause {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub struct Ps {
/// format to display processes: table or json (default: "table")
#[clap(short, long, default_value = "table")]
pub format: String,
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
/// options will be passed to the ps utility
#[clap(last = true)]
Expand Down
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use clap::Parser;
/// Resume the processes within the container
#[derive(Parser, Debug)]
pub struct Resume {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ pub struct Run {
#[clap(long, default_value = "0")]
pub preserve_fds: i32,
/// name of the container instance to be started
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use clap::Parser;
/// Start a previously created container
#[derive(Parser, Debug)]
pub struct Start {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use clap::Parser;
/// Show the container state
#[derive(Parser, Debug)]
pub struct State {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,
}
2 changes: 1 addition & 1 deletion crates/liboci-cli/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;
/// Update running container resource constraints
#[derive(Parser, Debug)]
pub struct Update {
#[clap(forbid_empty_values = true, required = true)]
#[clap(value_parser = clap::builder::NonEmptyStringValueParser::new(), required = true)]
pub container_id: String,

/// Read the new resource limits from the given json file. Use - to read from stdin.
Expand Down
6 changes: 3 additions & 3 deletions crates/youki/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ wasm-wasmedge = ["libcontainer/wasm-wasmedge"]
wasm-wasmtime = ["libcontainer/wasm-wasmtime"]

[dependencies.clap]
version = "3.2.23"
version = "4.0.32"
default-features = false
features = ["std", "suggestions", "derive", "cargo"]
features = ["std", "suggestions", "derive", "cargo", "help", "usage", "error-context"]

[dependencies]
anyhow = "1.0.65"
Expand All @@ -40,7 +40,7 @@ procfs = "0.14.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tabwriter = "1"
clap_complete = "3.2.5"
clap_complete = "4.0.7"
caps = "0.5.5"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/youki/src/commands/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io;
#[derive(Debug, Parser)]
/// Generate scripts for shell completion
pub struct Completion {
#[clap(long = "shell", short = 's', arg_enum)]
#[clap(long = "shell", short = 's', value_enum)]
pub shell: Shell,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/youki/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod logger;
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use clap::IntoApp;
use clap::CommandFactory;
use clap::{crate_version, Parser};
use nix::libc;
use std::fs;
Expand Down
4 changes: 2 additions & 2 deletions tests/rust-integration-tests/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ uuid = "1.2"
which = "4.3.0"

[dependencies.clap]
version = "3.2.23"
version = "4.0.32"
default-features = false
features = ["std", "suggestions", "derive", "cargo"]
features = ["std", "suggestions", "derive", "cargo", "help", "usage", "error-context"]

[dependencies.clap_derive]
version = "4.0.21"
Expand Down
2 changes: 1 addition & 1 deletion tests/rust-integration-tests/integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct Run {
/// Selected tests to be run, format should be
/// space separated groups, eg
/// -t group1::test1,test3 group2 group3::test5
#[clap(short, long, multiple_values = true, value_delimiter = ' ')]
#[clap(short, long, num_args(1..), value_delimiter = ' ')]
tests: Option<Vec<String>>,
}

Expand Down

0 comments on commit bcd90bb

Please # to comment.