laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/36920?usp=email )

Change subject: contrib/sim-rest-client: don't crash without args
......................................................................

contrib/sim-rest-client: don't crash without args

When running without an argument, let argparse print a nice usage error:

  $ ./sim-rest-client.py
  usage: sim-rest-client.py [-h] [-H HOST] [-p PORT] [-v] [-n SLOT_NR] 
{auth,info} ...
  sim-rest-client.py: error: the following arguments are required: {auth,info}

Instead of:

  $ ./sim-rest-client.py
  Traceback (most recent call last):
    File "/usr/share/pysim/contrib/./sim-rest-client.py", line 185, in <module>
      main(sys.argv)
    File "/usr/share/pysim/contrib/./sim-rest-client.py", line 181, in main
      args.func(args)
      ^^^^^^^^^
  AttributeError: 'Namespace' object has no attribute 'func'

Change-Id: I92998d9b94dcfb9dcfc3da161fe5d8f45f242b78
---
M contrib/sim-rest-client.py
1 file changed, 27 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/contrib/sim-rest-client.py b/contrib/sim-rest-client.py
index 7da2363..a9fabb8 100755
--- a/contrib/sim-rest-client.py
+++ b/contrib/sim-rest-client.py
@@ -162,6 +162,7 @@
     parser.add_argument("-v", "--verbose", help="increase output verbosity", 
action='count', default=0)
     parser.add_argument("-n", "--slot-nr", help="SIM slot number", type=int, 
default=0)
     subp = parser.add_subparsers()
+    subp.required = True

     auth_p = subp.add_parser('auth', help='UMTS AKA Authentication')
     auth_p.add_argument("-c", "--count", help="Auth count", type=int, 
default=10)

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/36920?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I92998d9b94dcfb9dcfc3da161fe5d8f45f242b78
Gerrit-Change-Number: 36920
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to