From 5bc8a878dc1a2b76780a9c55c2f5cfd86297736c Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 11 Jul 2021 15:39:14 +0200 Subject: [PATCH] Treat empty CLI args as error and show usage --- src/spoc_cli.py | 3 +-- tests/test_cli.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spoc_cli.py b/src/spoc_cli.py index 0311ba4..bb68423 100644 --- a/src/spoc_cli.py +++ b/src/spoc_cli.py @@ -79,8 +79,7 @@ def prune(): def parse_args(args=None): parser = argparse.ArgumentParser(description='SPOC application manager') - parser.set_defaults(action=None) - subparsers = parser.add_subparsers() + subparsers = parser.add_subparsers(dest='action', required=True) parser_list = subparsers.add_parser('list') parser_list.set_defaults(action=listing) diff --git a/tests/test_cli.py b/tests/test_cli.py index cad1e7b..83efc33 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -317,6 +317,7 @@ def test_main_invalid(prune, login, stop_all, start_autostarted, status, stop, s ['autostart', 'someapp'], ['login'], ['invalid'], + [], ]) def test_main_systemexit(argv): argv.insert(0, 'foo')