powercli 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {powercli-0.2.0/src/powercli.egg-info → powercli-0.3.0}/PKG-INFO +1 -1
- {powercli-0.2.0 → powercli-0.3.0}/pyproject.toml +1 -1
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/__init__.py +1 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/__init__.py +1 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/open_.py +2 -1
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/runner.py +9 -7
- {powercli-0.2.0 → powercli-0.3.0/src/powercli.egg-info}/PKG-INFO +1 -1
- {powercli-0.2.0 → powercli-0.3.0}/tests/test_runner.py +7 -0
- {powercli-0.2.0 → powercli-0.3.0}/LICENSE +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/README.md +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/setup.cfg +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/cli/__init__.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/cli/entry_point.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/commands.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/install.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/commands/run.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/input.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/models/__init__.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/models/models.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/__init__.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/console.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/message.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/progress.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/rich.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/output/status.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/cli/py.typed +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/powercli.egg-info/SOURCES.txt +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/powercli.egg-info/dependency_links.txt +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/powercli.egg-info/entry_points.txt +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/powercli.egg-info/requires.txt +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/src/powercli.egg-info/top_level.txt +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/tests/test_cli_entry_point.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/tests/test_message.py +0 -0
- {powercli-0.2.0 → powercli-0.3.0}/tests/test_progress.py +0 -0
|
@@ -5,7 +5,6 @@ import typing
|
|
|
5
5
|
from collections.abc import Callable
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from functools import cached_property
|
|
8
|
-
from pathlib import Path
|
|
9
8
|
from typing import Any, Generic, TypeVar
|
|
10
9
|
|
|
11
10
|
from ..models import CalledProcessError
|
|
@@ -30,14 +29,17 @@ class Runner(Generic[T1]):
|
|
|
30
29
|
input: str | None = None
|
|
31
30
|
stdout: int | None = None
|
|
32
31
|
stderr: int | None = None
|
|
33
|
-
cwd: Path | str | None = None
|
|
34
32
|
|
|
35
33
|
verbose_errors: bool = True
|
|
36
34
|
kwargs: dict[str, Any] = field(default_factory=dict)
|
|
35
|
+
subprocess_kwargs: dict[str, Any] = field(default_factory=dict)
|
|
37
36
|
|
|
38
37
|
def __post_init__(self) -> None:
|
|
39
|
-
for
|
|
40
|
-
self
|
|
38
|
+
for name, value in self.kwargs.items():
|
|
39
|
+
if hasattr(self, name):
|
|
40
|
+
self.__setattr__(name, value)
|
|
41
|
+
else:
|
|
42
|
+
self.subprocess_kwargs[name] = value
|
|
41
43
|
|
|
42
44
|
@cached_property
|
|
43
45
|
def command_parts(self) -> tuple[str, ...]:
|
|
@@ -77,7 +79,7 @@ class Runner(Generic[T1]):
|
|
|
77
79
|
self, capture_output: bool | None = None
|
|
78
80
|
) -> subprocess.CompletedProcess[T1]:
|
|
79
81
|
if capture_output is None:
|
|
80
|
-
capture_output =
|
|
82
|
+
capture_output = self.quiet
|
|
81
83
|
return self.run_with_exception_handling(self._run, capture_output)
|
|
82
84
|
|
|
83
85
|
def _run(self, capture_output: bool) -> subprocess.CompletedProcess[T1]:
|
|
@@ -90,7 +92,7 @@ class Runner(Generic[T1]):
|
|
|
90
92
|
input=self.input,
|
|
91
93
|
stdout=self.stdout,
|
|
92
94
|
stderr=self.stderr,
|
|
93
|
-
|
|
95
|
+
**self.subprocess_kwargs,
|
|
94
96
|
)
|
|
95
97
|
|
|
96
98
|
def run_in_console(self) -> subprocess.Popen[str]:
|
|
@@ -111,7 +113,7 @@ class Runner(Generic[T1]):
|
|
|
111
113
|
shell=self.shell,
|
|
112
114
|
stdout=self.stdout,
|
|
113
115
|
stderr=self.stderr,
|
|
114
|
-
|
|
116
|
+
**self.subprocess_kwargs,
|
|
115
117
|
)
|
|
116
118
|
|
|
117
119
|
def run_with_exception_handling(
|
|
@@ -73,3 +73,10 @@ def test_cwd() -> None:
|
|
|
73
73
|
with Path.tempdir() as folder:
|
|
74
74
|
extracted_folder_name = cli.capture_output("pwd", cwd=folder).split("/")[-1]
|
|
75
75
|
assert extracted_folder_name == folder.name
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@given(value=text_strategy())
|
|
79
|
+
@linux_only_test
|
|
80
|
+
def test_extra_subprocess_kwarg(value: str) -> None:
|
|
81
|
+
env = {"name": value}
|
|
82
|
+
assert cli.capture_output("echo", "$name", shell=True, env=env) == value
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|