def init(program : ArgumentParser) -> None: global ARGS if not ARGS: ip = None if not helper.has_argument('--xiaomi-yeelight-ip'): ip = discover_ips() if ip: program.add_argument('--xiaomi-yeelight-ip', default = ip) else: program.add_argument('--xiaomi-yeelight-ip', action = 'append', required = True) ARGS = helper.get_first(program.parse_known_args())
def init(program: ArgumentParser) -> None: global ARGS if not ARGS: ip = None if not helper.has_argument('--philips-hue-ip'): ip = helper.get_first(discover_ips()) if ip: program.add_argument('--philips-hue-ip', default=ip) else: program.add_argument('--philips-hue-ip', required=True) program.add_argument('--philips-hue-light', action='append') program.add_argument('--philips-hue-group', action='append') ARGS = helper.get_first(program.parse_known_args())
def init(program): global ARGS if not ARGS: ip = None if not helper.has_argument('--philips-hue-ip'): ip = discover_ip() if ip: program.add_argument('--philips-hue-ip', default = ip) else: program.add_argument('--philips-hue-ip', required = True) program.add_argument('--philips-hue-light', action = 'append') program.add_argument('--philips-hue-group', action = 'append') ARGS = program.parse_known_args()[0]
def cli() -> None: signal.signal(signal.SIGINT, lambda signal_number, frame: destroy()) program = ArgumentParser() program.add_argument('-V', '--version', action='version', version=metadata.get('name') + ' ' + metadata.get('version')) program.add_argument('-P', '--producer', action='append', choices=producer.__all__, required=True) program.add_argument('-C', '--consumer', action='append', choices=consumer.__all__, required=helper.has_argument('--dry-run') is False) program.add_argument('-I', '--background-interval', default=60, type=int) program.add_argument('-B', '--background-run', action='store_true') program.add_argument('-D', '--dry-run', action='store_true') init(program)
def test_has_argument() -> None: assert helper.has_argument('invalid') is False