diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-01-10 16:08:04 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-01-10 16:08:04 +0200 |
commit | 0d03db771b48f7d90cf96560c32048001809e84f (patch) | |
tree | 0dd2afc2fef804df1e501c60000d0d08e1773e50 /with | |
parent | 9fdf74a1b44f76a3749ae4111472647d79cf3f6a (diff) | |
download | extrautils-0d03db771b48f7d90cf96560c32048001809e84f.tar.gz |
Add: a bunch of new scripts
Diffstat (limited to 'with')
-rwxr-xr-x | with | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,35 @@ +#!/usr/bin/python3 + + +import os + + +import cliapp +import yaml + + +class With(cliapp.Application): + + def add_settings(self): + self.settings.string( + ['env-file', 'e'], + 'read environment description from FILE', + metavar='FILE', + default=os.path.expanduser('~/.config/with-envs/environments.yaml')) + + def process_args(self, args): + env_name = args[0] + argv = args[1:] + + envs = self.get_environments() + print(envs) + env = dict(os.environ) + env.update(envs[env_name]) + cliapp.runcmd(argv, env=env, stdout=None, stderr=None) + + def get_environments(self): + filename = self.settings['env-file'] + return yaml.safe_load(open(filename)) + + +With().run() |