argbash icon indicating copy to clipboard operation
argbash copied to clipboard

feature request: ARG_USE_ENV required field

Open hemna opened this issue 5 years ago • 5 comments

It would be nice to specify if an ARG_USE_ENV var is required to be set. If it's not set, when the user calls the generated shell script, then an error should be output

ARG_USE_ENV([KEYNAME], , [openstack security keypair name to add to your server], [True]) where the last arg ([True]) means it's a required evironment variable. Yes, I can set the default, but the default value might be bogus.... Think password env var, it makes no sense to have a default for that, but it makes sense that it needs to be set.

The help output should note that it's a required field.

hemna avatar Apr 16 '19 23:04 hemna

I will give this a thought. I am little bit reluctant to implement it in Argbash, as I believe that

  1. required input should be supplied via positional arguments, and
  2. missing value of an env variable is super easy to handle in the script's body.

matejak avatar Apr 17 '19 20:04 matejak

  1. true, but you typically don't want a password on the command line as that can be seen elsewhere, especially if the script is long running . ./my_script -u myuser -p mypassword

  2. Also true, but I would assume that argbash is for parsing and handling arguments and although it can be handled manually in the script body, it would be nice if the argparser generated would handle all required arguments.

hemna avatar Apr 18 '19 00:04 hemna

Argbash could also generate references to the environment variables in the help function.

felipecrs avatar Jan 28 '20 14:01 felipecrs

Argbash could also generate references to the environment variables in the help function.

What do you mean? If you declare an env variable input, the help function gets expanded appropriately.

matejak avatar Jan 29 '20 00:01 matejak

Oh that's great! I didn't notice it, my bad.

felipecrs avatar Jan 29 '20 12:01 felipecrs