add argparse and simple option to output json

This commit is contained in:
Ranomier 2025-01-16 00:47:05 +01:00
parent f35bd34706
commit b8eb7b0ef8

View file

@ -3,6 +3,7 @@
# TODO: can't connect to AP with empty ssid # TODO: can't connect to AP with empty ssid
import subprocess as sp import subprocess as sp
import sys import sys
import argparse
CFG = { CFG = {
@ -99,6 +100,14 @@ def connect(ssid: str) -> bool:
def main(): def main():
try: try:
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() my_dict = get_wifi()
for element in my_dict: for element in my_dict:
print(element) print(element)