[Feature] Support Selecting Properties in `jsonInputArg` objects.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 523
- Forks
- 75
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 24
Description
Summary of the new feature / enhancement
Provide a method of passing individual properties as arguments instead of the entire JSON.
This supports more complex scenarios, and splitting behavior already exists when using "input": "env".
Reasoning
In creating a Pip resource I found myself wishing I could pass in just the "name" property as an argument. While the resource would not be as feature rich, combined with #1261 and #1264 I could have created a resource using only the definition and without needing a separate program.
I see a pattern of configuration / package management programs which:
- Could be resources.
- Accept strings as arguments, but not JSON.
- Can output their current state as JSON.
Proposed technical implementation details (optional)
Simple Option
- Support a
propertyselector allowing for parts of a JSON object to be used as command arguments. - Remove the "jsonInputArg" property, as the JSON is always a separate argument as is.
{
"set": {
"executable": "python.exe",
"args": [
"-m",
"pip",
"--no-input",
"install",
{
"mandatory": true,
"property": "name"
}
]
}
}
More Complex Option
Implement Simple option, and support optional arguments based on a JSON property.
{
"set": {
"executable": "python.exe",
"args": [
"-m",
"pip",
"--no-input",
"install",
{
"mandatory": false,
"property": "useLatest",
"type": "switch",
args: [ "--upgrade" ] // Only added if "useLatest" is true.
},
{
"mandatory": true,
"property": "name"
}
]
}
}
Brainstormed Idea (Out Of Scope)
# Most Complex Option (Likely out of scope) * Support [JSON Schema style if then else](https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse). * Support a format string, allowing properties to be combined.{
"set": {
"executable": "python.exe",
"args": [
"-m",
"pip",
"--no-input",
"install",
{
"if": {
"properties": {
"useLatest": { "const": true }
}
},
"then": {
"args": [
"--upgrade"
]
}
},
{
"if": {
"properties": {
"version": { "type": "string" }
},
{
"required": [ "version" ]
}
},
"then": {
"args": [
{ "format": "{name}=={version}" }
]
},
"else": {
"args": [
{ "format": "{name}" }
]
}
}
]
}
}
</details>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing jsonInputArg handling and the argument processing for set.args. Determine whether the intended scope is the simple property selector or also the optional and conditional forms; done means individual JSON properties can be passed as command arguments according to the selected scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100