Changeset - bf7668f56c5d
[Not reviewed]
version_5
0 1 0
Dennis Fink - 9 years ago 2015-10-14 22:46:13
dennis.fink@c3l.lu
Added bridgeprogram switch to add server option
1 file changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
ennstatus/cli/commands/config.py
Show inline comments
 
@@ -31,8 +31,9 @@ def server():
 
@click.argument('name')
 
@click.option('-i', '--ips', prompt='IPs (comma separated)')
 
@click.password_option()
 
@click.option('--bridgeprogram/--no-bridgeprogram', default=False)
 
@click.pass_obj
 
def add(obj, name, ips, password):
 
def add(obj, name, ips, password, bridgeprogram):
 

	
 
    with obj['config_file'].open() as f:
 
        config = json.load(f)
 
@@ -60,6 +61,12 @@ def add(obj, name, ips, password):
 
        'PASSWORD': password
 
    }
 

	
 
    if bridgeprogram:
 
        try:
 
            config['ENNSTATUS_BRIDGE_PROGRAM'].append(name)
 
        except KeyError:
 
            config['ENNSTATUS_BRIDGE_PROGRAM'] = [name]
 

	
 
    with obj['config_file'].open(mode='w', encoding='utf-8') as f:
 
        json.dump(config, f, indent=4, sort_keys=True)
 

	
 
@@ -78,5 +85,10 @@ def delete(obj, name):
 
    except KeyError:
 
        raise SystemExit('{} does not exists!'.format(name))
 

	
 
    try:
 
        config['ENNSTATUS_BRIDGE_PROGRAM'].remove(name)
 
    except KeyError:
 
        pass
 

	
 
    with obj['config_file'].open(mode='w', encoding='utf-8') as f:
 
        json.dump(config, f, indent=4, sort_keys=True)
0 comments (0 inline, 0 general)