auto_rest.cli¶
The cli
module manages input/output operations for the application's
command line interface (CLI). Application inputs are parsed using the
built-in argparse
module while output messages are handled using the
Python logging
library.
Example: Parsing Arguments
The create_argument_parser
function returns an ArgumentParser
instance with pre-populated argument definitions.
from auto_rest.cli import create_argument_parser
parser = create_argument_parser()
args = parser.parse_args()
print(vars(args))
Example: Enabling Console Logging
The configure_cli_logging
method overrides any existing logging
configurations and enables console logging according to the provided log
level.
from auto_rest.cli import configure_cli_logging
configure_cli_logging(log_level="INFO")
configure_cli_logging(level)
¶
Enable console logging with the specified application log level.
Calling this method overrides and removes all previously configured logging configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
str
|
The Python logging level. |
required |
Source code in auto_rest/cli.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
create_cli_parser(exit_on_error=True)
¶
Create a command-line argument parser with preconfigured arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exit_on_error
|
bool
|
Whether to exit the program on a parsing error. |
True
|
Returns:
Type | Description |
---|---|
ArgumentParser
|
An argument parser instance. |
Source code in auto_rest/cli.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|