ops can be used to run scripts, e.g. in a bin/ directory, passing command-line arguments to the script. It would be useful if ops could also perform some checks on arguments.
The minimum check would be checking number of arguments. It could also perform some validation of the argument values.
With the action definition
actions:
hello:
command: echo "Hello, "
arguments:
name:
optional: false
description: says 'hello' to the given name
, ops could infer that the required number of arguments is one. ops hello would print:
ops: Usage: hello <name>
says 'hello' to the given name
and exit with the existing syntax error status code.
ops help hello could print the same message, but exit with 0.
actions:
copy:
command: scp -i key/id_rsa
arguments:
sources:
optional: false
multiple: true
description: a list of locations to copy files from; must be all local paths or all remote paths
destination:
optional: false
description: the location to which to copy files; can be a local or remote file
From this action definition, ops copy file host: would execute the command. ops copy file1 file2 host would execute the command. ops copy or ops help copy would print:
ops: Usage: copy <sources> <destination>
sources: a list of locations to copy files from; must be all local paths or all remote paths
desintations: the location to which to copy files; can be a local or remote file
Should more than one multiple: true argument be allowed? Can ops perform syntax checking in this case?Does this add too much complexity for the value it delivers? ops will be less of a pleasure to use if users feel that because this feature exists they must now document parameters. It does, however, help users document the scripts they use in their project.Does it make sense for ops to do this? Scripts can be called outside of ops, and ops should never assume otherwise. Argument checking would be better in the script itself.
ops
can be used to run scripts, e.g. in abin/
directory, passing command-line arguments to the script. It would be useful ifops
could also perform some checks on arguments.The minimum check would be checking number of arguments. It could also perform some validation of the argument values.
With the action definition
,
ops
could infer that the required number of arguments is one.ops hello
would print:and exit with the existing syntax error status code.
ops help hello
could print the same message, but exit with 0.From this action definition,
ops copy file host:
would execute the command.ops copy file1 file2 host
would execute the command.ops copy
orops help copy
would print:Should more than one
multiple: true
argument be allowed? Canops
perform syntax checking in this case? Does this add too much complexity for the value it delivers?ops
will be less of a pleasure to use if users feel that because this feature exists they must now document parameters. It does, however, help users document the scripts they use in their project. Does it make sense forops
to do this? Scripts can be called outside ofops
, andops
should never assume otherwise. Argument checking would be better in the script itself.