Skip to content

Commit 331cb54

Browse files
authored
Show executed commands when --verbose is on. (#38)
stack-info: PR: #38, branch: ZolotukhinM/stack/3
1 parent 5220b76 commit 331cb54

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/stack_pr/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
get_gh_username,
6363
get_uncommitted_changes,
6464
)
65-
from stack_pr.shell_commands import get_command_output, run_shell_command
65+
from stack_pr.shell_commands import (
66+
get_command_output,
67+
run_shell_command,
68+
set_show_commands,
69+
)
6670
from typing import List, NamedTuple, Optional, Pattern
6771

6872
# A bunch of regexps for parsing commit messages and PR descriptions
@@ -1380,6 +1384,10 @@ def main():
13801384

13811385
common_args = CommonArgs.from_args(args)
13821386

1387+
if common_args.verbose:
1388+
# Output shell commands that we run if verbose=True
1389+
set_show_commands(True)
1390+
13831391
check_gh_installed()
13841392

13851393
current_branch = get_current_branch_name()

src/stack_pr/shell_commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
ShellCommand = Iterable[Union[str, Path]]
66

7+
SHOW_COMMANDS = False
8+
9+
10+
def set_show_commands(val: bool):
11+
global SHOW_COMMANDS
12+
SHOW_COMMANDS = val
13+
714

815
def run_shell_command(
916
cmd: ShellCommand, *, quiet: bool, check: bool = True, **kwargs: Any
@@ -30,6 +37,8 @@ def run_shell_command(
3037
kwargs.update(
3138
{"stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
3239
)
40+
if SHOW_COMMANDS:
41+
print(f"Running: {cmd}")
3342
return subprocess.run(list(map(str, cmd)), **kwargs)
3443

3544

0 commit comments

Comments
 (0)