blob: 469d6bd87eccfc06b97f132981c2ea797a504830 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
|