Skip to content

Add first-run hints, init --config, and verbose flag support#6

Merged
voidreamer merged 1 commit into
mainfrom
claude/anvil-first-run-experience-NJpCd
Apr 29, 2026
Merged

Add first-run hints, init --config, and verbose flag support#6
voidreamer merged 1 commit into
mainfrom
claude/anvil-first-run-experience-NJpCd

Conversation

@voidreamer
Copy link
Copy Markdown
Owner

Summary

This PR improves the first-time user experience by adding helpful diagnostics when packages aren't found, scaffolding a starter global config file, and implementing a verbose flag for controlling log output.

Key Changes

  • First-run hints: When anvil list finds no packages, emit contextual hints to stderr suggesting anvil init --config or checking ANVIL_PACKAGES environment variable. Added Config::first_run_hint() to diagnose common configuration issues.

  • anvil init --config: New subcommand to scaffold ~/.anvil.yaml with a commented template including example package_paths, aliases, and filters. Refuses to overwrite existing config files.

  • Verbose flag (-v, -vv): Global -v / --verbose flag that steps up log levels from warn (default) → info → debug. RUST_LOG environment variable still takes precedence. Default quiet behavior prevents info logs from polluting stderr in piped contexts like eval "$(anvil env ...)".

  • anvil info improvements: When multiple versions of a package exist (e.g., resolver-1.yaml, resolver-2.yaml), display all available versions so users aren't surprised by silent version selection.

  • CLI updates: Made Init command's name parameter optional (required only when not using --config), added --config flag with proper conflict handling.

  • Documentation: Updated README with quick-start instructions for anvil init --config, clarified commands map behavior with examples, and documented environment variables and log verbosity control.

Implementation Details

  • Logging now writes to stderr (previously defaulted to stdout) and respects the verbose flag before checking RUST_LOG.
  • Config::first_run_hint() returns None when at least one package path exists, avoiding noise in normal operation.
  • The init --config template includes helpful comments and examples for common use cases (aliases, filters, shell selection).
  • Tests cover all new functionality: empty package directories, missing paths, config scaffolding, overwrite protection, and verbose flag behavior.

https://claude.ai/code/session_0147nsxp1EPFDBeeT3rCyTNc

- Default log level drops to WARN so `anvil env <pkg> --export | eval`
  doesn't dump "Loaded N packages" and similar info logs to stderr.
  Add a global `-v` (info) / `-vv` (debug) flag; `RUST_LOG` still wins.
- `anvil list` now prints a hint when no packages are visible, telling
  the user whether the config is missing, has no `package_paths`, or
  whether the configured paths don't exist on disk.
- New `anvil init --config` scaffolds a commented `~/.anvil.yaml`
  template so first-time users have something to edit.
- `anvil info <name>` surfaces all available versions when there's
  more than one on disk — covers the resolver-1.yaml / resolver-2.yaml
  case where filenames diverge from the package name.
- README: install hint about `~/.cargo/bin` on PATH, expanded section
  on multi-token command aliases, mention of `anvil init --config`,
  and a note that anvil is quiet by default with `-v` for verbose.

https://claude.ai/code/session_0147nsxp1EPFDBeeT3rCyTNc
@voidreamer voidreamer merged commit 3a9ece3 into main Apr 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants