(argv)
| 23 | |
| 24 | |
| 25 | def init(argv): |
| 26 | arg_parser = ArgumentParser( |
| 27 | prog="aiohttp.web ...", description="Application CLI", add_help=False |
| 28 | ) |
| 29 | |
| 30 | # Positional argument |
| 31 | arg_parser.add_argument( |
| 32 | "message", |
| 33 | help="message to print" |
| 34 | ) |
| 35 | |
| 36 | # Optional argument |
| 37 | arg_parser.add_argument( |
| 38 | "--repeat", |
| 39 | help="number of times to repeat message", type=int, default="1" |
| 40 | ) |
| 41 | |
| 42 | # Avoid conflict with -h from `aiohttp.web` CLI parser |
| 43 | arg_parser.add_argument( |
| 44 | "--app-help", |
| 45 | help="show this message and exit", action="help" |
| 46 | ) |
| 47 | |
| 48 | args = arg_parser.parse_args(argv) |
| 49 | |
| 50 | app = Application() |
| 51 | app["args"] = args |
| 52 | app.router.add_route('GET', '/', display_message) |
| 53 | |
| 54 | return app |
nothing calls this directly
no test coverage detected