add argparse and simple option to output json
This commit is contained in:
parent
f35bd34706
commit
b8eb7b0ef8
1 changed files with 14 additions and 5 deletions
19
wifi.py
19
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")
|
||||
|
|
Loading…
Add table
Reference in a new issue