diff options
author | Jouni Malinen <jouni@qca.qualcomm.com> | 2013-11-29 10:41:34 (GMT) |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2014-01-27 20:08:13 (GMT) |
commit | ab1db08c0505804676a9862b59ed9b8800949957 (patch) | |
tree | ae919084a8c074d4af62bb14acad6840abc08fcc /hostapd/wps-ap-nfc.py | |
parent | 6f8fa6e552d82c026d8b7a2630119423de002dd5 (diff) | |
download | hostap-ab1db08c0505804676a9862b59ed9b8800949957.zip hostap-ab1db08c0505804676a9862b59ed9b8800949957.tar.gz hostap-ab1db08c0505804676a9862b59ed9b8800949957.tar.bz2 |
WPS NFC: Use argparse in the nfcpy scripts
This cleans up command line parsing and simplifies the commands.
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'hostapd/wps-ap-nfc.py')
-rwxr-xr-x | hostapd/wps-ap-nfc.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/hostapd/wps-ap-nfc.py b/hostapd/wps-ap-nfc.py index be7338d..f72564f 100755 --- a/hostapd/wps-ap-nfc.py +++ b/hostapd/wps-ap-nfc.py @@ -9,6 +9,7 @@ import os import sys import time +import argparse import nfc import nfc.ndef @@ -214,19 +215,27 @@ def llcp_connected(llc): def main(): clf = nfc.ContactlessFrontend() + parser = argparse.ArgumentParser(description='nfcpy to hostapd integration for WPS NFC operations') + parser.add_argument('--only-one', '-1', action='store_true', + help='run only one operation and exit') + parser.add_argument('command', choices=['write-config', + 'write-password'], + nargs='?') + args = parser.parse_args() + + global only_one + only_one = args.only_one + try: if not clf.open("usb"): print "Could not open connection with an NFC device" raise SystemExit - global only_one - only_one = False - - if len(sys.argv) > 1 and sys.argv[1] == "write-config": + if args.command == "write-config": wps_write_config_tag(clf) raise SystemExit - if len(sys.argv) > 1 and sys.argv[1] == "write-password": + if args.command == "write-password": wps_write_password_tag(clf) raise SystemExit |