ts-command-line-args icon indicating copy to clipboard operation
ts-command-line-args copied to clipboard

Support for environment variables

Open lunaris opened this issue 2 years ago • 1 comments

Hey there. Would this library be open to a contribution that allowed supporting environment variables alongside command-line arguments? Something in line with commander's env method on Options, but with the typing benefits of ts-command-line-args. I'm envisaging an interface something like:

const args = parse<ICopyFilesArguments>({
  sourcePath: {
    type: String,
    env: "SOURCE_PATH",
  },
})

With the merge order being -- default values, configuration file, environment variables, command-line arguments. I'm not sure if this is something you feel falls under the remit of this library, but if it is, I'd be happy to help develop it. Our use case is largely one of backwards compatibility (we are porting some applications that support both command-line and environment variables to NodeJS) and a slightly better support for environment variables in some of the containerised environments we deploy to.

Thanks in advance for your thoughts and the work on the library so far!

lunaris avatar Apr 08 '22 08:04 lunaris