Repository navigation
fix(task): preserve string type for usage value flags #12355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: jdx/mise
Length of output: 21796
🏁 Script executed:
Repository: jdx/mise
Length of output: 21644
🏁 Script executed:
Repository: jdx/mise
Length of output: 14516
🌐 Web query:
jdx usage Rust SpecFlag SpecArg arg env flag source💡 Result:
In the context of the Rust ecosystem, the term "jdx" refers to two distinct projects: 1. A JSON Data Explorer, an interactive, AI-augmented terminal tool [1][2]. 2. The "Usage" framework and specification, which provides tools for building CLIs and is associated with the domain usage.jdx.dev [3][4]. The types SpecFlag and SpecArg, along with their usage with arguments (arg), environment variables (env), and flags (flag), belong specifically to the Usage framework (usage-lib crate) [5][6]. Usage Framework Technical Context: SpecFlag and SpecArg are core structures used to define the command-line interface specification [5][6]. - SpecFlag: Represents a command-line flag (e.g., --verbose or -u). It contains fields for names, help text, and optional configuration such as env (for environment variable backing), and an optional SpecArg if the flag requires a value [5]. - SpecArg: Represents a positional argument [7][6]. Like SpecFlag, it can be configured with environment variable backing via an env field [7]. Usage Examples: You can define these using macros provided by the usage-lib crate for minimal boilerplate [8]: - Flags: Defined using spec_flag!, which can associate a long flag with an argument using the syntax: spec_flag!("--long" => ""; help = "description") [8]. - Arguments: Defined using spec_arg!, which supports configuration for requirements, variability (var), and environment variable backing: spec_arg!("file"; required = true, env = "MY_FILE") [7][8]. The framework allows these specifications to be used for generating autocompletion, manpages, and documentation, or for advanced argument parsing [3][4]. Note that "jdx" in your query likely refers to the Usage project (often hosted at usage.jdx.dev) rather than the separate JSON exploration tool [3][1].
Citations:
🌐 Web query:
site:docs.rs/usage-lib/latest/usage/spec/struct.SpecFlag.html arg env SpecFlag💡 Result:
The correct
SpecFlagdocs path is likely:https://docs.rs/usage-lib/latest/usage/spec/flag/struct.SpecFlag.htmlSpecFlagsupports an optional nestedargfor flags that take values. Environment-variable support is represented through the flag specification’senvfield, e.g.:This means resolution uses the command-line value first, then the environment variable. [1][2]
[1] (docs.rs)
[2] (usage.jdx.dev)
Citations:
🌐 Web query:
site:github.com/jdx/usage SpecFlag arg env flag source💡 Result:
In the context of the usage library (a tool for building CLI specifications, often defined in KDL), SpecFlag is a struct that represents the definition of a flag (e.g., -v, --verbose, --config) [1][2]. It is part of the spec model defined in lib/src/spec/ [1]. Regarding the terms "arg", "env", and "flag": 1. Arg: SpecFlag typically includes an internal argument (SpecArg) when the flag expects a value [1]. The SpecFlagBuilder allows associating an argument with a flag definition [3]. 2. Env: SpecFlag supports environment variable integration [3]. Flags can be configured to derive their values from environment variables [4][5], and parsing logic distinguishes between flags explicitly set via the command line or environment versus those carrying default values [4][6]. 3. Flag Source: The library tracks the origin of flag values during parsing to handle relationships such as overrides, conditional requirements (requires_if), and exclusions [4][6][7]. For example, conditional logic often differentiates whether a flag's value comes from the CLI, the environment, or a default setting, ensuring that rules only trigger when a flag is explicitly provided [4][6]. SpecFlag is managed using a builder pattern (SpecFlagBuilder), which provides methods to configure these properties, including setting names, help text, relationships, and environment mappings [4][6][3][8].
Citations:
🏁 Script executed:
Repository: jdx/mise
Length of output: 9534
🏁 Script executed:
Repository: jdx/mise
Length of output: 7798
🏁 Script executed:
Repository: jdx/mise
Length of output: 197
🏁 Script executed:
Repository: jdx/mise
Length of output: 32681
🏁 Script executed:
Repository: jdx/mise
Length of output: 763
🏁 Script executed:
Repository: jdx/mise
Length of output: 46646
🏁 Script executed:
Repository: jdx/mise
Length of output: 251
🏁 Script executed:
Repository: jdx/mise
Length of output: 329
Keep
SpecFlag::argreserved for value-taking flags.usage-libsupportsenvon boolean flags, but the deprecatedflag()helper setsargfor any env-backed flag. This convertsdefault=#false`` to the string"false". Avoid creating `SpecArg` for env-only boolean flags and add a regression test.🤖 Prompt for AI Agents