Changeset - ca9bcbada262
[Not reviewed]
version_5
0 1 0
Dennis Fink - 9 years ago 2015-10-14 22:35:45
dennis.fink@c3l.lu
Arguments can not be prompted!
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ennstatus/cli/commands/config.py
Show inline comments
 
@@ -25,25 +25,25 @@ def show(obj):
 
        raise
 

	
 
    app = create_app()
 
    pprint(app.config)
 

	
 

	
 
@config.group(short_help='Configure servers')
 
def server():
 
    pass
 

	
 

	
 
@server.command('add', short_help='Add server')
 
@click.argument('name', prompt=True)
 
@click.argument('name')
 
@click.option('-i', '--ips', prompt='IPs (comma separated)')
 
@click.password_option()
 
@click.pass_obj
 
def add(obj, name, ips, password):
 

	
 
    config = json.load(obj['config_file'])
 
    name = name.lower()
 
    ips = [ip.strip() for ip in ips.split(',')]
 

	
 
    if name in config['ENNSTATUS_SERVERS']:
 
        try:
 
            click.confirm('Server already exits! Overwrite?', abort=True)
 
@@ -57,25 +57,25 @@ def add(obj, name, ips, password):
 
            raise SystemExit('ip {} is not accepted!'.format(str(ip)))
 

	
 
    config['ENNSTATUS_SERVERS'][name] = {
 
        'IPS': ips,
 
        'PASSWORD': password
 
    }
 

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

	
 

	
 
@server.command('delete', short_help='Remove server')
 
@click.argument('name', prompt=True)
 
@click.argument('name')
 
@click.pass_obj
 
def delete(obj, name):
 

	
 
    config = json.load(obj['config_file'])
 
    name = name.lower()
 

	
 
    try:
 
        del config['ENNSTATUS_SERVERS'][name]
 
    except KeyError:
 
        raise SystemExit('{} does not exists!'.format(name))
 

	
 
    with open(obj['config_file'], mode='w', encoding='utf-8') as f:
0 comments (0 inline, 0 general)