difftreelog
Merge pull request #18 from CertainLach/upgrade-clap
in: master
Help headings and colors
9 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -62,8 +62,8 @@
[[package]]
name = "clap"
-version = "3.0.0-beta.1"
-source = "git+https://github.com/clap-rs/clap?rev=3e9ee86713b5c407b50ba76f30cffaed25952063#3e9ee86713b5c407b50ba76f30cffaed25952063"
+version = "3.0.0-beta.2"
+source = "git+https://github.com/clap-rs/clap?rev=1d0b21908f93478e75b4b1a21533d86325d39386#1d0b21908f93478e75b4b1a21533d86325d39386"
dependencies = [
"atty",
"bitflags",
@@ -80,8 +80,8 @@
[[package]]
name = "clap_derive"
-version = "3.0.0-beta.1"
-source = "git+https://github.com/clap-rs/clap?rev=3e9ee86713b5c407b50ba76f30cffaed25952063#3e9ee86713b5c407b50ba76f30cffaed25952063"
+version = "3.0.0-beta.2"
+source = "git+https://github.com/clap-rs/clap?rev=1d0b21908f93478e75b4b1a21533d86325d39386#1d0b21908f93478e75b4b1a21533d86325d39386"
dependencies = [
"heck",
"proc-macro-error",
cmds/jrsonnet/Cargo.tomldiffbeforeafterboth--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -23,4 +23,4 @@
[dependencies.clap]
git = "https://github.com/clap-rs/clap"
-rev = "3e9ee86713b5c407b50ba76f30cffaed25952063"
+rev = "1d0b21908f93478e75b4b1a21533d86325d39386"
cmds/jrsonnet/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -1,3 +1,4 @@
+use clap::AppSettings;
use clap::Clap;
use jrsonnet_cli::{ConfigureState, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};
use jrsonnet_evaluator::{error::LocError, EvaluationState, ManifestFormat};
@@ -13,7 +14,7 @@
static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;
#[derive(Clap)]
-// #[clap(help_heading = "DEBUG")]
+#[clap(help_heading = "DEBUG")]
struct DebugOpts {
/// Required OS stack size.
/// This shouldn't be changed unless jrsonnet is failing with stack overflow error.
@@ -22,6 +23,10 @@
}
#[derive(Clap)]
+#[clap(
+ global_setting = AppSettings::ColoredHelp,
+ global_setting = AppSettings::DeriveDisplayOrder,
+)]
struct Opts {
#[clap(flatten)]
input: InputOpts,
crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -13,4 +13,4 @@
[dependencies.clap]
git = "https://github.com/clap-rs/clap"
-rev = "3e9ee86713b5c407b50ba76f30cffaed25952063"
+rev = "1d0b21908f93478e75b4b1a21533d86325d39386"
crates/jrsonnet-cli/src/ext.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/ext.rs
+++ b/crates/jrsonnet-cli/src/ext.rs
@@ -54,7 +54,7 @@
}
#[derive(Clap)]
-// #[clap(help_heading = "EXTERNAL VARIABLES")]
+#[clap(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.rsdiffbeforeafterboth1mod ext;2mod manifest;3mod tla;4mod trace;56pub use ext::*;7pub use manifest::*;8pub use tla::*;9pub use trace::*;1011use clap::Clap;12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};13use std::path::PathBuf;1415pub trait ConfigureState {16 fn configure(&self, state: &EvaluationState) -> Result<()>;17}1819#[derive(Clap)]20// #[clap(help_heading = "INPUT")]21pub struct InputOpts {22 #[clap(23 long,24 short = 'e',25 about = "Treat input as code, evaluate them instead of reading file"26 )]27 pub exec: bool,2829 #[clap(30 about = "Path to the file to be compiled if `--evaluate` is unset, otherwise code itself"31 )]32 pub input: String,33}3435#[derive(Clap)]36// #[clap(help_heading = "OPTIONS")]37pub struct MiscOpts {38 /// Disable standard library.39 /// By default standard library will be available via global `std` variable.40 /// Note that standard library will still be loaded41 /// if chosen manifestification method is not `none`.42 #[clap(long)]43 no_stdlib: bool,4445 /// Maximal allowed number of stack frames,46 /// stack overflow error will be raised if this number gets exceeded.47 #[clap(long, short = 's', default_value = "200")]48 max_stack: usize,4950 /// Library search dirs.51 /// Any not found `imported` file will be searched in these.52 /// This can also be specified via `JSONNET_PATH` variable,53 /// which should contain a colon-separated (semicolon-separated on Windows) list of directories.54 #[clap(long, short = 'J')]55 jpath: Vec<PathBuf>,56}57impl ConfigureState for MiscOpts {58 fn configure(&self, state: &EvaluationState) -> Result<()> {59 if !self.no_stdlib {60 state.with_stdlib();61 }6263 state.set_import_resolver(Box::new(FileImportResolver {64 library_paths: self.jpath.clone(),65 }));6667 state.set_max_stack(self.max_stack);68 Ok(())69 }70}7172/// General configuration of jsonnet73#[derive(Clap)]74#[clap(name = "jrsonnet", version, author)]75pub struct GeneralOpts {76 #[clap(flatten)]77 misc: MiscOpts,7879 #[clap(flatten)]80 tla: TLAOpts,81 #[clap(flatten)]82 ext: ExtVarOpts,8384 #[clap(flatten)]85 trace: TraceOpts,86}8788impl ConfigureState for GeneralOpts {89 fn configure(&self, state: &EvaluationState) -> Result<()> {90 // Configure trace first, because tla-code/ext-code can throw91 self.trace.configure(state)?;92 self.misc.configure(state)?;93 self.tla.configure(state)?;94 self.ext.configure(state)?;95 Ok(())96 }97}1mod ext;2mod manifest;3mod tla;4mod trace;56pub use ext::*;7pub use manifest::*;8pub use tla::*;9pub use trace::*;1011use clap::Clap;12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};13use std::path::PathBuf;1415pub trait ConfigureState {16 fn configure(&self, state: &EvaluationState) -> Result<()>;17}1819#[derive(Clap)]20#[clap(help_heading = "INPUT")]21pub struct InputOpts {22 #[clap(23 long,24 short = 'e',25 about = "Treat input as code, evaluate them instead of reading file"26 )]27 pub exec: bool,2829 #[clap(30 about = "Path to the file to be compiled if `--evaluate` is unset, otherwise code itself"31 )]32 pub input: String,33}3435#[derive(Clap)]36#[clap(help_heading = "OPTIONS")]37pub struct MiscOpts {38 /// Disable standard library.39 /// By default standard library will be available via global `std` variable.40 /// Note that standard library will still be loaded41 /// if chosen manifestification method is not `none`.42 #[clap(long)]43 no_stdlib: bool,4445 /// Maximal allowed number of stack frames,46 /// stack overflow error will be raised if this number gets exceeded.47 #[clap(long, short = 's', default_value = "200")]48 max_stack: usize,4950 /// Library search dirs.51 /// Any not found `imported` file will be searched in these.52 /// This can also be specified via `JSONNET_PATH` variable,53 /// which should contain a colon-separated (semicolon-separated on Windows) list of directories.54 #[clap(long, short = 'J')]55 jpath: Vec<PathBuf>,56}57impl ConfigureState for MiscOpts {58 fn configure(&self, state: &EvaluationState) -> Result<()> {59 if !self.no_stdlib {60 state.with_stdlib();61 }6263 state.set_import_resolver(Box::new(FileImportResolver {64 library_paths: self.jpath.clone(),65 }));6667 state.set_max_stack(self.max_stack);68 Ok(())69 }70}7172/// General configuration of jsonnet73#[derive(Clap)]74#[clap(name = "jrsonnet", version, author)]75pub struct GeneralOpts {76 #[clap(flatten)]77 misc: MiscOpts,7879 #[clap(flatten)]80 tla: TLAOpts,81 #[clap(flatten)]82 ext: ExtVarOpts,8384 #[clap(flatten)]85 trace: TraceOpts,86}8788impl ConfigureState for GeneralOpts {89 fn configure(&self, state: &EvaluationState) -> Result<()> {90 // Configure trace first, because tla-code/ext-code can throw91 self.trace.configure(state)?;92 self.misc.configure(state)?;93 self.tla.configure(state)?;94 self.ext.configure(state)?;95 Ok(())96 }97}crates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -23,8 +23,7 @@
}
#[derive(Clap)]
-// TODO: Restore arg group after issue fixed in clap
-// #[clap(group = clap::ArgGroup::new("output_format"), help_heading = "MANIFESTIFICATION OUTPUT")]
+#[clap(group = clap::ArgGroup::new("output_format"), 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,
@@ -33,7 +32,7 @@
format: ManifestFormatName,
/// Expect plain string as output.
/// Shortcut for `--format=string` thus this option is mutually exclusive with `format` option.
- #[clap(long, short = 'S'/*, group = "output_format"*/)]
+ #[clap(long, short = 'S', group = "output_format")]
string: bool,
/// Write output as YAML stream, can be used with --format json/yaml
#[clap(long, short = 'y')]
crates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -3,7 +3,7 @@
use jrsonnet_evaluator::{error::Result, EvaluationState};
#[derive(Clap)]
-// #[clap(help_heading = "TOP LEVEL ARGUMENTS")]
+#[clap(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
@@ -25,7 +25,7 @@
}
#[derive(Clap)]
-// #[clap(help_heading = "STACK TRACE VISUAL")]
+#[clap(help_heading = "STACK TRACE VISUAL")]
pub struct TraceOpts {
/// Format of stack traces' display in console.
/// `compact` format only shows `filename:line:column`s