apply_stdin_pipe(
args: argparse.Namespace,
) ->Read piped stdin and merge it into the parsed CLI arguments.
When stdin is not a TTY (i.e. input is piped), reads all available text
and applies it to the argument namespace. If stdin is a TTY or the piped
input is empty/whitespace-only, the function returns without modifying
args. Leading and trailing whitespace is stripped from piped input.
non_interactive_message is already set (-n), prepends the
piped text to it (the CLI still runs non-interactively):cat context.txt | dcode -n "summarize this"
# non_interactive_message = "{contents of context.txt}\n\nsummarize this"
initial_prompt is already set (-m, but not -n), prepends
the piped text to it (the CLI still runs interactively):cat error.log | dcode -m "explain this"
# initial_prompt = "{contents of error.log}\n\nexplain this"
initial_skill is already set (--skill, but not -n/-m) and the
pipe was auto-detected (no explicit --stdin), stores the piped text in
initial_prompt so the skill receives it as the seed for the
interactive TUI:cat diff.txt | dcode --skill code-review
# initial_prompt = "{contents of diff.txt}"
When --stdin is passed explicitly, this convenience is skipped: the
piped text falls through to non_interactive_message so the skill runs
headless (see below):
cat diff.txt | dcode --skill code-review --stdin
# non_interactive_message = "{contents of diff.txt}"
non_interactive_message to the piped text, causing
the CLI to run non-interactively with it as the prompt:echo "fix the typo in README.md" | dcode
# non_interactive_message = "fix the typo in README.md"| Name | Type | Description |
|---|---|---|
args* | argparse.Namespace |
The parsed argument namespace (mutated in place).