-
Notifications
You must be signed in to change notification settings - Fork 14
Streamline commands #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Streamline commands #472
Conversation
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
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #472 +/- ##
==========================================
- Coverage 79.36% 79.15% -0.22%
==========================================
Files 9 14 +5
Lines 659 1439 +780
Branches 148 309 +161
==========================================
+ Hits 523 1139 +616
- Misses 78 185 +107
- Partials 58 115 +57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
979f724
to
3283818
Compare
why: Align vcspull CLI with modern DevOps tool conventions (Terraform, Cargo, Ruff, Biome) for improved developer experience and automation support. Previous CLI lacked introspection commands, dry-run support, and machine-readable output. what: Breaking Changes: - Remove `vcspull import` command (split into `add` and `discover`) - Rename `-c/--config` to `-f/--file` across all commands - Add `-w/--workspace/--workspace-root` (all aliases supported) New Commands: - `vcspull list` - List configured repos with --tree, --json, --ndjson - `vcspull status` - Check repo health (exists, clean/dirty, ahead/behind) - `vcspull add` - Add single repository with --dry-run support - `vcspull discover` - Scan filesystem for repos with --dry-run support New Infrastructure: - Create _output.py for OutputFormatter (JSON/NDJSON/human modes) - Create _colors.py with semantic colors and NO_COLOR support - Add --dry-run/-n flag to sync, add, discover commands - Add --json/--ndjson structured output to sync, list, status - Add --color {auto,always,never} flag with NO_COLOR env support Improvements: - Split _import.py into add.py (single) and discover.py (bulk) - Update sync.py with new flags and dry-run preview mode - Update fmt.py to use -f flag instead of -c - Wire all new commands in __init__.py with updated examples - Update README.md with new command examples - Update CHANGES with breaking changes and migration guide - Update test_log.py for new module structure Migration Guide in CHANGES: - vcspull import NAME URL → vcspull add NAME URL - vcspull import --scan DIR → vcspull discover DIR - vcspull sync -c FILE → vcspull sync -f FILE - vcspull sync --workspace-root PATH → vcspull sync -w PATH refs: All tests pass (109 tests), mypy clean, ruff clean
why: New commands (add, discover, list, status) need test coverage to ensure reliability and prevent regressions. Tests follow project's NamedTuple fixture pattern for parameterized testing. what: - Create tests/cli/test_add.py with 5 tests: * Parameterized tests for add with default/custom workspace * Dry-run mode test * Duplicate repository warning test * New config file creation test - Create tests/cli/test_discover.py with 6 tests: * Parameterized tests for single-level and recursive discovery * Dry-run mode test * Skip repos without remote URL test * Show existing repos test * Workspace override test - Create tests/cli/test_list.py with 6 tests: * Parameterized tests for listing all/filtered repos * JSON output test * Tree mode test * Empty config test * Pattern no-match test - Create tests/cli/test_status.py with 7 tests: * Parameterized tests for repo status (exists/git/missing) * Status all repos test * JSON output test * Detailed mode test * Pattern filter test Testing patterns: - Use caplog.set_level(logging.INFO) to capture log output - Use tmp_path and monkeypatch for isolated test environments - Follow project's NamedTuple fixture pattern for parameterization - Test both human and machine-readable output modes refs: All 133 tests pass (109 original + 24 new), mypy clean, ruff clean
… to repo configs why: workspace_root field was showing as empty strings in JSON output from list and status commands. This field is essential for identifying which workspace section a repository belongs to, especially for automation and tooling that processes vcspull output. what: - Add workspace_root field to ConfigDict TypedDict in types.py - Set workspace_root in extract_repos() to preserve original directory label - Include workspace_root in check_repo_status() return value - Update test fixtures to include workspace_root field for type compliance The workspace_root now correctly shows labels like "~/study/ai/" or "~/work/python/" in JSON output, matching the keys from .vcspull.yaml config.
why: The CLI modernization added four new commands (list, status, add, discover), replaced the import command, and added the workspace_root field to JSON output. These changes needed comprehensive documentation for users and API reference updates. what: - Create docs/cli/list.md with JSON/NDJSON output examples showing workspace_root - Create docs/cli/status.md with detailed status and automation examples - Create docs/cli/add.md documenting single repo addition (replaces import) - Create docs/cli/discover.md for bulk filesystem scanning (replaces import --scan) - Update docs/cli/sync.md with --dry-run, --json, --ndjson, -f, -w flags - Update docs/cli/fmt.md changing -c/--config to -f/--file throughout - Update docs/cli/import.md with deprecation notice and migration guide - Update docs/quickstart.md changing import to add/discover, -c to -f - Create API reference docs for new modules (add, discover, list, status) - Update docs/cli/index.md and docs/api/cli/index.md with new command toctrees - Update docs/api/cli/import.md noting module removal All JSON output examples now show workspace_root field correctly populated with workspace labels like "~/study/ai/" matching .vcspull.yaml keys. Migration guides included for users upgrading from import command.
why: Sphinx build was failing because docs/cli/import.md referenced the import subparser which was removed in the CLI modernization. what: Remove argparse directive from import.md since the command no longer exists. Keep the historical documentation for reference but remove the command reference that tried to introspect the non-existent subparser.
why: Ensure Terraform-style planner and helper utilities stay stable. what: - add plan payload and progress tests in tests/cli/test_plan_output_helpers.py - cover _maybe_fetch and _determine_plan_action edge cases in tests/cli/test_sync_plan_helpers.py - extend dry-run CLI fixtures to inject deterministic plan results via module monkeypatch
3283818
to
4253b85
Compare
4253b85
to
c87805f
Compare
8 tasks
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.
Modernize CLI: Align with DevOps Tool Conventions
Summary
This PR modernizes vcspull's CLI to align with modern DevOps tool conventions (Terraform, Cargo, Ruff, Biome), providing a more intuitive developer experience and better automation support.
Motivation
The previous CLI lacked:
-c
vs-f
, verbose--workspace-root
)import
command tried to do two different thingsChanges
🎯 New Commands
vcspull list
- List Configured Repositoriesvcspull status
- Check Repository Healthvcspull add
- Add Single Repositoryvcspull add mylib https://github.com/example/mylib.git vcspull add mylib URL -w ~/code vcspull add mylib URL --dry-run
vcspull discover
- Scan Filesystem for Repositories🔄 Breaking Changes
vcspull import NAME URL
vcspull add NAME URL
vcspull import --scan DIR
vcspull discover DIR
-c/--config
-f/--file
--workspace-root
-w/--workspace
(all 3 aliases supported)✨ New Features
Dry-Run Mode
Action commands support
--dry-run/-n
for safe previewing:Structured Output
Machine-readable output for automation:
Semantic Colors
--color {auto,always,never}
- Control color outputNO_COLOR
environment variableShort Flags
-w
for workspace (instead of verbose--workspace-root
)-n
for dry-run-f
for file (matches kubectl, docker-compose conventions)📁 File Structure
New Files:
Deleted Files:
src/vcspull/cli/_import.py
(split into add.py + discover.py)tests/cli/test_import.py
(replaced by test_add.py + test_discover.py)Modified Files:
src/vcspull/cli/__init__.py
- Wire new commands, update examplessrc/vcspull/cli/sync.py
- Add-f
,-w
,--dry-run
,--json/--ndjson
, async planningsrc/vcspull/cli/fmt.py
- Change-c
to-f
tests/test_cli.py
- Update for new command structuretests/test_log.py
- Update logger names for new modulesREADME.md
- Update all examples with new commandsCHANGES
- Document breaking changes with migration guidedocs/
- Comprehensive documentation for all new commandsMigration Guide
Command Changes
# Old → New vcspull import NAME URL → vcspull add NAME URL vcspull import --scan DIR → vcspull discover DIR
Flag Changes
Examples
Before (v1.38.x)
After (v1.39.x)
Testing
Test Coverage
New Tests Breakdown
Testing Patterns
Validation
Design Decisions
Why Split
import
intoadd
anddiscover
?Problem: Single command doing two unrelated things is confusing
vcspull import NAME URL
- adds single repovcspull import --scan DIR
- scans filesystemSolution: Separate commands with clear purposes
vcspull add NAME URL
- single repo, explicitvcspull discover DIR
- filesystem scan, bulk operationThis matches patterns from other tools:
git add <file>
(single) vsgit add -A
(bulk)npm install <package>
(single) vsnpm install
(from package.json)cargo add <crate>
(single) vs bulk dependency managementWhy
-f/--file
instead of-c/--config
?Precedent: Matches widely-used DevOps tools
kubectl -f/--filename
docker-compose -f/--file
make -f/--file
terraform -chdir=DIR
(similar concept)Benefit: Reduces cognitive load for users already familiar with these tools
Why
--dry-run/-n
?Precedent: Universal pattern across DevOps tools
terraform plan
(preview changes)apt-get -s/--dry-run
(simulate)rsync -n/--dry-run
(preview)git add -n/--dry-run
(preview)ansible-playbook --check
(dry-run)Benefit: Safety-first approach prevents accidental changes
Why
--json
and--ndjson
?Use Cases:
--json
: Single operation results (list, status) - complete JSON object--ndjson
: Streaming operations (sync progress) - one JSON per linePrecedent:
--message-format=json
(NDJSON to stdout)--json
(NDJSON events)-json
(plan/apply output)docker events --format '{{json .}}'
Why "Action Commands" vs "Introspection Commands"?
Clarity: Creates clear parallel between command types
sync
,add
,discover
) - perform mutations, support--dry-run
list
,status
) - read-only, no side effectsThis terminology is clear and doesn't overload the meaning of "write" (which could mean "write to disk" or "write to config").
Documentation Updates
User-Facing Documentation
--help
output for all commandsvcspull add
(176 lines)vcspull discover
(273 lines)vcspull list
(160 lines)vcspull status
(212 lines)API Documentation
Backwards Compatibility
What Breaks
vcspull import
command removed (useadd
ordiscover
)-c
short flag removed (use-f
)What Stays Compatible
--workspace-root
still works (alias to-w/--workspace
)Alignment with DevOps Tools
This PR brings vcspull in line with modern CLI conventions:
--dry-run/-n
--json/--ndjson
-f/--file
--color {auto,always,never}
Key Features
Terraform-Style Dry-Run Plans
Machine-Readable Output
Introspection Commands
Commits
This PR contains 17 commits organized by feature area:
Core CLI Infrastructure:
cli(feat)
: Add shared output formatter for JSON/NDJSON/human-readable modescli(feat)
: Add semantic colors with NO_COLOR supportcli(feat)
: Add workspace filtering helperNew Commands:
4.
cli(list feat)
: Add list command for viewing configured repositories5.
cli(status feat)
: Add status command for repository health checks6.
cli(status feat[detailed])
: Report branch divergence and ahead/behind7.
cli(add feat)
: Add command for single repository registration8.
cli(discover feat)
: Add discover command for filesystem scanningSync Enhancements:
9.
cli(sync feat)
: Add dry-run mode with Terraform-style plans10.
cli(sync)
: Async dry-run plan output with progress tracking11.
cli(sync)
: Quiet stderr/stdout capture for structured output12.
cli(sync)
: Suppress progress noise in machine-readable output13.
cli(sync feat[workspace-filter])
: Add shared workspace filtering helperFlag Alignment:
14.
cli
: Align help text and formatter with new flags (-f, -w)Testing & Documentation:
15.
tests(discover/config,cli)
: Cover edge-path behaviour16.
cli/tests(test[plan-output])
: Add coverage for sync planner helpers17.
docs(readme)
: Document new cli introspection commands18.
docs(CHANGES)
: Improve accuracy and readability19.
docs(CHANGES)
: Use "action commands" instead of "write commands"Impact
For End Users
For Automation/CI/CD
--yes
flag for bulk operationsFor Maintainers
Performance
No performance regressions:
Security
No security changes - same git/hg/svn subprocess handling
Checklist
References