Skip to content
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

Support for commands with positional arguments in the File Provisioner #507

Open
jmsnll opened this issue Jan 15, 2025 · 0 comments · May be fixed by #508
Open

Support for commands with positional arguments in the File Provisioner #507

jmsnll opened this issue Jan 15, 2025 · 0 comments · May be fixed by #508

Comments

@jmsnll
Copy link

jmsnll commented Jan 15, 2025

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 AddArgs with:
    • 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 AddArgs function 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.txt

In this example:

  • The flag --recipients-file key.txt must appear before the positional argument input.txt
  • Using AddArgs to 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

@jmsnll jmsnll linked a pull request Jan 15, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant