Source code for jgdv.cli.param_spec.defaults

 1#!/usr/bin/env python3
 2"""
 3
 4"""
 5
 6# Imports:
 7from __future__ import annotations
 8
 9# ##-- stdlib imports
10import builtins
11import datetime
12import enum
13import functools as ftz
14import importlib
15import itertools as itz
16import logging as logmod
17import pathlib as pl
18import re
19import time
20import types
21import typing
22import weakref
23from uuid import UUID, uuid1
24
25# ##-- end stdlib imports
26
27# ##-- 1st party imports
28from jgdv.mixins.annotate.annotate import SubAnnotate_m
29from jgdv.structs.chainguard import ChainGuard
30
31# ##-- end 1st party imports
32
33from jgdv.cli.errors import ArgParseError
34from .param_spec import ParamSpec
35from .core import ToggleParam
36from .extra import RepeatToggleParam, LiteralParam
37from .._interface import ParamSpec_p
38
39# ##-- types
40# isort: off
41import abc
42import collections.abc
43from typing import TYPE_CHECKING, cast, assert_type, assert_never
44from typing import Generic, NewType, Any
45# Protocols:
46from typing import Protocol, runtime_checkable
47# Typing Decorators:
48from typing import no_type_check, final, override, overload
49
50if TYPE_CHECKING:
51    from jgdv import Maybe
52    from typing import Final
53    from typing import ClassVar, Any, LiteralString
54    from typing import Never, Self, Literal
55    from typing import TypeGuard
56    from collections.abc import Iterable, Iterator, Callable, Generator
57    from collections.abc import Sequence, Mapping, MutableMapping, Hashable
58
59##--|
60# isort: on
61# ##-- end types
62##-- logging
63logging = logmod.getLogger(__name__)
64##-- end logging
65
66
[docs] 67class HelpParam(ToggleParam): #[bool]): 68 """ The --help flag that is always available """ 69 70 desc : str = "The Default Help Param" 71 72 def __init__(self, **kwargs:Any) -> None: # noqa: ANN401 73 kwargs.update({"name":"--help", "default":False, "implicit":True}) 74 super().__init__(**kwargs)
75
[docs] 76class VerboseParam(RepeatToggleParam): #[int]): 77 """ The implicit -verbose flag """ 78 79 desc : str = "The Default Verbosity Param" 80 81 def __init__(self, **kwargs:Any) -> None: # noqa: ANN401 82 kwargs.update({"name":"--verbose", "default":0, "implicit":True}) 83 super().__init__(**kwargs)
84
[docs] 85class SeparatorParam(LiteralParam): 86 """ A Parameter to separate subcmds """ 87 88 desc : str = "The Default Separator Param" 89 90 def __init__(self, **kwargs:Any) -> None: # noqa: ANN401 91 kwargs.update({"name":"--", "implicit":True}) 92 super().__init__(**kwargs)