This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
2015-11-27 18:38:33 +00:00
|
|
|
import click
|
2015-12-03 18:07:08 +00:00
|
|
|
from project.utils import config
|
2015-11-27 18:38:33 +00:00
|
|
|
|
2015-12-02 22:39:40 +00:00
|
|
|
|
2015-12-03 18:18:04 +00:00
|
|
|
@click.group('config')
|
|
|
|
def cli():
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command('show')
|
|
|
|
@click.argument('key', nargs=-1)
|
|
|
|
def show(key):
|
|
|
|
key = " ".join(key)
|
2015-12-03 18:07:08 +00:00
|
|
|
print(config.get(key))
|
2015-12-03 18:18:04 +00:00
|
|
|
return 0
|
2015-12-03 22:33:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command('set')
|
|
|
|
@click.argument('key', nargs=1)
|
|
|
|
@click.argument('value', nargs=-1)
|
|
|
|
def set(key, value):
|
2015-12-06 14:20:55 +00:00
|
|
|
if type(value) == type(()):
|
|
|
|
value = " ".join(value)
|
2015-12-03 22:33:04 +00:00
|
|
|
status = config.set(key, value)
|
|
|
|
if status == "SUCCESS":
|
2015-12-03 22:43:42 +00:00
|
|
|
print("{} set to {}".format(key, value))
|
2015-12-03 22:33:04 +00:00
|
|
|
return 0
|
|
|
|
elif status == "NO_KEY":
|
|
|
|
print("Key {} not found".format(key))
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
print("Something went wrong:", status)
|
|
|
|
return 1
|