feat: add non-interactive mode with auto TTY detection#8
Open
Conversation
- Add `is_interactive_mode()` to util.rs using `is-terminal` crate for zero-cost TTY detection (auto-detects pipes/CI environments) - Add global `-n/--no-interactive` and `-y/--yes` CLI flags to all commands - `PjiApp::new(interactive, auto_yes)` replaces no-arg constructor; mode is threaded through all selection and confirmation methods - `find_repo()`: interactive shows fuzzy TUI; non-interactive filters by query string and exits 1 with clear error on zero/ambiguous matches - `exec_into_dir()`: interactive replaces process with shell; non-interactive prints path to stdout enabling `cd $(pji -n find myrepo)` integration - `confirm()`: non-interactive returns `auto_yes` value instead of prompting - `config` gains `--root <path>` flag for non-interactive root setup - `worktree add` gains `--branch`, `--new-branch`, `--base`, `--path` flags - `worktree remove` requires worktree arg in non-interactive mode - `worktree switch/select_worktree`: filter by query, error on ambiguity 🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-91a6df75e9964bc4bff2f60476413412) Co-Authored-By: Pochi <noreply@getpochi.com>
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
-n/--no-interactiveand-y/--yesCLI flags that apply to every subcommandis-terminalcrate (triggers automatically in pipes/CI/scripts)find_repo()/select_worktree()now filter by query string in non-interactive mode, exiting 1 with actionable errors on zero/ambiguous matchesexec_into_dir()prints the resolved path to stdout in non-interactive mode, enablingcd $(pji -n find myrepo)shell integrationconfirm()returns--yesflag value instead of prompting in non-interactive modeconfiggains--root <path>flag;worktree addgains--branch,--new-branch,--base,--pathflagsNew CLI usage
Test plan
pji myrepoin a terminal — fuzzy TUI still appears as beforepji -n find myrepo— prints the repo path and exitscd $(pji -n find myrepo)— changes directory successfullypji -n find ambiguouswith multiple matches — exits 1 with listpji -n find nomatch— exits 1 with clear error messageecho "" | pji find myrepo— auto-detects non-TTY, prints pathpji config --root ~/projects— adds root without interactive promptpji -n worktree add --branch feat/x --new-branch— creates worktree without TUIpji -n -y worktree remove feat/x— removes without confirmation🤖 Generated with Pochi | Task