Skip to content

Commit

Permalink
Merge branch 'main' into rm-caps
Browse files Browse the repository at this point in the history
  • Loading branch information
clux authored Oct 3, 2022
2 parents bcc53ca + d6b33ce commit f2a7504
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tower-http = { version = "0.3.2", features = ["trace", "decompression-gzip"] }
hyper = { version = "0.14.13", features = ["client", "http1", "stream", "tcp"] }
thiserror = "1.0.29"
backoff = "0.4.0"
clap = { version = "3.1.9", default-features = false, features = ["std", "cargo", "derive"] }
clap = { version = "4.0", default-features = false, features = ["std", "cargo", "derive"] }
edit = "0.1.3"
tokio-stream = { version = "0.1.9", features = ["net"] }

Expand Down
32 changes: 21 additions & 11 deletions examples/kubectl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,43 @@ use tracing::*;

#[derive(clap::Parser)]
struct App {
#[clap(long, short, arg_enum, default_value_t)]
#[arg(long, short, default_value_t = OutputMode::Pretty)]
output: OutputMode,
#[clap(long, short)]
#[arg(long, short)]
file: Option<std::path::PathBuf>,
#[clap(long, short = 'l')]
#[arg(long, short = 'l')]
selector: Option<String>,
#[clap(long, short)]
#[arg(long, short)]
namespace: Option<String>,
#[clap(long, short = 'A')]
#[arg(long, short = 'A')]
all: bool,
#[clap(arg_enum)]
verb: Verb,
resource: Option<String>,
name: Option<String>,
}

#[derive(clap::ArgEnum, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, clap::ValueEnum)]
enum OutputMode {
Pretty,
Yaml,
}
impl Default for OutputMode {
fn default() -> Self {
Self::Pretty

impl OutputMode {
fn as_str(&self) -> &'static str {
match self {
Self::Pretty => "pretty",
Self::Yaml => "yaml",
}
}
}

impl std::fmt::Display for OutputMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.pad(self.as_str())
}
}
#[derive(clap::ArgEnum, Clone, PartialEq, Eq, Debug)]

#[derive(Clone, PartialEq, Eq, Debug, clap::ValueEnum)]
enum Verb {
Get,
Delete,
Expand Down

0 comments on commit f2a7504

Please sign in to comment.