difftreelog
build upgrade clap to v3.1
in: master
8 files changed
cmds/jrsonnet/Cargo.tomldiffbeforeafterboth--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -18,11 +18,5 @@
mimallocator = { version = "0.1.3", optional = true }
thiserror = "1.0"
gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
-
-[dependencies.clap]
-git = "https://github.com/clap-rs/clap"
-rev = "f0c5ea5e1503de5c8e74d8c047a799cf51498e83"
-
-[dependencies.clap_generate]
-git = "https://github.com/clap-rs/clap"
-rev = "f0c5ea5e1503de5c8e74d8c047a799cf51498e83"
+clap = { version = "3.1", features = ["derive"] }
+clap_complete = { version = "3.1" }
cmds/jrsonnet/src/main.rsdiffbeforeafterboth1use clap::{AppSettings, Clap, IntoApp};1use clap::{AppSettings, IntoApp, Parser};2use clap_complete::Shell;2use jrsonnet_cli::{ConfigureState, GcOpts, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};3use jrsonnet_cli::{ConfigureState, GcOpts, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};3use jrsonnet_evaluator::{error::LocError, EvaluationState};4use jrsonnet_evaluator::{error::LocError, EvaluationState};4use std::{5use std::{5 fs::{create_dir_all, File},6 fs::{create_dir_all, File},6 io::Read,7 io::Read,7 io::Write,8 io::Write,8 path::PathBuf,9 path::PathBuf,9 str::FromStr,10};10};111112#[cfg(feature = "mimalloc")]12#[cfg(feature = "mimalloc")]13#[global_allocator]13#[global_allocator]14static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;14static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;1516#[derive(Parser)]17enum SubOpts {18 /// Generate completions for specified shell19 Generate {20 /// Target shell name21 shell: Shell,22 },23}152416#[derive(Clap)]25#[derive(Parser)]17#[clap(help_heading = "DEBUG")]26#[clap(next_help_heading = "DEBUG")]18struct DebugOpts {27struct DebugOpts {19 /// Required OS stack size.28 /// Required OS stack size.20 /// This shouldn't be changed unless jrsonnet is failing with stack overflow error.29 /// This shouldn't be changed unless jrsonnet is failing with stack overflow error.21 #[clap(long, name = "size")]30 #[clap(long, name = "size")]22 pub os_stack: Option<usize>,31 pub os_stack: Option<usize>,23 /// Generate completions script24 #[clap(long)]25 generate: Option<GenerateTarget>,26}32}2728enum GenerateTarget {29 Bash,30 Zsh,31 Fish,32 PowerShell,33}34impl FromStr for GenerateTarget {35 type Err = &'static str;3637 fn from_str(s: &str) -> Result<Self, Self::Err> {38 match s {39 "bash" => Ok(Self::Bash),40 "zsh" => Ok(Self::Zsh),41 "fish" => Ok(Self::Fish),42 "powershell" => Ok(Self::PowerShell),43 _ => Err("unknown target"),44 }45 }46}473348#[derive(Clap)]34#[derive(Parser)]49#[clap(35#[clap(50 global_setting = AppSettings::ColoredHelp,36 global_setting = AppSettings::DeriveDisplayOrder,51 global_setting = AppSettings::DeriveDisplayOrder,37 // args_conflicts_with_subcommands = true,52)]38)]53struct Opts {39struct Opts {40 #[clap(subcommand)]41 sub: Option<SubOpts>,4254 #[clap(flatten)]43 #[clap(flatten)]55 input: InputOpts,44 input: InputOpts,68fn main() {57fn main() {69 let opts: Opts = Opts::parse();58 let opts: Opts = Opts::parse();705971 if let Some(target) = opts.debug.generate {60 if let Some(sub) = opts.sub {72 use clap_generate::{generate, generators};61 match sub {73 use GenerateTarget::*;62 SubOpts::Generate { shell } => {63 use clap_complete::generate;74 let app = &mut Opts::into_app();64 let app = &mut Opts::command();75 let buf = &mut std::io::stdout();65 let buf = &mut std::io::stdout();76 let bin = "jrsonnet";77 match target {78 Bash => generate::<generators::Bash, _>(app, bin, buf),79 Zsh => generate::<generators::Zsh, _>(app, bin, buf),80 Fish => generate::<generators::Fish, _>(app, bin, buf),81 PowerShell => generate::<generators::PowerShell, _>(app, bin, buf),66 generate(shell, app, "jrsonnet", buf);82 }83 std::process::exit(0);67 std::process::exit(0)68 }69 }84 };70 }857186 let success = if let Some(size) = opts.debug.os_stack {72 let success = if let Some(size) = opts.debug.os_stack {87 std::thread::Builder::new()73 std::thread::Builder::new()crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -14,6 +14,4 @@
jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
-[dependencies.clap]
-git = "https://github.com/clap-rs/clap"
-rev = "f0c5ea5e1503de5c8e74d8c047a799cf51498e83"
+clap = { version = "3.1", features = ["derive"] }
crates/jrsonnet-cli/src/ext.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/ext.rs
+++ b/crates/jrsonnet-cli/src/ext.rs
@@ -1,5 +1,5 @@
use crate::ConfigureState;
-use clap::Clap;
+use clap::Parser;
use jrsonnet_evaluator::{error::Result, EvaluationState};
use std::{fs::read_to_string, str::FromStr};
@@ -53,8 +53,8 @@
}
}
-#[derive(Clap)]
-#[clap(help_heading = "EXTERNAL VARIABLES")]
+#[derive(Parser)]
+#[clap(next_help_heading = "EXTERNAL VARIABLES")]
pub struct ExtVarOpts {
/// Add string external variable.
/// External variables are globally available so it is preferred
crates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -8,7 +8,7 @@
pub use tla::*;
pub use trace::*;
-use clap::Clap;
+use clap::Parser;
use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};
use std::{env, path::PathBuf};
@@ -16,24 +16,19 @@
fn configure(&self, state: &EvaluationState) -> Result<()>;
}
-#[derive(Clap)]
-#[clap(help_heading = "INPUT")]
+#[derive(Parser)]
+#[clap(next_help_heading = "INPUT")]
pub struct InputOpts {
- #[clap(
- long,
- short = 'e',
- about = "Treat input as code, evaluate them instead of reading file"
- )]
+ /// Treat input as code, evaluate them instead of reading file
+ #[clap(long, short = 'e')]
pub exec: bool,
- #[clap(
- about = "Path to the file to be compiled if `--evaluate` is unset, otherwise code itself"
- )]
+ /// Path to the file to be compiled if `--evaluate` is unset, otherwise code itself
pub input: String,
}
-#[derive(Clap)]
-#[clap(help_heading = "OPTIONS")]
+#[derive(Parser)]
+#[clap(next_help_heading = "OPTIONS")]
pub struct MiscOpts {
/// Disable standard library.
/// By default standard library will be available via global `std` variable.
@@ -74,7 +69,7 @@
}
/// General configuration of jsonnet
-#[derive(Clap)]
+#[derive(Parser)]
#[clap(name = "jrsonnet", version, author)]
pub struct GeneralOpts {
#[clap(flatten)]
@@ -100,8 +95,8 @@
}
}
-#[derive(Clap)]
-#[clap(help_heading = "GARBAGE COLLECTION")]
+#[derive(Parser)]
+#[clap(next_help_heading = "GARBAGE COLLECTION")]
pub struct GcOpts {
/// Do not skip gc on exit
#[clap(long)]
crates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,5 +1,5 @@
use crate::ConfigureState;
-use clap::Clap;
+use clap::Parser;
use jrsonnet_evaluator::{error::Result, EvaluationState, ManifestFormat};
use std::{path::PathBuf, str::FromStr};
@@ -22,8 +22,8 @@
}
}
-#[derive(Clap)]
-#[clap(help_heading = "MANIFESTIFICATION OUTPUT")]
+#[derive(Parser)]
+#[clap(next_help_heading = "MANIFESTIFICATION OUTPUT")]
pub struct ManifestOpts {
/// Output format, wraps resulting value to corresponding std.manifest call.
/// If set to `string` then plain string value is expected to be returned,
@@ -66,7 +66,7 @@
}
}
-#[derive(Clap)]
+#[derive(Parser)]
pub struct OutputOpts {
/// Write to the output file rather than stdout
#[clap(long, short = 'o')]
crates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -1,9 +1,9 @@
use crate::{ConfigureState, ExtFile, ExtStr};
-use clap::Clap;
+use clap::Parser;
use jrsonnet_evaluator::{error::Result, EvaluationState};
-#[derive(Clap)]
-#[clap(help_heading = "TOP LEVEL ARGUMENTS")]
+#[derive(Parser)]
+#[clap(next_help_heading = "TOP LEVEL ARGUMENTS")]
pub struct TLAOpts {
/// Add top level string argument.
/// Top level arguments will be passed to function before manifestification stage.
crates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,5 +1,5 @@
use crate::ConfigureState;
-use clap::Clap;
+use clap::Parser;
use jrsonnet_evaluator::{
error::Result,
trace::{CompactFormat, ExplainingFormat, PathResolver},
@@ -24,8 +24,8 @@
}
}
-#[derive(Clap)]
-#[clap(help_heading = "STACK TRACE VISUAL")]
+#[derive(Parser)]
+#[clap(next_help_heading = "STACK TRACE VISUAL")]
pub struct TraceOpts {
/// Format of stack traces' display in console.
/// `compact` format only shows `filename:line:column`s