Skip to content

feat: add list-vaults command and validate set-default input#98

Open
petems wants to merge 2 commits intoYakitrak:mainfrom
petems:feat/list-vaults-command
Open

feat: add list-vaults command and validate set-default input#98
petems wants to merge 2 commits intoYakitrak:mainfrom
petems:feat/list-vaults-command

Conversation

@petems
Copy link

@petems petems commented Mar 2, 2026

Summary

  • Add a new list-vaults (alias lv) command that discovers all registered Obsidian vaults from the config file, with --json and --path-only output flags
  • Validate set-default input against registered vaults via a new ResolveVaultName helper — accepts vault name or full path, and shows available vaults on mismatch
  • Extend Obsidian config file discovery to support numbered snap directories (e.g. ~/snap/obsidian/x1/...) when the current symlink is absent
  • Full WSL path translation support for listed vaults

What's included

File Description
cmd/list_vaults.go New list-vaults command with --json and --path-only flags
cmd/set_default.go Wire set-default through ResolveVaultName for input validation
pkg/obsidian/vault_list.go ListVaults() and ResolveVaultName() — vault discovery and name resolution
pkg/obsidian/vault_list_test.go 263 lines of tests covering listing, WSL paths, name/path resolution, and error cases
pkg/config/obsidian_path.go Add numbered snap directory glob to config search candidates
pkg/config/obsidian_path_test.go Test for numbered snap directory config discovery

References

Test plan

  • go test ./... passes locally
  • Manual: notesmd list-vaults shows registered vaults
  • Manual: notesmd list-vaults --json outputs valid JSON array
  • Manual: notesmd list-vaults --path-only outputs one path per line
  • Manual: notesmd set-default NonExistent prints available vaults and exits with error
  • Manual: notesmd set-default <valid-vault> succeeds as before

AI disclosure

This PR was developed with assistance from Claude Code (claude-opus-4-6). The AI helped with code generation, test writing, and PR preparation. All code was reviewed and validated by a human before submission.


🤖 Generated with Claude Code

petems and others added 2 commits February 27, 2026 07:34
- Add `list-vaults` (alias `lv`) command with --json and --path-only flags
- Add ListVaults() function to enumerate all vaults from obsidian.json
- Derive vault names from directory path using filepath.Base()
- Apply WSL path adjustment when running under WSL
- Sort output alphabetically by vault name for deterministic display
- Add support for numbered snap subdirectories (e.g. ~/snap/obsidian/x1/)
  when the "current" symlink is missing
- Add tests for vault listing (7 cases) and numbered snap discovery

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
set-default now resolves user input (name or path) against Obsidian's
registered vaults, preventing silent failures when a path is passed
instead of a vault name. Unrecognized input produces a helpful error
listing available vaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Yakitrak
Copy link
Owner

Yakitrak commented Mar 2, 2026

Thank you for the PR, please can you update the README.md documentation similar to the rest of the commands

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.

Feature Request: Add list-vaults command to discover registered Obsidian vaults set-default didn't check for wrong input, causing silent errors

2 participants