| 62 | |
| 63 | |
| 64 | def create_parser() -> _Parser: |
| 65 | parser = _Parser(description="ptpython: Interactive Python shell.") |
| 66 | parser.add_argument("--vi", action="store_true", help="Enable Vi key bindings") |
| 67 | parser.add_argument( |
| 68 | "-i", |
| 69 | "--interactive", |
| 70 | action="store_true", |
| 71 | help="Start interactive shell after executing this file.", |
| 72 | ) |
| 73 | parser.add_argument( |
| 74 | "--asyncio", |
| 75 | action="store_true", |
| 76 | help='Run an asyncio event loop to support top-level "await".', |
| 77 | ) |
| 78 | parser.add_argument( |
| 79 | "--light-bg", |
| 80 | action="store_true", |
| 81 | help="Run on a light background (use dark colors for text).", |
| 82 | ) |
| 83 | parser.add_argument( |
| 84 | "--dark-bg", |
| 85 | action="store_true", |
| 86 | help="Run on a dark background (use light colors for text).", |
| 87 | ) |
| 88 | parser.add_argument( |
| 89 | "--config-file", type=str, help="Location of configuration file." |
| 90 | ) |
| 91 | parser.add_argument("--history-file", type=str, help="Location of history file.") |
| 92 | parser.add_argument( |
| 93 | "-V", |
| 94 | "--version", |
| 95 | action="version", |
| 96 | version=metadata.version("ptpython"), |
| 97 | ) |
| 98 | parser.add_argument("args", nargs="*", help="Script and arguments") |
| 99 | return parser |
| 100 | |
| 101 | |
| 102 | def get_config_and_history_file(namespace: argparse.Namespace) -> tuple[str, str]: |