Many programs require global parameters before any subcommand name, and reject them if they appear afterwards with the specific parameters. For example, git, or any Python program using Click for argument processing. The general pattern is
program --flag --global=value ... subcommand --fspecific --specific=value arg ...
Does anyone have an elegant pattern for inserting global parameters before a subcommand in a program_subcommand.cwl
specification? I’m hoping that this is an ordinary use case and that there is already a clever solution.
I am unhappy with the following:
- Specifying the global parameters without an
inputBinding
and pasting them one-by-one intoarguments
:
This is unsatisfying because none of theinputs: flag: type: boolean default: False inputBinding: prefix: "--flag" global: type: string default: VALUE data: type: string inputBinding: position: 1 baseCommand: - "program" arguments: - $("--global=" + inputs.global) - "$(inputs.flag ? '--flag' : '--no-flag')" - "subcommand"
inputBinding
helpers likeprefix
are available, and because the global parameters must have a default value since they are unconditionally added to the command line. (Mitigated ifarguments
is an expression, but that obfuscates the definition.) - Specifying the subcommand as a parameter and relying on
position
:
This is unsatisfying because it pollutes the API with a useless parameter, andinputs: flag: type: boolean default: False inputBinding: prefix: "--flag" global: type: string? inputBinding: prefix: "--global" separator: false subcommand: type: string default: "subcommand" inputBinding: position: 1 data: type: string inputBinding: position: 2 baseCommand: - "program" arguments: []
allows the user to override the subcommand.
- Building a shell script to sort the parameters before invocation – inelegant, and even more complicated if specific parameters can override global parameters of the same name.
I’m not sure what the mechanism would be.
- Splicing arguments at a numbered position instead of the beginning?
- Defining hidden readonly inputs?
- Using expressions to post-process the generated command line?
Thanks in advance for any suggestions