difftreelog
build upgrade dependencies
in: master
13 files changed
cmds/jrsonnet/Cargo.tomldiffbeforeafterboth--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -28,5 +28,5 @@
mimallocator = { version = "0.1.3", optional = true }
thiserror = "1.0"
-clap = { version = "3.2", features = ["derive"] }
-clap_complete = { version = "3.2" }
+clap = { version = "4.0", features = ["derive"] }
+clap_complete = { version = "4.0" }
cmds/jrsonnet/src/main.rsdiffbeforeafterboth1use std::{2 fs::{create_dir_all, File},3 io::{Read, Write},4};56use clap::{AppSettings, IntoApp, Parser};7use clap_complete::Shell;8use jrsonnet_cli::{ConfigureState, GeneralOpts, ManifestOpts, OutputOpts};9use jrsonnet_evaluator::{error::LocError, State};1011#[cfg(feature = "mimalloc")]12#[global_allocator]13static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;1415#[derive(Parser)]16enum SubOpts {17 /// Generate completions for specified shell18 Generate {19 /// Target shell name20 shell: Shell,21 },22}2324#[derive(Parser)]25#[clap(next_help_heading = "DEBUG")]26struct DebugOpts {27 /// Required OS stack size.28 /// This shouldn't be changed unless jrsonnet is failing with stack overflow error.29 #[clap(long, name = "size")]30 pub os_stack: Option<usize>,31}3233#[derive(Parser)]34#[clap(next_help_heading = "INPUT")]35struct InputOpts {36 /// Treat input as code, evaluate them instead of reading file37 #[clap(long, short = 'e')]38 pub exec: bool,3940 /// Path to the file to be compiled if `--evaluate` is unset, otherwise code itself41 pub input: Option<String>,42}4344#[derive(Parser)]45#[clap(46 global_setting = AppSettings::DeriveDisplayOrder,47 args_conflicts_with_subcommands = true,48)]49struct Opts {50 #[clap(subcommand)]51 sub: Option<SubOpts>,5253 #[clap(flatten)]54 input: InputOpts,55 #[clap(flatten)]56 general: GeneralOpts,57 #[clap(flatten)]58 manifest: ManifestOpts,59 #[clap(flatten)]60 output: OutputOpts,61 #[clap(flatten)]62 debug: DebugOpts,63}6465fn main() {66 let opts: Opts = Opts::parse();6768 if let Some(sub) = opts.sub {69 match sub {70 SubOpts::Generate { shell } => {71 use clap_complete::generate;72 let app = &mut Opts::command();73 let buf = &mut std::io::stdout();74 generate(shell, app, "jrsonnet", buf);75 std::process::exit(0)76 }77 }78 }7980 let success = if let Some(size) = opts.debug.os_stack {81 std::thread::Builder::new()82 .stack_size(size * 1024 * 1024)83 .spawn(|| main_catch(opts))84 .expect("new thread spawned")85 .join()86 .expect("thread finished successfully")87 } else {88 main_catch(opts)89 };90 if !success {91 std::process::exit(1);92 }93}9495#[derive(thiserror::Error, Debug)]96enum Error {97 // Handled differently98 #[error("evaluation error")]99 Evaluation(jrsonnet_evaluator::error::LocError),100 #[error("io error")]101 Io(#[from] std::io::Error),102 #[error("input is not utf8 encoded")]103 Utf8(#[from] std::str::Utf8Error),104 #[error("missing input argument")]105 MissingInputArgument,106}107impl From<LocError> for Error {108 fn from(e: LocError) -> Self {109 Self::Evaluation(e)110 }111}112113fn main_catch(opts: Opts) -> bool {114 let s = State::default();115 if let Err(e) = main_real(&s, opts) {116 if let Error::Evaluation(e) = e {117 eprintln!("{}", s.stringify_err(&e));118 } else {119 eprintln!("{}", e);120 }121 return false;122 }123 true124}125126fn main_real(s: &State, opts: Opts) -> Result<(), Error> {127 let _guards = opts.general.configure(s)?;128 opts.manifest.configure(s)?;129130 let input = opts.input.input.ok_or(Error::MissingInputArgument)?;131 let val = if opts.input.exec {132 s.evaluate_snippet("<cmdline>".to_owned(), &input as &str)?133 } else if input == "-" {134 let mut input = Vec::new();135 std::io::stdin().read_to_end(&mut input)?;136 let input_str = std::str::from_utf8(&input)?;137 s.evaluate_snippet("<stdin>".to_owned(), input_str)?138 } else {139 s.import(&input)?140 };141142 let val = s.with_tla(val)?;143144 if let Some(multi) = opts.output.multi {145 if opts.output.create_output_dirs {146 let mut dir = multi.clone();147 dir.pop();148 create_dir_all(dir)?;149 }150 for (file, data) in s.manifest_multi(val)?.iter() {151 let mut path = multi.clone();152 path.push(file as &str);153 if opts.output.create_output_dirs {154 let mut dir = path.clone();155 dir.pop();156 create_dir_all(dir)?;157 }158 println!("{}", path.to_str().expect("path"));159 let mut file = File::create(path)?;160 writeln!(file, "{}", data)?;161 }162 } else if let Some(path) = opts.output.output_file {163 if opts.output.create_output_dirs {164 let mut dir = path.clone();165 dir.pop();166 create_dir_all(dir)?;167 }168 let mut file = File::create(path)?;169 writeln!(file, "{}", s.manifest(val)?)?;170 } else {171 let output = s.manifest(val)?;172 if !output.is_empty() {173 println!("{}", output);174 }175 }176177 Ok(())178}1use std::{2 fs::{create_dir_all, File},3 io::{Read, Write},4};56use clap::{CommandFactory, Parser};7use clap_complete::Shell;8use jrsonnet_cli::{ConfigureState, GeneralOpts, ManifestOpts, OutputOpts};9use jrsonnet_evaluator::{error::LocError, State};1011#[cfg(feature = "mimalloc")]12#[global_allocator]13static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;1415#[derive(Parser)]16enum SubOpts {17 /// Generate completions for specified shell18 Generate {19 /// Target shell name20 shell: Shell,21 },22}2324#[derive(Parser)]25#[clap(next_help_heading = "DEBUG")]26struct DebugOpts {27 /// Required OS stack size.28 /// This shouldn't be changed unless jrsonnet is failing with stack overflow error.29 #[clap(long, name = "size")]30 pub os_stack: Option<usize>,31}3233#[derive(Parser)]34#[clap(next_help_heading = "INPUT")]35struct InputOpts {36 /// Treat input as code, evaluate them instead of reading file37 #[clap(long, short = 'e')]38 pub exec: bool,3940 /// Path to the file to be compiled if `--evaluate` is unset, otherwise code itself41 pub input: Option<String>,42}4344#[derive(Parser)]45#[clap(args_conflicts_with_subcommands = true, disable_version_flag = true)]46struct Opts {47 #[clap(subcommand)]48 sub: Option<SubOpts>,4950 #[clap(flatten)]51 input: InputOpts,52 #[clap(flatten)]53 general: GeneralOpts,54 #[clap(flatten)]55 manifest: ManifestOpts,56 #[clap(flatten)]57 output: OutputOpts,58 #[clap(flatten)]59 debug: DebugOpts,60}6162fn main() {63 let opts: Opts = Opts::parse();6465 if let Some(sub) = opts.sub {66 match sub {67 SubOpts::Generate { shell } => {68 use clap_complete::generate;69 let app = &mut Opts::command();70 let buf = &mut std::io::stdout();71 generate(shell, app, "jrsonnet", buf);72 std::process::exit(0)73 }74 }75 }7677 let success = if let Some(size) = opts.debug.os_stack {78 std::thread::Builder::new()79 .stack_size(size * 1024 * 1024)80 .spawn(|| main_catch(opts))81 .expect("new thread spawned")82 .join()83 .expect("thread finished successfully")84 } else {85 main_catch(opts)86 };87 if !success {88 std::process::exit(1);89 }90}9192#[derive(thiserror::Error, Debug)]93enum Error {94 // Handled differently95 #[error("evaluation error")]96 Evaluation(jrsonnet_evaluator::error::LocError),97 #[error("io error")]98 Io(#[from] std::io::Error),99 #[error("input is not utf8 encoded")]100 Utf8(#[from] std::str::Utf8Error),101 #[error("missing input argument")]102 MissingInputArgument,103}104impl From<LocError> for Error {105 fn from(e: LocError) -> Self {106 Self::Evaluation(e)107 }108}109110fn main_catch(opts: Opts) -> bool {111 let s = State::default();112 if let Err(e) = main_real(&s, opts) {113 if let Error::Evaluation(e) = e {114 eprintln!("{}", s.stringify_err(&e));115 } else {116 eprintln!("{}", e);117 }118 return false;119 }120 true121}122123fn main_real(s: &State, opts: Opts) -> Result<(), Error> {124 let _guards = opts.general.configure(s)?;125 opts.manifest.configure(s)?;126127 let input = opts.input.input.ok_or(Error::MissingInputArgument)?;128 let val = if opts.input.exec {129 s.evaluate_snippet("<cmdline>".to_owned(), &input as &str)?130 } else if input == "-" {131 let mut input = Vec::new();132 std::io::stdin().read_to_end(&mut input)?;133 let input_str = std::str::from_utf8(&input)?;134 s.evaluate_snippet("<stdin>".to_owned(), input_str)?135 } else {136 s.import(&input)?137 };138139 let val = s.with_tla(val)?;140141 if let Some(multi) = opts.output.multi {142 if opts.output.create_output_dirs {143 let mut dir = multi.clone();144 dir.pop();145 create_dir_all(dir)?;146 }147 for (file, data) in s.manifest_multi(val)?.iter() {148 let mut path = multi.clone();149 path.push(file as &str);150 if opts.output.create_output_dirs {151 let mut dir = path.clone();152 dir.pop();153 create_dir_all(dir)?;154 }155 println!("{}", path.to_str().expect("path"));156 let mut file = File::create(path)?;157 writeln!(file, "{}", data)?;158 }159 } else if let Some(path) = opts.output.output_file {160 if opts.output.create_output_dirs {161 let mut dir = path.clone();162 dir.pop();163 create_dir_all(dir)?;164 }165 let mut file = File::create(path)?;166 writeln!(file, "{}", s.manifest(val)?)?;167 } else {168 let output = s.manifest(val)?;169 if !output.is_empty() {170 println!("{}", output);171 }172 }173174 Ok(())175}crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -21,4 +21,4 @@
jrsonnet-gcmodule = { version = "0.3.4" }
jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
-clap = { version = "3.2", features = ["derive"] }
+clap = { version = "4.0", features = ["derive"] }
crates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -44,7 +44,7 @@
/// Any not found `imported` file will be searched in these.
/// This can also be specified via `JSONNET_PATH` variable,
/// which should contain a colon-separated (semicolon-separated on Windows) list of directories.
- #[clap(long, short = 'J', multiple_occurrences = true)]
+ #[clap(long, short = 'J')]
jpath: Vec<PathBuf>,
}
impl ConfigureState for MiscOpts {
crates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,10 +1,11 @@
use std::{path::PathBuf, str::FromStr};
-use clap::Parser;
+use clap::{Parser, ValueEnum};
use jrsonnet_evaluator::{error::Result, ManifestFormat, State};
use crate::ConfigureState;
+#[derive(Clone, ValueEnum)]
pub enum ManifestFormatName {
/// Expect string as output, and write them directly
String,
@@ -28,7 +29,7 @@
#[clap(next_help_heading = "MANIFESTIFICATION OUTPUT")]
pub struct ManifestOpts {
/// Output format, wraps resulting value to corresponding std.manifest call.
- #[clap(long, short = 'f', default_value = "json", possible_values = &["json", "yaml"])]
+ #[clap(long, short = 'f', default_value = "json")]
format: ManifestFormatName,
/// Expect plain string as output.
/// Mutually exclusive with `--format`
crates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -69,40 +69,19 @@
/// to use top level arguments whenever it's possible.
/// If [=data] is not set then it will be read from `name` env variable.
/// Can be accessed from code via `std.extVar("name")`.
- #[clap(
- long,
- short = 'V',
- name = "name[=var data]",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, short = 'V', name = "name[=var data]", number_of_values = 1)]
ext_str: Vec<ExtStr>,
/// Read string external variable from file.
/// See also `--ext-str`
- #[clap(
- long,
- name = "name=var path",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name=var path", number_of_values = 1)]
ext_str_file: Vec<ExtFile>,
/// Add external variable from code.
/// See also `--ext-str`
- #[clap(
- long,
- name = "name[=var source]",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name[=var source]", number_of_values = 1)]
ext_code: Vec<ExtStr>,
/// Read string external variable from file.
/// See also `--ext-str`
- #[clap(
- long,
- name = "name=var code path",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name=var code path", number_of_values = 1)]
ext_code_file: Vec<ExtFile>,
}
impl ConfigureState for StdOpts {
crates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -10,40 +10,19 @@
/// Top level arguments will be passed to function before manifestification stage.
/// This is preferred to ExtVars method.
/// If [=data] is not set then it will be read from `name` env variable.
- #[clap(
- long,
- short = 'A',
- name = "name[=tla data]",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, short = 'A', name = "name[=tla data]", number_of_values = 1)]
tla_str: Vec<ExtStr>,
/// Read top level argument string from file.
/// See also `--tla-str`
- #[clap(
- long,
- name = "name=tla path",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name=tla path", number_of_values = 1)]
tla_str_file: Vec<ExtFile>,
/// Add top level argument from code.
/// See also `--tla-str`
- #[clap(
- long,
- name = "name[=tla source]",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name[=tla source]", number_of_values = 1)]
tla_code: Vec<ExtStr>,
/// Read top level argument code from file.
/// See also `--tla-str`
- #[clap(
- long,
- name = "name=tla code path",
- number_of_values = 1,
- multiple_occurrences = true
- )]
+ #[clap(long, name = "name=tla code path", number_of_values = 1)]
tla_code_file: Vec<ExtFile>,
}
impl ConfigureState for TLAOpts {
crates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,6 +1,4 @@
-use std::str::FromStr;
-
-use clap::Parser;
+use clap::{Parser, ValueEnum};
use jrsonnet_evaluator::{
error::Result,
trace::{CompactFormat, ExplainingFormat, PathResolver},
@@ -9,31 +7,19 @@
use crate::ConfigureState;
-#[derive(PartialEq, Eq)]
+#[derive(PartialEq, Eq, ValueEnum, Clone)]
pub enum TraceFormatName {
+ /// Only show `filename:line:column`
Compact,
+ /// Display source code with attached trace annotations
Explaining,
-}
-
-impl FromStr for TraceFormatName {
- type Err = &'static str;
- fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
- Ok(match s {
- "compact" => TraceFormatName::Compact,
- "explaining" => TraceFormatName::Explaining,
- _ => return Err("no such format"),
- })
- }
}
#[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
- /// while `explaining` displays source code with attached trace annotations
- /// thus being more verbose.
- #[clap(long, possible_values = &["compact", "explaining"])]
+ #[clap(long)]
trace_format: Option<TraceFormatName>,
/// Amount of stack trace elements to be displayed.
/// If set to `0` then full stack trace will be displayed.
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -31,7 +31,7 @@
jrsonnet-gcmodule = { version = "0.3.4" }
pathdiff = "0.2.1"
-hashbrown = "0.12.1"
+hashbrown = "0.12.3"
static_assertions = "1.1"
rustc-hash = "1.1"
crates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -22,4 +22,4 @@
structdump = { version = "0.2.0", optional = true }
rustc-hash = "1.1"
-hashbrown = { version = "0.12.1", features = ["inline-more"] }
+hashbrown = { version = "0.12.3", features = ["inline-more"] }
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -190,6 +190,7 @@
}
}
+#[cfg_attr(feature = "structdump", derive(Codegen))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Trace)]
pub enum DestructRest {
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -30,7 +30,7 @@
# std.md5
md5 = "0.7.0"
# std.base64
-base64 = "0.13.0"
+base64 = "0.13.1"
# std.parseJson
serde_json = "1.0"
# std.parseYaml, custom library fork is used for C++/golang compatibility
crates/jrsonnet-types/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -9,4 +9,4 @@
[dependencies]
jrsonnet-gcmodule = { version = "0.3.4" }
-peg = "0.8.0"
+peg = "0.8.1"