Add non-interactive CLI support and pre-commit hooks#109
Closed
Add non-interactive CLI support and pre-commit hooks#109
Conversation
Pre-commit hooks: - Add scripts/pre-commit hook (cargo fmt --check + clippy) - Add make install-hooks and make check targets Global flags infrastructure: - Add GlobalOpts struct with --json, --no-input, --quiet flags - Create Output module for stderr/stdout separation - Thread GlobalOpts through all command signatures Non-interactive login: - Add --org-id, --alias, --api-env, --skip-api-key-wait flags - Bail with clear error when --no-input is set without required args - Move prompts and status messages to stderr Rename --dangerous-skip-interactive to --yes/-y: - Old flag preserved as hidden alias for backward compatibility - --no-input also auto-skips interactive approval prompts Tests (8 -> 16): - Global flags recognition tests - --yes, -y, backward compat tests for deploy approve - --no-input skips interactive tests - Non-interactive login tests
5 tasks
- Remove unused is_no_input() method and IsTerminal import from GlobalOpts. Non-interactive mode is controlled exclusively by the --no-input flag / TVC_NO_INPUT env var. No magic TTY detection. - Move all interactive approve output (review sections, confirm prompts, approval status) to stderr. This keeps stdout clean for the approval JSON when piping output. - Update tests to assert interactive content on stderr instead of stdout, and approval JSON on stdout.
Remove Output::result() method since no command in this PR uses it (belongs in PR B where JSON output structs are added). Remove unused serde import. Add tests for all API environment values: - login_api_env_dev, login_api_env_preprod, login_api_env_local - login_api_env_invalid_rejected (clap validation) - login_api_env_defaults_to_prod (omitted flag) - login_quiet_suppresses_status (behavioral --quiet test) Test count: 16 -> 22
emostov
reviewed
Mar 27, 2026
Contributor
There was a problem hiding this comment.
My opinion is we should keep this not checked in and add to gitignore if you like using it. Pre-commit hooks are a bit more of personal pref that I don't want to push on people
emostov
reviewed
Mar 27, 2026
| println!("========================================\n"); | ||
| eprintln!("\n========================================"); | ||
| eprintln!(" MANIFEST APPROVAL"); | ||
| eprintln!("========================================\n"); |
emostov
reviewed
Mar 27, 2026
| } | ||
|
|
||
| fn notice(message: &str) { | ||
| eprintln!("{message}"); |
Contributor
There was a problem hiding this comment.
why wrap eprintln with this function but in other places use it directly?
Contributor
|
Can we break this up into separate PRs by functionality
|
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds non-interactive support to the TVC CLI while keeping the interface simple and predictable for both humans and autonomous agents.
Current behavior:
tvchas two global flags:--no-inputand--quiet--no-inputunless all required inputs are provided explicitlytvc loginsupports a non-interactive setup flow with--org-id,--alias, and--api-envtvc deploy approveuses--yes/-yfor explicit non-interactive approval, with--dangerous-skip-interactivekept as a backward-compatible aliasstderr, while command results stay onstdoutmake install-hooksand runscargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo testThe CLI surface in this branch is intentionally small:
--no-inputis the non-interactive pathTest Plan
cargo test -p tvctvc --helptvc --no-input loginfailure pathtvc --no-input login --org-id ...through real network verification outside the sandboxtvc --no-input deploy approve ...failure without--yestvc --no-input deploy approve ... --yes --skip-postcargo fmt --check,cargo clippy, andcargo test)