| 1 | import abc |
| 2 | import argparse |
| 3 | |
| 4 | from typing import Dict |
| 5 | from typing import List |
| 6 | from typing import Optional |
| 7 | from typing import TextIO |
| 8 | |
| 9 | class DocumentableMixin(metaclass=abc.ABCMeta): |
| 10 | def __init__( |
| 11 | self, |
| 12 | description: Optional[str] = None, |
| 13 | extra_sections: Optional[Dict[str, str]] = None, |
| 14 | options_prolog: Optional[str] = None, |
| 15 | options_epilog: Optional[str] = None, |
| 16 | ) -> None: ... |
| 17 | @property |
| 18 | def description(self) -> Optional[str]: ... |
| 19 | @property |
| 20 | def parser(self) -> argparse.ArgumentParser: ... |
| 21 | @parser.setter |
| 22 | def parser(self, parser: argparse.ArgumentParser) -> None: ... |
| 23 | @property |
| 24 | def args(self) -> argparse.Namespace: ... |
| 25 | @args.setter |
| 26 | def args(self, args: argparse.Namespace) -> None: ... |
| 27 | @property |
| 28 | def argument_help(self) -> Dict[str, Optional[str]]: ... |
| 29 | |
| 30 | class Application(DocumentableMixin): |
| 31 | def __init__( |
| 32 | self, |
| 33 | name: str, |
| 34 | version: str, |
| 35 | author: Optional[str] = None, |
| 36 | title: Optional[str] = None, |
| 37 | description: Optional[str] = None, |
| 38 | default_command: Optional[str] = None, |
| 39 | add_help: bool = True, |
| 40 | extra_sections: Optional[Dict[str, str]] = None, |
| 41 | prolog: Optional[str] = None, |
| 42 | epilog: Optional[str] = None, |
| 43 | options_prolog: Optional[str] = None, |
| 44 | options_epilog: Optional[str] = None, |
| 45 | add_commands_section: bool = False, |
| 46 | ) -> None: ... |
| 47 | @property |
| 48 | def name(self) -> str: ... |
| 49 | @property |
| 50 | def author(self) -> str: ... |
| 51 | @property |
| 52 | def version(self) -> str: ... |
| 53 | @property |
| 54 | def commands(self) -> List[Command]: ... |
| 55 | @property |
| 56 | def groups(self) -> List[Group]: ... |
| 57 | def add_argument(self, *args, **kwargs) -> argparse.Action: ... |
| 58 | def add(self, command: Command): ... |
| 59 | def add_group(self, title: str) -> Group: ... |
| 60 | def register(self): ... |
| 61 | def handle(self) -> int: ... |
| 62 | def run( |
| 63 | self, |
| 64 | args: Optional[List[str]] = None, |
| 65 | namespace: Optional[argparse.Namespace] = None, |
| 66 | exit_on_error: bool = True, |
| 67 | ) -> int: ... |
| 68 | def run_command(self, command: Command) -> int: ... |
| 69 | def get_command(self, command_name: str) -> Command: ... |
| 70 | def set_prolog(self, prolog: str) -> None: ... |
| 71 | def set_epilog(self, epilog: str) -> None: ... |
| 72 | def get_commands_text(self) -> str: ... |
| 73 | def create_manpage(self) -> ManPage: ... |
| 74 | def format_help(self) -> str: ... |
| 75 | def print_help(self, file: Optional[TextIO] = None) -> None: ... |
| 76 | |
| 77 | class Group: |
| 78 | def __init__( |
| 79 | self, title: Optional[str] = None, is_root: bool = False |
| 80 | ) -> None: ... |
| 81 | @property |
| 82 | def application(self) -> Optional[Application]: ... |
| 83 | @property |
| 84 | def title(self) -> Optional[str]: ... |
| 85 | @property |
| 86 | def commands(self) -> List[Command]: ... |
| 87 | @property |
| 88 | def is_root(self) -> bool: ... |
| 89 | def commands_as_actions(self) -> List[argparse.Action]: ... |
| 90 | def set_app(self, app: Application) -> None: ... |
| 91 | def add(self, command: Command) -> None: ... |
| 92 | def __len__(self) -> int: ... |
| 93 | |
| 94 | class Command(DocumentableMixin, metaclass=abc.ABCMeta): |
| 95 | def __init__( |
| 96 | self, |
| 97 | name: str, |
| 98 | title: Optional[str] = None, |
| 99 | description: Optional[str] = None, |
| 100 | add_help: bool = True, |
| 101 | extra_sections: Optional[Dict[str, str]] = None, |
| 102 | options_prolog: Optional[str] = None, |
| 103 | options_epilog: Optional[str] = None, |
| 104 | ) -> None: ... |
| 105 | @property |
| 106 | def application(self) -> Optional[Application]: ... |
| 107 | @property |
| 108 | def name(self) -> str: ... |
| 109 | @property |
| 110 | def title(self) -> Optional[str]: ... |
| 111 | def add_argument(self, *args, **kwargs) -> None: ... |
| 112 | def add_argument_group(self, *args, **kwargs) -> ArgumentGroup: ... |
| 113 | def add_mutually_exclusive_group( |
| 114 | self, *args, **kwargs |
| 115 | ) -> MutuallyExclusiveGroup: ... |
| 116 | def register(self) -> None: ... |
| 117 | @abc.abstractmethod |
| 118 | def handle(self) -> int: ... |
| 119 | def create_manpage(self) -> ManPage: ... |
| 120 | |
| 121 | class ManPage: |
| 122 | def __init__( |
| 123 | self, |
| 124 | application_name: str, |
| 125 | author: Optional[str] = "", |
| 126 | command_name: Optional[str] = None, |
| 127 | date: Optional[str] = None, |
| 128 | title: Optional[str] = None, |
| 129 | version: Optional[str] = "", |
| 130 | ) -> None: ... |
| 131 | @property |
| 132 | def name(self) -> str: ... |
| 133 | def metadata(self) -> List[str]: ... |
| 134 | def preamble(self) -> List[str]: ... |
| 135 | def header(self) -> str: ... |
| 136 | def section_name(self) -> str: ... |
| 137 | def add_section_synopsis(self, synopsis: str) -> None: ... |
| 138 | def add_section(self, label: str, text: str) -> None: ... |
| 139 | def groffify(self, text: str) -> str: ... |
| 140 | def groffify_line(self, line: str) -> str: ... |
| 141 | def export(self, output_dir: str) -> str: ... |
| 142 | |
| 143 | class ArgumentGroup: |
| 144 | def __init__(self, group: argparse._ArgumentGroup) -> None: ... |
| 145 | @property |
| 146 | def command(self) -> Optional[Command]: ... |
| 147 | @command.setter |
| 148 | def command(self, command: Command) -> None: ... |
| 149 | def add_argument(self, *args, **kwargs) -> None: ... |
| 150 | |
| 151 | class MutuallyExclusiveGroup: |
| 152 | def __init__(self, meg: argparse._MutuallyExclusiveGroup) -> None: ... |
| 153 | @property |
| 154 | def command(self) -> Optional[Command]: ... |
| 155 | @command.setter |
| 156 | def command(self, command: Command) -> None: ... |
| 157 | def add_argument(self, *args, **kwargs) -> None: ... |
| 158 | |
| 159 | class Tester: |
| 160 | def __init__(self, app: Application) -> None: ... |
| 161 | @property |
| 162 | def application(self) -> Application: ... |
| 163 | def clear(self) -> None: ... |
| 164 | def get_return_code(self) -> Optional[int]: ... |
| 165 | def get_stdout(self) -> Optional[str]: ... |
| 166 | def get_stderr(self) -> Optional[str]: ... |
| 167 | def test_command(self, cmd_name: str, args: List[str]) -> None: ... |
| 168 | def test_application(self, args: Optional[List[str]] = None) -> None: ... |