writing-user-outputs

Solid

CLI output formatting standards for worktrunk. Load before editing any code that calls warning_message, hint_message, error_message, info_message, eprintln, or println, or that produces strings the user will see (CLI help, progress UI, snapshot text). Documents ANSI color nesting rules, message patterns, and output system architecture.

Code & Development 5,433 stars 184 forks Updated today NOASSERTION

Install

View on GitHub

Quality Score: 86/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Output System Architecture ## Shell Integration Worktrunk uses split file-based directive passing for shell integration: 1. Shell wrapper creates two temp files via `mktemp` (cd and exec) 2. Shell wrapper sets `WORKTRUNK_DIRECTIVE_CD_FILE` and `WORKTRUNK_DIRECTIVE_EXEC_FILE` 3. wt writes a raw path to the CD file; shell commands to the EXEC file (for `--execute`) 4. Shell wrapper reads the CD file with `cd -- "$(< file)"` (no shell parsing) 5. Shell wrapper sources the EXEC file if non-empty When neither directive env var is set (direct binary call), commands execute directly and shell integration hints are shown. ## Output Functions The output system handles shell integration automatically. Just call output functions — they do the right thing regardless of whether shell integration is active. ```rust // NEVER DO THIS - don't check mode in command code if is_shell_integration_active() { // different behavior } // ALWAYS DO THIS - just call output functions eprintln!("{}", success_message("Created worktree")); output::change_directory(&path)?; // Writes to directive file if set, else no-op ``` **Printing output:** Use `eprintln!` and `println!` from `worktrunk::styling` (re-exported from `anstream` for automatic color support and TTY detection): ```rust use worktrunk::styling::{eprintln, println, stderr}; // Status messages to stderr eprintln!("{}", success_message("Created worktree")); // Primary output to stdout (tables, JSON, pipeable) println!("{}", tab...

Details

Author
max-sixty
Repository
max-sixty/worktrunk
Created
7 months ago
Last Updated
today
Language
Rust
License
NOASSERTION

Similar Skills

Semantically similar based on skill content — not just same category