preserves-tools: deps: Update to clap 3 release.
This was previously using a beta release. This helps move towards updating to the current v4 release.
This commit is contained in:
parent
6f085a7192
commit
acfacd636b
|
@ -14,9 +14,8 @@ preserves-path = { path = "../preserves-path", version = "4.1.0"}
|
|||
preserves-schema = { path = "../preserves-schema", version = "3.1.0"}
|
||||
|
||||
bytes = "1.0"
|
||||
clap = "=3.0.0-beta.2"
|
||||
clap_generate = "=3.0.0-beta.2"
|
||||
clap_derive = "=3.0.0-beta.2"
|
||||
clap = { version = "3", features = ["derive"] }
|
||||
clap_complete = "3"
|
||||
|
||||
[package.metadata.workspaces]
|
||||
independent = true
|
||||
|
|
|
@ -2,10 +2,8 @@ use bytes::Buf;
|
|||
use bytes::BufMut;
|
||||
use bytes::BytesMut;
|
||||
|
||||
use clap::ArgEnum;
|
||||
use clap::Clap;
|
||||
use clap::IntoApp;
|
||||
use clap_generate::{generate, generators};
|
||||
use clap:: {ArgEnum, Command, IntoApp, Parser, value_parser};
|
||||
use clap_complete::{generate, Generator, Shell};
|
||||
|
||||
use preserves::value::IOBinarySource;
|
||||
use preserves::value::IOValue;
|
||||
|
@ -55,15 +53,6 @@ enum CommasFormat {
|
|||
Terminating,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
enum CompletionDialect {
|
||||
Bash,
|
||||
Zsh,
|
||||
PowerShell,
|
||||
Fish,
|
||||
Elvish,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Copy, Debug)]
|
||||
enum Boolish {
|
||||
#[clap(alias = "no", alias = "n", alias = "off", alias = "0", alias = "false")]
|
||||
|
@ -94,7 +83,7 @@ enum SelectOutput {
|
|||
Set,
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
struct Convert {
|
||||
// #[clap(long, arg_enum, default_value = "none")]
|
||||
// input_encoding: Encoding,
|
||||
|
@ -149,7 +138,7 @@ enum StringInputTerminator {
|
|||
Nul,
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
struct StringQuotation {
|
||||
#[clap(long, arg_enum, default_value = "eof")]
|
||||
input_terminator: StringInputTerminator,
|
||||
|
@ -161,14 +150,14 @@ struct StringQuotation {
|
|||
escape_spaces: bool,
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
enum QuotationOutput {
|
||||
String(StringQuotation),
|
||||
ByteString,
|
||||
Symbol(StringQuotation),
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
struct Quote {
|
||||
#[clap(long, short, arg_enum, default_value = "text")]
|
||||
output_format: OutputFormat,
|
||||
|
@ -177,35 +166,34 @@ struct Quote {
|
|||
output: QuotationOutput,
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
enum Subcommand {
|
||||
Completions {
|
||||
#[clap(arg_enum, value_name = "dialect")]
|
||||
dialect: CompletionDialect,
|
||||
#[clap(value_parser=value_parser!(Shell))]
|
||||
shell: Shell,
|
||||
},
|
||||
Convert(Convert),
|
||||
Quote(Quote),
|
||||
}
|
||||
|
||||
#[derive(Clap, Clone, Debug)]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[clap(name="preserves-tool")]
|
||||
#[clap(version)]
|
||||
struct CommandLine {
|
||||
#[clap(subcommand)]
|
||||
command: Subcommand,
|
||||
}
|
||||
|
||||
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
|
||||
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let args = CommandLine::parse();
|
||||
Ok(match args.command {
|
||||
Subcommand::Completions { dialect } => {
|
||||
let mut app = CommandLine::into_app();
|
||||
match dialect {
|
||||
CompletionDialect::Bash => generate::<generators::Bash, _>(&mut app, "preserves-tool", &mut io::stdout()),
|
||||
CompletionDialect::Zsh => generate::<generators::Zsh, _>(&mut app, "preserves-tool", &mut io::stdout()),
|
||||
CompletionDialect::PowerShell => generate::<generators::PowerShell, _>(&mut app, "preserves-tool", &mut io::stdout()),
|
||||
CompletionDialect::Fish => generate::<generators::Fish, _>(&mut app, "preserves-tool", &mut io::stdout()),
|
||||
CompletionDialect::Elvish => generate::<generators::Elvish, _>(&mut app, "preserves-tool", &mut io::stdout()),
|
||||
}
|
||||
Subcommand::Completions { shell } => {
|
||||
let mut cmd = CommandLine::into_app();
|
||||
print_completions(shell, &mut cmd);
|
||||
},
|
||||
Subcommand::Convert(c) => convert(c)?,
|
||||
Subcommand::Quote(q) => quote(q)?,
|
||||
|
|
Loading…
Reference in New Issue