Executable added

This commit is contained in:
2022-06-25 17:51:04 +02:00
parent 80bce11258
commit ff4ed23325
6 changed files with 8 additions and 5 deletions

41
src/projectorpi/cli.py Executable file
View File

@@ -0,0 +1,41 @@
#! /usr/bin/env python3
from argparse import ArgumentParser
from .projector import ProjectorSerial
from .extron import ExtronSerial
verbose = False
def main():
parser = ArgumentParser(
prog="projectorpi", description="A tool that turns the projector on and off."
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="increase output verbosity"
)
sleep_or_wake = parser.add_mutually_exclusive_group(required=True)
sleep_or_wake.add_argument(
"input",
nargs="?",
type=int,
choices=[1, 2, 3, 4],
help="wake and select input",
)
sleep_or_wake.add_argument("--sleep", action="store_true", help="put in sleep mode")
args = parser.parse_args()
verbose = args.verbose
proj = ProjectorSerial(verbose)
extr = ExtronSerial(verbose)
if args.input:
proj.power_on()
extr.wake()
extr.change_input(args.input)
elif args.sleep:
proj.power_off()
extr.sleep()