Skip to content

Commit 6cb0b69

Browse files
program247365claude
andcommitted
feat(cli): document exit codes and pipe examples in --help
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4a25121 commit 6cb0b69

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/cli.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ use crate::types::{Section, Story};
77
#[command(
88
name = "hackertuah",
99
version,
10-
about = "Hacker News in your terminal — TUI by default, agent-friendly subcommands for scripts"
10+
about = "Hacker News in your terminal — TUI by default, agent-friendly subcommands for scripts",
11+
after_help = "Exit codes:
12+
0 success
13+
1 network/runtime failure
14+
2 usage error (also returned when the TUI is invoked with piped stdout)
15+
16+
Subcommands write data to stdout and progress/errors to stderr.
17+
18+
Examples:
19+
hackertuah stories --limit 10 --json | jq -r '.[].title'
20+
hackertuah stories ask --json"
1121
)]
1222
pub struct Cli {
1323
#[command(subcommand)]
@@ -155,6 +165,15 @@ mod tests {
155165
assert_eq!(Section::from(CliSection::Jobs).as_str(), "Jobs");
156166
}
157167

168+
#[test]
169+
fn help_documents_exit_codes_and_examples() {
170+
use clap::CommandFactory;
171+
let help = Cli::command().render_long_help().to_string();
172+
assert!(help.contains("Exit codes:"));
173+
assert!(help.contains("Examples:"));
174+
assert!(help.contains("--json | jq"));
175+
}
176+
158177
fn sample_story() -> Story {
159178
Story {
160179
id: 42,

0 commit comments

Comments
 (0)