Refactor unlockers command structure and add quiet flag to list command

- Rename 'unlockers' command to 'unlocker' for consistency
- Move all unlocker subcommands (list, add, remove) under single 'unlocker' command
- Add --quiet/-q flag to 'secret list' for scripting support
- Update documentation and tests to reflect command changes

The quiet flag outputs only secret names without headers or formatting,
making it ideal for shell script usage like: secret get $(secret list -q | head -1)
This commit is contained in:
2025-07-22 16:04:44 +02:00
parent 70d19d09d0
commit a73a409fe4
7 changed files with 125 additions and 48 deletions

View File

@@ -132,10 +132,10 @@ Generates and stores a random secret.
### Unlocker Management
#### `secret unlockers list [--json]` / `secret unlockers ls`
#### `secret unlocker list [--json]` / `secret unlocker ls`
Lists all unlockers in the current vault with their metadata.
#### `secret unlockers add <type> [options]`
#### `secret unlocker add <type> [options]`
Creates a new unlocker of the specified type:
**Types:**
@@ -146,7 +146,7 @@ Creates a new unlocker of the specified type:
**Options:**
- `--keyid <id>`: GPG key ID (required for PGP type)
#### `secret unlockers remove <unlocker-id> [--force]` / `secret unlockers rm` ⚠️ 🛑
#### `secret unlocker remove <unlocker-id> [--force]` / `secret unlocker rm` ⚠️ 🛑
**DANGER**: Permanently removes an unlocker. Like Unix `rm`, this command does not ask for confirmation.
Cannot remove the last unlocker if the vault has secrets unless --force is used.
- `--force, -f`: Force removal of last unlocker even if vault has secrets
@@ -308,7 +308,7 @@ secret vault create personal
# Work with work vault
secret vault select work
echo "work-db-pass" | secret add database/password
secret unlockers add passphrase # Add passphrase authentication
secret unlocker add passphrase # Add passphrase authentication
# Switch to personal vault
secret vault select personal
@@ -324,18 +324,18 @@ secret vault remove personal --force
### Advanced Authentication
```bash
# Add multiple unlock methods
secret unlockers add passphrase # Password-based
secret unlockers add pgp --keyid ABCD1234 # GPG key
secret unlockers add keychain # macOS Keychain (macOS only)
secret unlocker add passphrase # Password-based
secret unlocker add pgp --keyid ABCD1234 # GPG key
secret unlocker add keychain # macOS Keychain (macOS only)
# List unlockers
secret unlockers list
secret unlocker list
# Select a specific unlocker
secret unlocker select <unlocker-id>
# Remove an unlocker ⚠️ 🛑 (NO CONFIRMATION!)
secret unlockers remove <unlocker-id>
secret unlocker remove <unlocker-id>
```
### Version Management