Files
auto-huami-token/auto_huami_token/args_handler.py
T
2026-03-05 12:01:08 +01:00

31 lines
2.1 KiB
Python

#!/usr/bin/env python3
import argparse
from argparse import Namespace
class ArgsHandler:
def __init__(self):
parser = argparse.ArgumentParser(
prog = 'auto-huami-token',
description = 'Can acquire an amazfit or xiaomi key for your gadget and downloads amazfit and huami agps firmware updates',
prefix_chars='+-',
exit_on_error=False)
parser.add_argument('-s', '--save', action = 'store_true', help = 'Save argument values to the config file')
parser.add_argument('-t', '--target-dir', help = 'Move results to this directory after download')
parser.add_argument('-c', '--config-path', help = 'Use the specified filepath to load or save config values')
parser.add_argument('-l', '--with-logging', dest='log_to', help = "Write log messages to this file or folder, or the systemd journal with 'journal'. If a folder is specified the logfile will be called hf-cli.log. The target folder must exist.")
parser.add_argument('+l', '-q', '--without-logging', dest='log_to', action='store_const', const='disabled', help = "Write log messages to this file or folder, or the systemd journal with 'journal'. If a folder is specified the logfile will be called hf-cli.log. The target folder must exist.")
parser.add_argument('-v', '--verbose', action='store_true', default=None, help = 'Write each operation to the console')
targets_group = parser.add_mutually_exclusive_group()
targets_group.add_argument('-C', '--use-config', action='store_true', help = 'Load targets from the specified config file or ./config.json if not specified')
targets_group.add_argument('-k', '--keys', action = 'store_true', help = 'Fetch keys')
targets_group.add_argument('-i', '--setup', action = 'store_true', help = 'Interactively setup config.json. You will be prompted for values')
targets_group.add_argument('-g', '--gps', action = 'store_true', help = 'Fetch agps files',)
self.parser = parser
def parse_args(self, args: list[str]) -> Namespace:
return self.parser.parse_args(args)
def print_help(self):
self.parser.print_help()