Skip to content

Feature request: Argument config files #714

@stag-enterprises

Description

@stag-enterprises

It would be nice to be able to specify config files containing CLI args, and when a CLI app is ran the args in those files would be added on (though with duplicate args being overwritten). This also helps more closely Integrate config files and the arg parser.

An example of what I mean:

# script.py

from plumbum import cli, local

class MyApp(cli.Application):
    myarg = cli.SwitchAttr(["--myarg"], str, mandatory=True)

    @cli.configs(local.path("~/.config/myapp/config.cfg"))
    def main(self):
        print("myarg: ", self.myarg)

MyApp.run()
# ~/.config/myapp/config.cfg
--myarg=foobar
$ python script.py
myarg: foobar
$ python script.py --help
Usage:
    script.py [SWITCHES] args...

Argument config files:
    ~/.config/myapp/config.cfg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions