* @param debug - if true, throw instead of exiting on parse errors
(debug = false)
| 63 | * @param debug - if true, throw instead of exiting on parse errors |
| 64 | */ |
| 65 | constructor(debug = false) { |
| 66 | const prog = process.argv[1] ? path.basename(process.argv[1]) : 'appium'; |
| 67 | const parser = new ArgumentParser({ |
| 68 | add_help: true, |
| 69 | description: |
| 70 | 'A webdriver-compatible server that facilitates automation of web, mobile, and other ' + |
| 71 | 'types of apps across various platforms.', |
| 72 | prog, |
| 73 | }); |
| 74 | |
| 75 | ArgParser._patchExit(parser); |
| 76 | |
| 77 | this.prog = prog; |
| 78 | |
| 79 | this.debug = debug; |
| 80 | |
| 81 | this.parser = parser; |
| 82 | |
| 83 | parser.add_argument('-v', '--version', { |
| 84 | action: 'version', |
| 85 | version: APPIUM_VER, |
| 86 | }); |
| 87 | |
| 88 | const subParsers = parser.add_subparsers({dest: 'subcommand'}); |
| 89 | |
| 90 | // add the 'server' subcommand, and store the raw arguments on the parser |
| 91 | // object as a way for other parts of the code to work with the arguments |
| 92 | // conceptually rather than just through argparse |
| 93 | const serverArgs = ArgParser._addServerToParser(subParsers); |
| 94 | |
| 95 | this.rawArgs = serverArgs; |
| 96 | |
| 97 | // add the 'driver' and 'plugin' subcommands |
| 98 | ArgParser._addExtensionCommandsToParser(subParsers); |
| 99 | |
| 100 | // add the 'setup' command |
| 101 | ArgParser._addSetupToParser(subParsers); |
| 102 | |
| 103 | // backwards compatibility / drop-in wrapper |
| 104 | this.parse_args = this.parseArgs; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Normalizes server arg keys from schema names to parser destination names. |
nothing calls this directly
no test coverage detected