- 
                Notifications
    You must be signed in to change notification settings 
- Fork 230
Description
What does it concern?
The plugin SDK, design, or schema
Goal or desired behavior
The goal is to address a limitation in the file provisioner of the Provisioner SDK where the current AddArgs function does not handle commands with positional arguments at the end. Such commands cannot accept additional flag arguments after the positional arguments, leading to invalid command construction.
Proposed solution:
- Replace AddArgswith:- PrependArgs: Adds arguments to the beginning of the command (but after the command itself).
- AppendArgs: Adds arguments to the end of the command, same functionality as the- AddArgsfunction currently.
 
This change will allow the file provisioner to generate valid commands for age and other CLIs with similar requirements.  An argument could be made also for other functionality such as InsertAt(index) or InsertAfter(string) to allow exact placement of the injected argument.
Current behavior
The current implementation of AddArgs appends arguments to the end of the command without considering the position of positional arguments. This leads to issues when commands have strict ordering requirements for flags and positional arguments.
For example, in the file provisioner, consider the age command:
$ age --encrypt --recipients-file key.txt -o output.txt input.txtIn this example:
- The flag --recipients-file key.txtmust appear before the positional argumentinput.txt
- Using AddArgsto append these flags results in an invalid command:
$ age --encrypt -o output.txt input.txt --recipients-file key.txt 
age: error: too many INPUT arguments: "input.txt" "--recipients-file" "key.txt"
age: hint: the input file must be specified after all flags
age: hint: did you mean:
age: hint:     age --encrypt -o output.txt --recipients-file key.txt input.txt
Relevant log output
No response
op CLI version
No response
shell-plugins local ref
No response