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
|
# 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,11 +100,19 @@ def connect(ssid: str) -> bool:
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
my_dict = get_wifi()
|
|
||||||
for element in my_dict:
|
ap = argparse.ArgumentParser()
|
||||||
print(element)
|
ap.add_argument("-j", "--json", help="just output current scanned wifi as json", action="store_true")
|
||||||
my_input = input("wifi_name: ")
|
args = ap.parse_args()
|
||||||
connect(my_input)
|
|
||||||
|
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:
|
except KeyboardInterrupt:
|
||||||
print("")
|
print("")
|
||||||
print(">>> Interrupted by user")
|
print(">>> Interrupted by user")
|
||||||
|
|
Loading…
Add table
Reference in a new issue