Jaymon / captain

command line python scripts for humans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

client

Jaymon opened this issue · comments

I've now done a variation of this in 2 separate projects:

class Script(Captain):
    script_quiet = False

    def __init__(self, subcommand):
        self.cmd_prefix = "python -m <MODULE_NAME> {}".format(subcommand.replace("_", "-"))
        super(Script, self).__init__("")

So it would be worth adding something like this to captain so I don't have to override it everytime

I think adding ScriptClient and ModuleClient would work, ScriptClient would basically be a thin wrapper around Captain which will stay awhile for legacy purposes and ModuleClient will contain roughly the above code

class ModuleClient(Captain):
    script_quiet = False

    def __init__(self, module_name):
        self.cmd_prefix = "python -m {}".format(module_name)
        super(ModuleClient, self).__init__("")

change env to environ and add a method that will append to the environment instead of having to do something like this:

c = Captain("script.py")
environ = c.env
environ["FOO"] = "bar"
c.env = environ