zrb 0.18.1__py3-none-any.whl → 0.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrb/__init__.py +2 -0
- zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package-lock.json +33 -24
- zrb/config/config.py +1 -0
- zrb/helper/multilline.py +11 -0
- zrb/task_input/base_input.py +34 -4
- zrb/task_input/bool_input.py +8 -5
- zrb/task_input/choice_input.py +7 -4
- zrb/task_input/float_input.py +7 -4
- zrb/task_input/int_input.py +7 -4
- zrb/task_input/multiline_input.py +113 -0
- zrb/task_input/password_input.py +7 -4
- zrb/task_input/str_input.py +7 -4
- zrb/task_input/task_input.py +3 -2
- {zrb-0.18.1.dist-info → zrb-0.19.0.dist-info}/METADATA +1 -1
- {zrb-0.18.1.dist-info → zrb-0.19.0.dist-info}/RECORD +18 -16
- {zrb-0.18.1.dist-info → zrb-0.19.0.dist-info}/LICENSE +0 -0
- {zrb-0.18.1.dist-info → zrb-0.19.0.dist-info}/WHEEL +0 -0
- {zrb-0.18.1.dist-info → zrb-0.19.0.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -45,6 +45,7 @@ from zrb.task_input.bool_input import BoolInput
|
|
45
45
|
from zrb.task_input.choice_input import ChoiceInput
|
46
46
|
from zrb.task_input.float_input import FloatInput
|
47
47
|
from zrb.task_input.int_input import IntInput
|
48
|
+
from zrb.task_input.multiline_input import MultilineInput
|
48
49
|
from zrb.task_input.password_input import PasswordInput
|
49
50
|
from zrb.task_input.str_input import StrInput
|
50
51
|
from zrb.task_input.task_input import Input
|
@@ -93,6 +94,7 @@ assert BoolInput
|
|
93
94
|
assert ChoiceInput
|
94
95
|
assert FloatInput
|
95
96
|
assert IntInput
|
97
|
+
assert MultilineInput
|
96
98
|
assert PasswordInput
|
97
99
|
assert StrInput
|
98
100
|
assert Env
|
@@ -60,10 +60,13 @@
|
|
60
60
|
}
|
61
61
|
},
|
62
62
|
"node_modules/@types/node": {
|
63
|
-
"version": "20.
|
64
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.
|
65
|
-
"integrity": "sha512-
|
66
|
-
"dev": true
|
63
|
+
"version": "20.14.2",
|
64
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz",
|
65
|
+
"integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==",
|
66
|
+
"dev": true,
|
67
|
+
"dependencies": {
|
68
|
+
"undici-types": "~5.26.4"
|
69
|
+
}
|
67
70
|
},
|
68
71
|
"node_modules/balanced-match": {
|
69
72
|
"version": "1.0.2",
|
@@ -79,11 +82,11 @@
|
|
79
82
|
}
|
80
83
|
},
|
81
84
|
"node_modules/braces": {
|
82
|
-
"version": "3.0.
|
83
|
-
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.
|
84
|
-
"integrity": "sha512-
|
85
|
+
"version": "3.0.3",
|
86
|
+
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
87
|
+
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
85
88
|
"dependencies": {
|
86
|
-
"fill-range": "^7.
|
89
|
+
"fill-range": "^7.1.1"
|
87
90
|
},
|
88
91
|
"engines": {
|
89
92
|
"node": ">=8"
|
@@ -95,9 +98,9 @@
|
|
95
98
|
"integrity": "sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w=="
|
96
99
|
},
|
97
100
|
"node_modules/fast-glob": {
|
98
|
-
"version": "3.3.
|
99
|
-
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.
|
100
|
-
"integrity": "sha512-
|
101
|
+
"version": "3.3.2",
|
102
|
+
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
103
|
+
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
101
104
|
"dependencies": {
|
102
105
|
"@nodelib/fs.stat": "^2.0.2",
|
103
106
|
"@nodelib/fs.walk": "^1.2.3",
|
@@ -110,17 +113,17 @@
|
|
110
113
|
}
|
111
114
|
},
|
112
115
|
"node_modules/fastq": {
|
113
|
-
"version": "1.
|
114
|
-
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.
|
115
|
-
"integrity": "sha512-
|
116
|
+
"version": "1.17.1",
|
117
|
+
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
|
118
|
+
"integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
|
116
119
|
"dependencies": {
|
117
120
|
"reusify": "^1.0.4"
|
118
121
|
}
|
119
122
|
},
|
120
123
|
"node_modules/fill-range": {
|
121
|
-
"version": "7.
|
122
|
-
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.
|
123
|
-
"integrity": "sha512-
|
124
|
+
"version": "7.1.1",
|
125
|
+
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
126
|
+
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
124
127
|
"dependencies": {
|
125
128
|
"to-regex-range": "^5.0.1"
|
126
129
|
},
|
@@ -175,11 +178,11 @@
|
|
175
178
|
}
|
176
179
|
},
|
177
180
|
"node_modules/micromatch": {
|
178
|
-
"version": "4.0.
|
179
|
-
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.
|
180
|
-
"integrity": "sha512-
|
181
|
+
"version": "4.0.7",
|
182
|
+
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
|
183
|
+
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
|
181
184
|
"dependencies": {
|
182
|
-
"braces": "^3.0.
|
185
|
+
"braces": "^3.0.3",
|
183
186
|
"picomatch": "^2.3.1"
|
184
187
|
},
|
185
188
|
"engines": {
|
@@ -301,9 +304,9 @@
|
|
301
304
|
}
|
302
305
|
},
|
303
306
|
"node_modules/typescript": {
|
304
|
-
"version": "5.
|
305
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.
|
306
|
-
"integrity": "sha512-
|
307
|
+
"version": "5.4.5",
|
308
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
|
309
|
+
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
|
307
310
|
"dev": true,
|
308
311
|
"bin": {
|
309
312
|
"tsc": "bin/tsc",
|
@@ -312,6 +315,12 @@
|
|
312
315
|
"engines": {
|
313
316
|
"node": ">=14.17"
|
314
317
|
}
|
318
|
+
},
|
319
|
+
"node_modules/undici-types": {
|
320
|
+
"version": "5.26.5",
|
321
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
322
|
+
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
323
|
+
"dev": true
|
315
324
|
}
|
316
325
|
}
|
317
326
|
}
|
zrb/config/config.py
CHANGED
@@ -32,6 +32,7 @@ def _get_default_tmp_dir() -> str:
|
|
32
32
|
|
33
33
|
tmp_dir = os.getenv("ZRB_TMP_DIR", _get_default_tmp_dir())
|
34
34
|
default_shell = os.getenv("ZRB_SHELL", _get_current_shell())
|
35
|
+
default_editor = os.getenv("ZRB_EDITOR", "nano")
|
35
36
|
init_script_str = os.getenv("ZRB_INIT_SCRIPTS", "")
|
36
37
|
init_scripts = init_script_str.split(":") if init_script_str != "" else []
|
37
38
|
logging_level = untyped_to_logging_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
|
zrb/helper/multilline.py
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import click
|
2
|
+
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
5
|
+
|
6
|
+
@typechecked
|
7
|
+
def edit(editor: str, mark_comment: str, text: str) -> str:
|
8
|
+
result = click.edit(text="\n".join([mark_comment, text]), editor=editor)
|
9
|
+
if result is None:
|
10
|
+
result = text
|
11
|
+
return "\n".join(result.split(mark_comment)).strip()
|
zrb/task_input/base_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.config.config import show_prompt
|
|
2
2
|
from zrb.helper.accessories.color import colored
|
3
3
|
from zrb.helper.log import logger
|
4
4
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.typing import Any, List, Mapping, Optional, Union
|
5
|
+
from zrb.helper.typing import Any, Callable, List, Mapping, Optional, Union
|
6
6
|
from zrb.task_input.any_input import AnyInput
|
7
7
|
from zrb.task_input.constant import RESERVED_INPUT_NAMES
|
8
8
|
|
@@ -10,6 +10,9 @@ logger.debug(colored("Loading zrb.task_input.base_input", attrs=["dark"]))
|
|
10
10
|
|
11
11
|
# flake8: noqa E501
|
12
12
|
|
13
|
+
InputCallback = Callable[[Mapping[str, Any], Any], Any]
|
14
|
+
InputDefault = Callable[[Mapping[str, Any]], Any]
|
15
|
+
|
13
16
|
|
14
17
|
@typechecked
|
15
18
|
class BaseInput(AnyInput):
|
@@ -22,8 +25,9 @@ class BaseInput(AnyInput):
|
|
22
25
|
name (str): The name of the input, used as a unique identifier.
|
23
26
|
shortcut (Optional[str]): An optional single-character shortcut for the input.
|
24
27
|
default (Optional[Any]): The default value of the input.
|
28
|
+
callback (Optional[Any]): The default value of the input.
|
25
29
|
description (Optional[str]): A brief description of what the input is for.
|
26
|
-
show_default (Union[bool, JinjaTemplate, None]): Determines
|
30
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
27
31
|
prompt (Union[bool, str]): The prompt text to be displayed when asking for the input.
|
28
32
|
confirmation_prompt (Union[bool, str]): A prompt for confirmation if required.
|
29
33
|
prompt_required (bool): Indicates whether a prompt is required.
|
@@ -50,11 +54,15 @@ class BaseInput(AnyInput):
|
|
50
54
|
>>> )
|
51
55
|
"""
|
52
56
|
|
57
|
+
__input_value_map: Mapping[str, Any] = {}
|
58
|
+
__default: Mapping[str, Any] = {}
|
59
|
+
|
53
60
|
def __init__(
|
54
61
|
self,
|
55
62
|
name: str,
|
56
63
|
shortcut: Optional[str] = None,
|
57
|
-
default: Optional[Any] = None,
|
64
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
65
|
+
callback: Optional[InputCallback] = None,
|
58
66
|
description: Optional[str] = None,
|
59
67
|
show_default: Union[bool, str, None] = None,
|
60
68
|
prompt: Union[bool, str] = True,
|
@@ -79,6 +87,7 @@ class BaseInput(AnyInput):
|
|
79
87
|
self._shortcut = shortcut
|
80
88
|
self._prompt = prompt
|
81
89
|
self._default = default
|
90
|
+
self._callback = callback
|
82
91
|
self._help = description if description is not None else name
|
83
92
|
self._type = type
|
84
93
|
self._show_default = show_default
|
@@ -110,7 +119,6 @@ class BaseInput(AnyInput):
|
|
110
119
|
|
111
120
|
def get_options(self) -> Mapping[str, Any]:
|
112
121
|
options: Mapping[str, Any] = {
|
113
|
-
"default": self._default,
|
114
122
|
"help": self._help,
|
115
123
|
"type": self._type,
|
116
124
|
"show_default": self._show_default,
|
@@ -126,11 +134,33 @@ class BaseInput(AnyInput):
|
|
126
134
|
"show_choices": self._show_choices,
|
127
135
|
"show_envvar": self._show_envvar,
|
128
136
|
"nargs": self._nargs,
|
137
|
+
"callback": self._wrapped_callback,
|
138
|
+
"default": self._wrapped_default,
|
129
139
|
}
|
130
140
|
if show_prompt:
|
131
141
|
options["prompt"] = self._prompt
|
132
142
|
return options
|
133
143
|
|
144
|
+
def _wrapped_callback(self, ctx, param, value) -> Any:
|
145
|
+
if self.get_name() not in self.__input_value_map:
|
146
|
+
if callable(self._callback):
|
147
|
+
result = self._callback(self.__input_value_map, value)
|
148
|
+
self.__input_value_map[self.get_name()] = result
|
149
|
+
return result
|
150
|
+
self.__input_value_map[self.get_name()] = value
|
151
|
+
return value
|
152
|
+
return self.__input_value_map[self.get_name()]
|
153
|
+
|
154
|
+
def _wrapped_default(self) -> Any:
|
155
|
+
if self.get_name() not in self.__default:
|
156
|
+
if callable(self._default):
|
157
|
+
default = self._default(self.__input_value_map)
|
158
|
+
self.__default[self.get_name()] = default
|
159
|
+
return default
|
160
|
+
self.__default[self.get_name()] = self._default
|
161
|
+
return self._default
|
162
|
+
return self.__default[self.get_name()]
|
163
|
+
|
134
164
|
def should_render(self) -> bool:
|
135
165
|
return self.__should_render
|
136
166
|
|
zrb/task_input/bool_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.helper.accessories.color import colored
|
|
2
2
|
from zrb.helper.log import logger
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
4
|
from zrb.helper.typing import Any, Optional, Union
|
5
|
-
from zrb.task_input.base_input import BaseInput
|
5
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
6
6
|
|
7
7
|
logger.debug(colored("Loading zrb.task_input.bool_input", attrs=["dark"]))
|
8
8
|
|
@@ -20,9 +20,10 @@ class BoolInput(BaseInput):
|
|
20
20
|
Args:
|
21
21
|
name (str): The name of the input.
|
22
22
|
shortcut (Optional[str]): A shortcut string for the input.
|
23
|
-
default (Optional[Any]): The default value
|
24
|
-
|
25
|
-
|
23
|
+
default (Optional[Any]): The default value of the input.
|
24
|
+
callback (Optional[Any]): The default value of the input.
|
25
|
+
description (Optional[str]): A brief description of what the input is for.
|
26
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
26
27
|
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
27
28
|
confirmation_prompt (Union[bool, str]): If set to `True`, the user is asked to confirm the input.
|
28
29
|
prompt_required (bool): If `True`, the prompt for input is mandatory.
|
@@ -48,7 +49,8 @@ class BoolInput(BaseInput):
|
|
48
49
|
self,
|
49
50
|
name: str,
|
50
51
|
shortcut: Optional[str] = None,
|
51
|
-
default: Optional[Any] = None,
|
52
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
53
|
+
callback: Optional[InputCallback] = None,
|
52
54
|
description: Optional[str] = None,
|
53
55
|
show_default: Union[bool, str, None] = None,
|
54
56
|
prompt: Union[bool, str] = True,
|
@@ -71,6 +73,7 @@ class BoolInput(BaseInput):
|
|
71
73
|
name=name,
|
72
74
|
shortcut=shortcut,
|
73
75
|
default=default,
|
76
|
+
callback=callback,
|
74
77
|
description=description,
|
75
78
|
show_default=show_default,
|
76
79
|
prompt=prompt,
|
zrb/task_input/choice_input.py
CHANGED
@@ -4,7 +4,7 @@ from zrb.helper.accessories.color import colored
|
|
4
4
|
from zrb.helper.log import logger
|
5
5
|
from zrb.helper.typecheck import typechecked
|
6
6
|
from zrb.helper.typing import Any, Iterable, Optional, Union
|
7
|
-
from zrb.task_input.base_input import BaseInput
|
7
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
8
8
|
|
9
9
|
logger.debug(colored("Loading zrb.task_input.choice_input", attrs=["dark"]))
|
10
10
|
|
@@ -25,8 +25,9 @@ class ChoiceInput(BaseInput):
|
|
25
25
|
shortcut (Optional[str]): An optional shortcut string for the input.
|
26
26
|
choices (Iterable[Any]): An iterable of choices from which the user can select.
|
27
27
|
default (Optional[Any]): The default value for the input. Should be one of the choices if set.
|
28
|
-
|
29
|
-
|
28
|
+
callback (Optional[Any]): The default value of the input.
|
29
|
+
description (Optional[str]): A brief description of what the input is for.
|
30
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
30
31
|
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
31
32
|
confirmation_prompt (Union[bool, str]): If set to `True`, the user is asked to confirm the input.
|
32
33
|
prompt_required (bool): If `True`, the prompt for input is mandatory.
|
@@ -53,7 +54,8 @@ class ChoiceInput(BaseInput):
|
|
53
54
|
name: str,
|
54
55
|
shortcut: Optional[str] = None,
|
55
56
|
choices: Iterable[Any] = [],
|
56
|
-
default: Optional[Any] = None,
|
57
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
58
|
+
callback: Optional[InputCallback] = None,
|
57
59
|
description: Optional[str] = None,
|
58
60
|
show_default: Union[bool, str, None] = None,
|
59
61
|
prompt: Union[bool, str] = True,
|
@@ -76,6 +78,7 @@ class ChoiceInput(BaseInput):
|
|
76
78
|
name=name,
|
77
79
|
shortcut=shortcut,
|
78
80
|
default=default,
|
81
|
+
callback=callback,
|
79
82
|
description=description,
|
80
83
|
show_default=show_default,
|
81
84
|
prompt=prompt,
|
zrb/task_input/float_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.helper.accessories.color import colored
|
|
2
2
|
from zrb.helper.log import logger
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
4
|
from zrb.helper.typing import Any, Optional, Union
|
5
|
-
from zrb.task_input.base_input import BaseInput
|
5
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
6
6
|
|
7
7
|
logger.debug(colored("Loading zrb.task_input.float_input", attrs=["dark"]))
|
8
8
|
|
@@ -21,8 +21,9 @@ class FloatInput(BaseInput):
|
|
21
21
|
name (str): The name of the input.
|
22
22
|
shortcut (Optional[str]): An optional shortcut string for the input.
|
23
23
|
default (Optional[Any]): The default value for the input, expected to be a float if set.
|
24
|
-
|
25
|
-
|
24
|
+
callback (Optional[Any]): The default value of the input.
|
25
|
+
description (Optional[str]): A brief description of what the input is for.
|
26
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
26
27
|
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
27
28
|
confirmation_prompt (Union[bool, str]): If `True`, the user is asked to confirm the input.
|
28
29
|
prompt_required (bool): If `True`, the prompt for input is mandatory.
|
@@ -48,7 +49,8 @@ class FloatInput(BaseInput):
|
|
48
49
|
self,
|
49
50
|
name: str,
|
50
51
|
shortcut: Optional[str] = None,
|
51
|
-
default: Optional[Any] = None,
|
52
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
53
|
+
callback: Optional[InputCallback] = None,
|
52
54
|
description: Optional[str] = None,
|
53
55
|
show_default: Union[bool, str, None] = None,
|
54
56
|
prompt: Union[bool, str] = True,
|
@@ -71,6 +73,7 @@ class FloatInput(BaseInput):
|
|
71
73
|
name=name,
|
72
74
|
shortcut=shortcut,
|
73
75
|
default=default,
|
76
|
+
callback=callback,
|
74
77
|
description=description,
|
75
78
|
show_default=show_default,
|
76
79
|
prompt=prompt,
|
zrb/task_input/int_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.helper.accessories.color import colored
|
|
2
2
|
from zrb.helper.log import logger
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
4
|
from zrb.helper.typing import Any, Optional, Union
|
5
|
-
from zrb.task_input.base_input import BaseInput
|
5
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
6
6
|
|
7
7
|
logger.debug(colored("Loading zrb.task_input.int_input", attrs=["dark"]))
|
8
8
|
|
@@ -22,8 +22,9 @@ class IntInput(BaseInput):
|
|
22
22
|
name (str): The name of the input, serving as an identifier.
|
23
23
|
shortcut (Optional[str]): An optional shortcut for easier reference to the input.
|
24
24
|
default (Optional[Any]): The default value for the input, should be an integer if provided.
|
25
|
-
|
26
|
-
|
25
|
+
callback (Optional[Any]): The default value of the input.
|
26
|
+
description (Optional[str]): A brief description of what the input is for.
|
27
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
27
28
|
prompt (Union[bool, str]): A boolean or string to determine the prompt for user input. If `True`, uses a default prompt.
|
28
29
|
confirmation_prompt (Union[bool, str]): If `True`, the user will be asked to confirm their input.
|
29
30
|
prompt_required (bool): If `True`, makes the input prompt mandatory.
|
@@ -49,7 +50,8 @@ class IntInput(BaseInput):
|
|
49
50
|
self,
|
50
51
|
name: str,
|
51
52
|
shortcut: Optional[str] = None,
|
52
|
-
default: Optional[Any] = None,
|
53
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
54
|
+
callback: Optional[InputCallback] = None,
|
53
55
|
description: Optional[str] = None,
|
54
56
|
show_default: Union[bool, str, None] = None,
|
55
57
|
prompt: Union[bool, str] = True,
|
@@ -72,6 +74,7 @@ class IntInput(BaseInput):
|
|
72
74
|
name=name,
|
73
75
|
shortcut=shortcut,
|
74
76
|
default=default,
|
77
|
+
callback=callback,
|
75
78
|
description=description,
|
76
79
|
show_default=show_default,
|
77
80
|
prompt=prompt,
|
@@ -0,0 +1,113 @@
|
|
1
|
+
from zrb.config.config import default_editor
|
2
|
+
from zrb.helper.accessories.color import colored
|
3
|
+
from zrb.helper.log import logger
|
4
|
+
from zrb.helper.multilline import edit
|
5
|
+
from zrb.helper.typecheck import typechecked
|
6
|
+
from zrb.helper.typing import Any, Mapping, Optional, Union
|
7
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
8
|
+
|
9
|
+
logger.debug(colored("Loading zrb.task_input.multiline_input", attrs=["dark"]))
|
10
|
+
|
11
|
+
# flake8: noqa E501
|
12
|
+
|
13
|
+
|
14
|
+
@typechecked
|
15
|
+
class MultilineInput(BaseInput):
|
16
|
+
"""
|
17
|
+
A specialized input class for handling string-based inputs in various tasks.
|
18
|
+
|
19
|
+
`StrInput` extends `BaseInput` to manage string-type inputs, supporting features like
|
20
|
+
default values, prompts, flags, and other customization options. This class is useful
|
21
|
+
for tasks requiring textual input, such as names, descriptions, or any other string parameters.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
name (str): The name of the input, used as an identifier.
|
25
|
+
shortcut (Optional[str]): An optional shortcut string for the input.
|
26
|
+
default (Optional[Any]): The default value for the input, expected to be a string if set.
|
27
|
+
callback (Optional[Any]): The default value of the input.
|
28
|
+
description (Optional[str]): A brief description of what the input is for.
|
29
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
30
|
+
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
31
|
+
confirmation_prompt (Union[bool, str]): If `True`, the user is asked to confirm the input.
|
32
|
+
prompt_required (bool): If `True’, the prompt for input is mandatory.
|
33
|
+
hide_input (bool): If `True’, hides the input value, typically used for sensitive data.
|
34
|
+
is_flag (Optional[bool]): Indicates if the input is a flag. If `True’, the input accepts boolean flag values.
|
35
|
+
flag_value (Optional[Any]): The value associated with the flag if `is_flag` is `True`.
|
36
|
+
multiple (bool): If `True’, allows multiple string values for the input.
|
37
|
+
count (bool): If `True’, counts the occurrences of the input.
|
38
|
+
allow_from_autoenv (bool): If `True’, enables automatic population of the input from environment variables.
|
39
|
+
hidden (bool): If `True’, keeps the input hidden in help messages or documentation.
|
40
|
+
show_choices (bool): If `True’, shows any restricted choices for the input value.
|
41
|
+
show_envvar (bool): If `True’, displays the associated environment variable, if applicable.
|
42
|
+
nargs (int): The number of arguments that the input can accept.
|
43
|
+
should_render (bool): If `True’, renders the input in the user interface or command-line interface.
|
44
|
+
|
45
|
+
Examples:
|
46
|
+
>>> multiline_input = StrInput(name='username', default='user123', description='Enter your username')
|
47
|
+
>>> multiline_input.get_default()
|
48
|
+
'user123'
|
49
|
+
"""
|
50
|
+
|
51
|
+
__default: Mapping[str, Any] = {}
|
52
|
+
|
53
|
+
def __init__(
|
54
|
+
self,
|
55
|
+
name: str,
|
56
|
+
shortcut: Optional[str] = None,
|
57
|
+
comment_start="#",
|
58
|
+
editor=default_editor,
|
59
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
60
|
+
callback: Optional[InputCallback] = None,
|
61
|
+
description: Optional[str] = None,
|
62
|
+
show_default: Union[bool, str, None] = None,
|
63
|
+
prompt: Union[bool, str] = True,
|
64
|
+
confirmation_prompt: Union[bool, str] = False,
|
65
|
+
prompt_required: bool = True,
|
66
|
+
hide_input: bool = False,
|
67
|
+
is_flag: Optional[bool] = None,
|
68
|
+
flag_value: Optional[Any] = None,
|
69
|
+
multiple: bool = False,
|
70
|
+
count: bool = False,
|
71
|
+
allow_from_autoenv: bool = True,
|
72
|
+
hidden: bool = False,
|
73
|
+
show_choices: bool = True,
|
74
|
+
show_envvar: bool = False,
|
75
|
+
nargs: int = 1,
|
76
|
+
should_render: bool = True,
|
77
|
+
):
|
78
|
+
BaseInput.__init__(
|
79
|
+
self,
|
80
|
+
name=name,
|
81
|
+
shortcut=shortcut,
|
82
|
+
default=default,
|
83
|
+
callback=callback,
|
84
|
+
description=description,
|
85
|
+
show_default=show_default,
|
86
|
+
prompt=prompt,
|
87
|
+
confirmation_prompt=confirmation_prompt,
|
88
|
+
prompt_required=prompt_required,
|
89
|
+
hide_input=hide_input,
|
90
|
+
is_flag=is_flag,
|
91
|
+
flag_value=flag_value,
|
92
|
+
multiple=multiple,
|
93
|
+
count=count,
|
94
|
+
allow_from_autoenv=allow_from_autoenv,
|
95
|
+
type=str,
|
96
|
+
hidden=hidden,
|
97
|
+
show_choices=show_choices,
|
98
|
+
show_envvar=show_envvar,
|
99
|
+
nargs=nargs,
|
100
|
+
should_render=should_render,
|
101
|
+
)
|
102
|
+
self._comment_start = comment_start
|
103
|
+
self._editor = editor
|
104
|
+
|
105
|
+
def _wrapped_default(self) -> Any:
|
106
|
+
if self.get_name() not in self.__default:
|
107
|
+
text = super()._wrapped_default()
|
108
|
+
prompt = self._prompt if isinstance(self._prompt, str) else self.get_name()
|
109
|
+
mark_comment = " ".join([self._comment_start, prompt])
|
110
|
+
self.__default[self.get_name()] = edit(
|
111
|
+
editor=self._editor, mark_comment=mark_comment, text=text
|
112
|
+
)
|
113
|
+
return self.__default[self.get_name()]
|
zrb/task_input/password_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.helper.accessories.color import colored
|
|
2
2
|
from zrb.helper.log import logger
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
4
|
from zrb.helper.typing import Any, Optional, Union
|
5
|
-
from zrb.task_input.base_input import BaseInput
|
5
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
6
6
|
|
7
7
|
logger.debug(colored("Loading zrb.task_input.password_input", attrs=["dark"]))
|
8
8
|
|
@@ -23,8 +23,9 @@ class PasswordInput(BaseInput):
|
|
23
23
|
name (str): The name of the input, serving as an identifier.
|
24
24
|
shortcut (Optional[str]): An optional shortcut string for the input.
|
25
25
|
default (Optional[Any]): The default value for the input, expected to be a string if set.
|
26
|
-
|
27
|
-
|
26
|
+
callback (Optional[Any]): The default value of the input.
|
27
|
+
description (Optional[str]): A brief description of what the input is for.
|
28
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
28
29
|
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
29
30
|
confirmation_prompt (Union[bool, str]): If `True`, the user is asked to confirm the input.
|
30
31
|
prompt_required (bool): If `True`, the prompt for input is mandatory.
|
@@ -49,7 +50,8 @@ class PasswordInput(BaseInput):
|
|
49
50
|
self,
|
50
51
|
name: str,
|
51
52
|
shortcut: Optional[str] = None,
|
52
|
-
default: Optional[Any] = None,
|
53
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
54
|
+
callback: Optional[InputCallback] = None,
|
53
55
|
description: Optional[str] = None,
|
54
56
|
show_default: Union[bool, str, None] = None,
|
55
57
|
prompt: Union[bool, str] = True,
|
@@ -71,6 +73,7 @@ class PasswordInput(BaseInput):
|
|
71
73
|
name=name,
|
72
74
|
shortcut=shortcut,
|
73
75
|
default=default,
|
76
|
+
callback=callback,
|
74
77
|
description=description,
|
75
78
|
show_default=show_default,
|
76
79
|
prompt=prompt,
|
zrb/task_input/str_input.py
CHANGED
@@ -2,7 +2,7 @@ from zrb.helper.accessories.color import colored
|
|
2
2
|
from zrb.helper.log import logger
|
3
3
|
from zrb.helper.typecheck import typechecked
|
4
4
|
from zrb.helper.typing import Any, Optional, Union
|
5
|
-
from zrb.task_input.base_input import BaseInput
|
5
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
6
6
|
|
7
7
|
logger.debug(colored("Loading zrb.task_input.str_input", attrs=["dark"]))
|
8
8
|
|
@@ -22,8 +22,9 @@ class StrInput(BaseInput):
|
|
22
22
|
name (str): The name of the input, used as an identifier.
|
23
23
|
shortcut (Optional[str]): An optional shortcut string for the input.
|
24
24
|
default (Optional[Any]): The default value for the input, expected to be a string if set.
|
25
|
-
|
26
|
-
|
25
|
+
callback (Optional[Any]): The default value of the input.
|
26
|
+
description (Optional[str]): A brief description of what the input is for.
|
27
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
27
28
|
prompt (Union[bool, str]): A boolean or string to prompt the user for input. If `True`, uses the default prompt.
|
28
29
|
confirmation_prompt (Union[bool, str]): If `True`, the user is asked to confirm the input.
|
29
30
|
prompt_required (bool): If `True’, the prompt for input is mandatory.
|
@@ -49,7 +50,8 @@ class StrInput(BaseInput):
|
|
49
50
|
self,
|
50
51
|
name: str,
|
51
52
|
shortcut: Optional[str] = None,
|
52
|
-
default: Optional[Any] = None,
|
53
|
+
default: Optional[Union[Any, InputDefault]] = None,
|
54
|
+
callback: Optional[InputCallback] = None,
|
53
55
|
description: Optional[str] = None,
|
54
56
|
show_default: Union[bool, str, None] = None,
|
55
57
|
prompt: Union[bool, str] = True,
|
@@ -72,6 +74,7 @@ class StrInput(BaseInput):
|
|
72
74
|
name=name,
|
73
75
|
shortcut=shortcut,
|
74
76
|
default=default,
|
77
|
+
callback=callback,
|
75
78
|
description=description,
|
76
79
|
show_default=show_default,
|
77
80
|
prompt=prompt,
|
zrb/task_input/task_input.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from zrb.helper.accessories.color import colored
|
2
2
|
from zrb.helper.log import logger
|
3
|
-
from zrb.task_input.base_input import BaseInput
|
3
|
+
from zrb.task_input.base_input import BaseInput, InputCallback, InputDefault
|
4
4
|
|
5
5
|
logger.debug(colored("Loading zrb.task_input.task_input", attrs=["dark"]))
|
6
6
|
|
@@ -15,8 +15,9 @@ class Input(BaseInput):
|
|
15
15
|
name (str): The name of the input, used as a unique identifier.
|
16
16
|
shortcut (Optional[str]): An optional single-character shortcut for the input.
|
17
17
|
default (Optional[Any]): The default value of the input.
|
18
|
+
callback (Optional[Any]): The default value of the input.
|
18
19
|
description (Optional[str]): A brief description of what the input is for.
|
19
|
-
show_default (Union[bool, JinjaTemplate, None]): Determines
|
20
|
+
show_default (Union[bool, JinjaTemplate, None]): Determines the default value to be shown.
|
20
21
|
prompt (Union[bool, str]): The prompt text to be displayed when asking for the input.
|
21
22
|
confirmation_prompt (Union[bool, str]): A prompt for confirmation if required.
|
22
23
|
prompt_required (bool): Indicates whether a prompt is required.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
zrb/__init__.py,sha256=
|
1
|
+
zrb/__init__.py,sha256=JHeTmm8QkMcg1FhI4eEL4jOGqF1sJ774eR-m8_0KtP8,2894
|
2
2
|
zrb/__main__.py,sha256=-_k0XOahDF-06n41Uly-oUMkZ8XDSxO-WUUImWz6GiA,171
|
3
3
|
zrb/action/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
zrb/action/runner.py,sha256=oizUiLa4wa4CjXppbw_YUFlkAUSwapfoQ1YAo9TEY30,5079
|
@@ -1157,7 +1157,7 @@ zrb/builtin/project/add/fastapp/crud/_input.py,sha256=LL9qR92qoMS_Tw_rdUTbYmNzHn
|
|
1157
1157
|
zrb/builtin/project/add/fastapp/crud/_task_factory.py,sha256=xfH5C0KkuhJvilrIzNBJ6LvrcG71lhM3N7ZPm6CW8Js,1481
|
1158
1158
|
zrb/builtin/project/add/fastapp/crud/crud.py,sha256=w1XeYB4RyMeieYVxA8nJ2oWb0nzNOOK6rL8MU-VdVCQ,5184
|
1159
1159
|
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/.gitignore,sha256=FtMORGIYn7FN1hG9twjFEGMMV2ofNbk4PomkNS2jbJc,13
|
1160
|
-
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package-lock.json,sha256=
|
1160
|
+
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package-lock.json,sha256=yWd9ww6RHHhAZBi5V01sbSKF6D8owxHoR1ebHGHs-2A,11620
|
1161
1161
|
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package.json,sha256=uqz8LlyK32NyMkH2rYAgZYi29pymj_zN5j46YiTDJ2w,369
|
1162
1162
|
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/src/addNav.ts,sha256=LeiRM_woR2rA6Se9zuZgBuo0WgtEFyYqHXQRufltEQ4,1460
|
1163
1163
|
zrb/builtin/project/add/fastapp/crud/nodejs/codemod/src/fastapp/src/frontend/src/lib/config/navData.ts,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -1294,7 +1294,7 @@ zrb/builtin/update.py,sha256=89i_fPUlL27IXczLI7Lr7k4STMpnxyw2je8daCKUTQo,225
|
|
1294
1294
|
zrb/builtin/version.py,sha256=vjbmSeOSEjT0SgdeQHGslwFCQMukwVZkOOkusZGZNcU,394
|
1295
1295
|
zrb/builtin/watch_changes.py,sha256=Vr__e_T31nnbefcPftvyn78dT3-UXqNRpH0KO-COeKQ,1220
|
1296
1296
|
zrb/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1297
|
-
zrb/config/config.py,sha256=
|
1297
|
+
zrb/config/config.py,sha256=pba-BbPFjfeH-U_cZyi3L8lElf1nyCFTYbKAzFJrWaQ,1616
|
1298
1298
|
zrb/helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1299
1299
|
zrb/helper/accessories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1300
1300
|
zrb/helper/accessories/color.py,sha256=E5OxlSOaN9skojG4gpD9tlBYyHDFC-YhLi_DoPCBbcg,948
|
@@ -1332,6 +1332,7 @@ zrb/helper/loader/load_module.py,sha256=qLYFTBKnrxlmgEA_-uepAM16LwpIx3XyfvXSIvJE
|
|
1332
1332
|
zrb/helper/log.py,sha256=lQBWNWc5UUz4BOzixWOMWjldcCRgycn1Pnn2nTJ7hlg,544
|
1333
1333
|
zrb/helper/map/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1334
1334
|
zrb/helper/map/conversion.py,sha256=I4VTrtv5c9OpfQ2lc7icxCgduWB46_qBtOh1RdjaPq0,603
|
1335
|
+
zrb/helper/multilline.py,sha256=hVbl1eqItrB211j-A9MROltC5tVm8ORttQ1rTlZghBA,313
|
1335
1336
|
zrb/helper/python_task.py,sha256=8FSMK5wHkNQUILUkDa-wNjfTYfQYFbItdKDPL35gRZ0,625
|
1336
1337
|
zrb/helper/render_data.py,sha256=sWQIQtdP61RDOoSh2_0ZJkKzDRmEsDLN18ADlhNWoAo,835
|
1337
1338
|
zrb/helper/string/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -1394,17 +1395,18 @@ zrb/task_group/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1394
1395
|
zrb/task_group/group.py,sha256=uF3tyLABTyyBNyE9FUCfJeYSDnaLFQCis3tuEn5FYho,6109
|
1395
1396
|
zrb/task_input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1396
1397
|
zrb/task_input/any_input.py,sha256=-uOq1ONXdhW20FRkC3pzqX081tbfmWjvCc_-d-gCNGY,2087
|
1397
|
-
zrb/task_input/base_input.py,sha256=
|
1398
|
-
zrb/task_input/bool_input.py,sha256=
|
1399
|
-
zrb/task_input/choice_input.py,sha256=
|
1398
|
+
zrb/task_input/base_input.py,sha256=STWgAY4lE8JSIavXsYPlNbGuz_5TVvZiicdCJOZIgeQ,6796
|
1399
|
+
zrb/task_input/bool_input.py,sha256=8InE55L9ht06q8SBOqdS5Miga59GNidebTCXLXBX8lQ,4192
|
1400
|
+
zrb/task_input/choice_input.py,sha256=sIu5cT27MpMufVhmV1Qs2WX9V5aml_ymcPb1NItf04Y,4471
|
1400
1401
|
zrb/task_input/constant.py,sha256=VEsnrI0BDdCJ1Z58EJgxXUhZBe5CA8TfURo0cNu5CaQ,200
|
1401
|
-
zrb/task_input/float_input.py,sha256=
|
1402
|
-
zrb/task_input/int_input.py,sha256
|
1403
|
-
zrb/task_input/
|
1404
|
-
zrb/task_input/
|
1405
|
-
zrb/task_input/
|
1406
|
-
zrb
|
1407
|
-
zrb-0.
|
1408
|
-
zrb-0.
|
1409
|
-
zrb-0.
|
1410
|
-
zrb-0.
|
1402
|
+
zrb/task_input/float_input.py,sha256=Y_pLd0oj1k5FjFqQuTNEIuupGpxzSQfwLfnFD12lvto,4308
|
1403
|
+
zrb/task_input/int_input.py,sha256=-4GFaTV2E-p_FMGqXWYmXmTeymqGYPd4gMvHAmEQSR8,4361
|
1404
|
+
zrb/task_input/multiline_input.py,sha256=5EWKdOBmzi8IiVFSBJ9owuShb-UL1IFCwTvmMu1UvcY,5152
|
1405
|
+
zrb/task_input/password_input.py,sha256=MPNXcrC5A1Qf-QIZ2LIBakdosaHFQ-DpjgkrA0SvCs0,4378
|
1406
|
+
zrb/task_input/str_input.py,sha256=AzbVbuEebGeQcIrE9lMmJLOVwADmLcngx6cK_GXpo5I,4386
|
1407
|
+
zrb/task_input/task_input.py,sha256=WTj_qIQyRs-04-VotjNTcVyIuf6b2afInVoCQHoRmr0,2327
|
1408
|
+
zrb-0.19.0.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
|
1409
|
+
zrb-0.19.0.dist-info/METADATA,sha256=ISpBH4PJyfyGdbQqKVPVIJSW84k15VMrepAGQy1DWXE,17076
|
1410
|
+
zrb-0.19.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
1411
|
+
zrb-0.19.0.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
|
1412
|
+
zrb-0.19.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|