MCPcopy Create free account
hub / github.com/ElementsProject/elements / shell

Function shell

contrib/review-prs.py:56–70  ·  view source on GitHub ↗

Run a shell command, capturing the lines of stdout. The command WILL be parsed in a shell-like fashion. Be careful with quoting when interpolating variables into it. Use shlex.quote() if necessary. suppress_stderr: if False (default), stderr will be sent to the terminal. check_returnco

(cmd: str, suppress_stderr=False, check_returncode=True)

Source from the content-addressed store, hash-verified

54 return result[0]
55
56def shell(cmd: str, suppress_stderr=False, check_returncode=True) -> List[str]:
57 """Run a shell command, capturing the lines of stdout.
58
59 The command WILL be parsed in a shell-like fashion. Be careful with quoting when interpolating variables into it. Use shlex.quote() if necessary.
60
61 suppress_stderr: if False (default), stderr will be sent to the terminal.
62 check_returncode: if True (default), throw an exception if the return code is nonzero."""
63
64 handle_stderr = subprocess.PIPE if suppress_stderr else None
65
66 # If check is True, a CalledProcessError will be raised on nonzero exit code.
67 if ECHO_COMMANDS:
68 print(f" > {cmd}")
69 result = subprocess.run(["sh", "-c", cmd], stdout=subprocess.PIPE, stderr=handle_stderr, check=check_returncode)
70 return result.stdout.decode("utf-8").rstrip().split("\n")
71
72def prompt_chars(prompt: str, chars: str) -> str:
73 """Prompt the user with a multiple-choice question."""

Callers 7

shell_onelineFunction · 0.85
get_bitcoin_commitsFunction · 0.85
get_elements_commitsFunction · 0.85
get_merged_commitsFunction · 0.85
check_commitFunction · 0.85
check_or_create_worktreeFunction · 0.85
mainFunction · 0.85

Calls 2

runMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected