Support --ip and --version command line options and -h/--help

[ci skip]
pull/896/head
probonopd 2 weeks ago
parent 988f08c36d
commit 778d6846be
  1. 16
      updater.py

@ -90,6 +90,8 @@ def extract_zip(zip_path):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="MiniDexed Updater")
parser.add_argument("-v", action="store_true", help="Enable verbose FTP debug output")
parser.add_argument("--ip", type=str, help="IP address of the device to upload to (skip mDNS discovery)")
parser.add_argument("--version", type=int, choices=[1,2,3], help="Version to upload: 1=Latest official, 2=Continuous, 3=Local build (skip prompt)")
args = parser.parse_args()
import time
@ -105,6 +107,14 @@ if __name__ == "__main__":
]
if has_local_build:
release_options.append(("Local build (from src/)", None))
if args.version:
selected_idx = args.version - 1
if selected_idx < 0 or selected_idx >= len(release_options):
print(f"Invalid version selection: {args.version}")
sys.exit(1)
github_url = release_options[selected_idx][1]
else:
print("Which release do you want to update?")
for idx, (desc, _) in enumerate(release_options):
print(f" [{idx+1}] {desc}")
@ -175,6 +185,12 @@ if __name__ == "__main__":
# Using mDNS to find the IP address of the device(s) that advertise the FTP service "_ftp._tcp."
ip_addresses = []
device_names = []
selected_ip = None
selected_name = None
if args.ip:
selected_ip = args.ip
selected_name = args.ip
else:
zeroconf = Zeroconf()
listener = MyListener(ip_addresses, device_names)
browser = ServiceBrowser(zeroconf, "_ftp._tcp.local.", listener)

Loading…
Cancel
Save