def parse_args(argv): parser = argparse.ArgumentParser( description=f"ESPHome v{const.__version__}") parser.add_argument("-v", "--verbose", help="Enable verbose esphome logs.", action="store_true") parser.add_argument("-q", "--quiet", help="Disable all esphome logs.", action="store_true") parser.add_argument("--dashboard", help=argparse.SUPPRESS, action="store_true") parser.add_argument( "-s", "--substitution", nargs=2, action="append", help="Add a substitution", metavar=("key", "value"), ) parser.add_argument("configuration", help="Your YAML configuration file.", nargs="*") subparsers = parser.add_subparsers(help="Commands", dest="command") subparsers.required = True subparsers.add_parser("config", help="Validate the configuration and spit it out.") parser_compile = subparsers.add_parser( "compile", help="Read the configuration and compile a program.") parser_compile.add_argument( "--only-generate", help="Only generate source code, do not compile.", action="store_true", ) parser_upload = subparsers.add_parser("upload", help="Validate the configuration " "and upload the latest binary.") parser_upload.add_argument( "--upload-port", help="Manually specify the upload port to use. " "For example /dev/cu.SLAB_USBtoUART.", ) parser_logs = subparsers.add_parser("logs", help="Validate the configuration " "and show all MQTT logs.") parser_logs.add_argument("--topic", help="Manually set the topic to subscribe to.") parser_logs.add_argument("--username", help="Manually set the username.") parser_logs.add_argument("--password", help="Manually set the password.") parser_logs.add_argument("--client-id", help="Manually set the client id.") parser_logs.add_argument( "--serial-port", help="Manually specify a serial port to use" "For example /dev/cu.SLAB_USBtoUART.", ) parser_run = subparsers.add_parser( "run", help="Validate the configuration, create a binary, " "upload it, and start MQTT logs.", ) parser_run.add_argument( "--upload-port", help="Manually specify the upload port/ip to use. " "For example /dev/cu.SLAB_USBtoUART.", ) parser_run.add_argument("--no-logs", help="Disable starting MQTT logs.", action="store_true") parser_run.add_argument( "--topic", help="Manually set the topic to subscribe to for logs.") parser_run.add_argument("--username", help="Manually set the MQTT username for logs.") parser_run.add_argument("--password", help="Manually set the MQTT password for logs.") parser_run.add_argument("--client-id", help="Manually set the client id for logs.") parser_clean = subparsers.add_parser( "clean-mqtt", help="Helper to clear an MQTT topic from " "retain messages.") parser_clean.add_argument("--topic", help="Manually set the topic to subscribe to.") parser_clean.add_argument("--username", help="Manually set the username.") parser_clean.add_argument("--password", help="Manually set the password.") parser_clean.add_argument("--client-id", help="Manually set the client id.") subparsers.add_parser( "wizard", help="A helpful setup wizard that will guide " "you through setting up esphome.", ) subparsers.add_parser("mqtt-fingerprint", help="Get the SSL fingerprint from a MQTT broker.") subparsers.add_parser("version", help="Print the esphome version and exit.") subparsers.add_parser("clean", help="Delete all temporary build files.") dashboard = subparsers.add_parser( "dashboard", help="Create a simple web server for a dashboard.") dashboard.add_argument( "--port", help="The HTTP port to open connections on. Defaults to 6052.", type=int, default=6052, ) dashboard.add_argument( "--username", help="The optional username to require " "for authentication.", type=str, default="", ) dashboard.add_argument( "--password", help="The optional password to require " "for authentication.", type=str, default="", ) dashboard.add_argument("--open-ui", help="Open the dashboard UI in a browser.", action="store_true") dashboard.add_argument("--hassio", help=argparse.SUPPRESS, action="store_true") dashboard.add_argument("--socket", help="Make the dashboard serve under a unix socket", type=str) vscode = subparsers.add_parser("vscode", help=argparse.SUPPRESS) vscode.add_argument("--ace", action="store_true") subparsers.add_parser("update-all", help=argparse.SUPPRESS) return parser.parse_args(argv[1:])
def parse_args(argv): parser = argparse.ArgumentParser( description=f'ESPHome v{const.__version__}') parser.add_argument('-v', '--verbose', help="Enable verbose esphome logs.", action='store_true') parser.add_argument('-q', '--quiet', help="Disable all esphome logs.", action='store_true') parser.add_argument('--dashboard', help=argparse.SUPPRESS, action='store_true') parser.add_argument('configuration', help='Your YAML configuration file.', nargs='*') subparsers = parser.add_subparsers(help='Commands', dest='command') subparsers.required = True subparsers.add_parser('config', help='Validate the configuration and spit it out.') parser_compile = subparsers.add_parser( 'compile', help='Read the configuration and compile a program.') parser_compile.add_argument( '--only-generate', help="Only generate source code, do not compile.", action='store_true') parser_upload = subparsers.add_parser('upload', help='Validate the configuration ' 'and upload the latest binary.') parser_upload.add_argument('--upload-port', help="Manually specify the upload port to use. " "For example /dev/cu.SLAB_USBtoUART.") parser_logs = subparsers.add_parser('logs', help='Validate the configuration ' 'and show all MQTT logs.') parser_logs.add_argument('--topic', help='Manually set the topic to subscribe to.') parser_logs.add_argument('--username', help='Manually set the username.') parser_logs.add_argument('--password', help='Manually set the password.') parser_logs.add_argument('--client-id', help='Manually set the client id.') parser_logs.add_argument('--serial-port', help="Manually specify a serial port to use" "For example /dev/cu.SLAB_USBtoUART.") parser_run = subparsers.add_parser( 'run', help='Validate the configuration, create a binary, ' 'upload it, and start MQTT logs.') parser_run.add_argument('--upload-port', help="Manually specify the upload port/ip to use. " "For example /dev/cu.SLAB_USBtoUART.") parser_run.add_argument('--no-logs', help='Disable starting MQTT logs.', action='store_true') parser_run.add_argument( '--topic', help='Manually set the topic to subscribe to for logs.') parser_run.add_argument('--username', help='Manually set the MQTT username for logs.') parser_run.add_argument('--password', help='Manually set the MQTT password for logs.') parser_run.add_argument('--client-id', help='Manually set the client id for logs.') parser_clean = subparsers.add_parser( 'clean-mqtt', help="Helper to clear an MQTT topic from " "retain messages.") parser_clean.add_argument('--topic', help='Manually set the topic to subscribe to.') parser_clean.add_argument('--username', help='Manually set the username.') parser_clean.add_argument('--password', help='Manually set the password.') parser_clean.add_argument('--client-id', help='Manually set the client id.') subparsers.add_parser('wizard', help="A helpful setup wizard that will guide " "you through setting up esphome.") subparsers.add_parser('mqtt-fingerprint', help="Get the SSL fingerprint from a MQTT broker.") subparsers.add_parser('version', help="Print the esphome version and exit.") subparsers.add_parser('clean', help="Delete all temporary build files.") dashboard = subparsers.add_parser( 'dashboard', help="Create a simple web server for a dashboard.") dashboard.add_argument( "--port", help="The HTTP port to open connections on. Defaults to 6052.", type=int, default=6052) dashboard.add_argument("--username", help="The optional username to require " "for authentication.", type=str, default='') dashboard.add_argument("--password", help="The optional password to require " "for authentication.", type=str, default='') dashboard.add_argument("--open-ui", help="Open the dashboard UI in a browser.", action='store_true') dashboard.add_argument("--hassio", help=argparse.SUPPRESS, action="store_true") dashboard.add_argument("--socket", help="Make the dashboard serve under a unix socket", type=str) vscode = subparsers.add_parser('vscode', help=argparse.SUPPRESS) vscode.add_argument('--ace', action='store_true') subparsers.add_parser('update-all', help=argparse.SUPPRESS) return parser.parse_args(argv[1:])
def parse_args(argv): parser = argparse.ArgumentParser(prog='esphome') parser.add_argument('-v', '--verbose', help="Enable verbose esphome logs.", action='store_true') parser.add_argument( '--dashboard', help="Internal flag to set if the command is run from the " "dashboard.", action='store_true') parser.add_argument('configuration', help='Your YAML configuration file.') subparsers = parser.add_subparsers(help='Commands', dest='command') subparsers.required = True subparsers.add_parser('config', help='Validate the configuration and spit it out.') parser_compile = subparsers.add_parser( 'compile', help='Read the configuration and compile a program.') parser_compile.add_argument( '--only-generate', help="Only generate source code, do not compile.", action='store_true') parser_upload = subparsers.add_parser('upload', help='Validate the configuration ' 'and upload the latest binary.') parser_upload.add_argument('--upload-port', help="Manually specify the upload port to use. " "For example /dev/cu.SLAB_USBtoUART.") parser_upload.add_argument('--host-port', help="Specify the host port.", type=int) parser_logs = subparsers.add_parser('logs', help='Validate the configuration ' 'and show all MQTT logs.') parser_logs.add_argument('--topic', help='Manually set the topic to subscribe to.') parser_logs.add_argument('--username', help='Manually set the username.') parser_logs.add_argument('--password', help='Manually set the password.') parser_logs.add_argument('--client-id', help='Manually set the client id.') parser_logs.add_argument('--serial-port', help="Manually specify a serial port to use" "For example /dev/cu.SLAB_USBtoUART.") parser_run = subparsers.add_parser( 'run', help='Validate the configuration, create a binary, ' 'upload it, and start MQTT logs.') parser_run.add_argument('--upload-port', help="Manually specify the upload port/ip to use. " "For example /dev/cu.SLAB_USBtoUART.") parser_run.add_argument('--host-port', help="Specify the host port to use for OTA", type=int) parser_run.add_argument('--no-logs', help='Disable starting MQTT logs.', action='store_true') parser_run.add_argument( '--topic', help='Manually set the topic to subscribe to for logs.') parser_run.add_argument('--username', help='Manually set the MQTT username for logs.') parser_run.add_argument('--password', help='Manually set the MQTT password for logs.') parser_run.add_argument('--client-id', help='Manually set the client id for logs.') parser_clean = subparsers.add_parser( 'clean-mqtt', help="Helper to clear an MQTT topic from " "retain messages.") parser_clean.add_argument('--topic', help='Manually set the topic to subscribe to.') parser_clean.add_argument('--username', help='Manually set the username.') parser_clean.add_argument('--password', help='Manually set the password.') parser_clean.add_argument('--client-id', help='Manually set the client id.') subparsers.add_parser('wizard', help="A helpful setup wizard that will guide " "you through setting up esphome.") subparsers.add_parser('mqtt-fingerprint', help="Get the SSL fingerprint from a MQTT broker.") subparsers.add_parser('version', help="Print the esphome version and exit.") subparsers.add_parser('clean', help="Delete all temporary build files.") dashboard = subparsers.add_parser( 'dashboard', help="Create a simple web server for a dashboard.") dashboard.add_argument( "--port", help="The HTTP port to open connections on. Defaults to 6052.", type=int, default=6052) dashboard.add_argument( "--password", help="The optional password to require for all requests.", type=str, default='') dashboard.add_argument("--open-ui", help="Open the dashboard UI in a browser.", action='store_true') dashboard.add_argument( "--hassio", help="Internal flag used to tell esphome is started as a Hass.io " "add-on.", action="store_true") dashboard.add_argument("--socket", help="Make the dashboard serve under a unix socket", type=str) subparsers.add_parser( 'hass-config', help="Dump the configuration entries that should be added " "to Home Assistant when not using MQTT discovery.") return parser.parse_args(argv[1:])