diff --git a/pynsot/commands/cmd_sites.py b/pynsot/commands/cmd_sites.py index bf31472..a795812 100644 --- a/pynsot/commands/cmd_sites.py +++ b/pynsot/commands/cmd_sites.py @@ -30,6 +30,7 @@ ('id', 'ID'), ('name', 'Name'), ('description', 'Description'), + ('parent', 'Parent'), ) @@ -66,8 +67,14 @@ def cli(ctx): help='The name of the Site.', required=True, ) +@click.option( + '-p', + '--parent', + metavar='PARENT', + help='ID of parent site' +) @click.pass_context -def add(ctx, description, name): +def add(ctx, description, name, parent): """ Add a new Site. @@ -181,15 +188,21 @@ def remove(ctx, id): metavar='NAME', help='The name of the Site.', ) +@click.option( + '-p', + '--parent', + metavar='PARENT', + help='ID of parent site' +) @click.pass_context -def update(ctx, description, id, name): +def update(ctx, description, id, name, parent): """ Update a Site. When updating a Site you must provide the unique ID (-i/--id) and at least - one of the -n/--name or -d/--description arguments. + one of the -n/--name, -p/--parent or -d/--description arguments. """ - if name is None and description is None: + if name is None and description is None and parent is None: msg = 'You must supply at least one of -n/--name or -d/--description' raise click.UsageError(msg) diff --git a/tests/fixtures.py b/tests/fixtures.py index 68c677b..bd6a9c1 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -85,7 +85,7 @@ def client(config): @pytest.fixture def site(client): """Returns a Site object.""" - return client.sites.post({'name': 'Foo', 'description': 'Foo site.'}) + return client.sites.post({'name': 'Foo', 'description': 'Foo site.', 'parent': ''}) @pytest.fixture