diff --git a/wifi.py b/wifi.py index 6401354..6f54750 100755 --- a/wifi.py +++ b/wifi.py @@ -3,6 +3,7 @@ # TODO: can't connect to AP with empty ssid import subprocess as sp import sys +import argparse CFG = { @@ -99,11 +100,19 @@ def connect(ssid: str) -> bool: def main(): try: - my_dict = get_wifi() - for element in my_dict: - print(element) - my_input = input("wifi_name: ") - connect(my_input) + + ap = argparse.ArgumentParser() + ap.add_argument("-j", "--json", help="just output current scanned wifi as json", action="store_true") + args = ap.parse_args() + + if args.json: + print(get_wifi()) + else: + my_dict = get_wifi() + for element in my_dict: + print(element) + my_input = input("wifi_name: ") + connect(my_input) except KeyboardInterrupt: print("") print(">>> Interrupted by user")