Skip to main content

Overview

The list command displays all keys currently stored in the vault, sorted alphabetically in ascending order. If the vault is empty, it displays “(no keys)”.

Syntax

vault list

Parameters

This command takes no parameters.

Examples

Basic Usage

vault list

Expected Output

When vault contains keys:
api_key
database_host
database_port
username
When vault is empty:
(no keys)

Complete Workflow Example

# Check empty vault
vault list
# Output: (no keys)

# Add some keys
vault add zebra "last item"
vault add apple "first item"
vault add middle "middle item"

# List all keys (sorted alphabetically)
vault list
# Output:
# apple
# middle
# zebra

# Remove a key
vault remove middle

# List again
vault list
# Output:
# apple
# zebra

Implementation Details

Under the Hood

The list command executes the following SQL query (KVSTORE.cs:111-114):
SELECT key FROM store
ORDER BY key ASC
The full implementation (KVSTORE.cs:108-127):
public int ListKeys()
{
    using var command = connection.CreateCommand();
    command.CommandText = """
        SELECT key FROM store
        ORDER BY key ASC
        """;
    using var reader = command.ExecuteReader();
    bool any = false;
    while (reader.Read())
    {
        any = true;
        Console.WriteLine(reader.GetString(0));
    }
    if (!any)
    {
        Console.WriteLine("(no keys)");
    }
    return 0;
}

Validation

The command validates that exactly 0 arguments are provided (KVSTORE.cs:187-191):
case "list":
    if (args.Length == 0)
    {
        return Command.LIST;
    }

Behavior Notes

Alphabetical SortingKeys are always returned in ascending alphabetical order (A-Z), regardless of the order in which they were added to the vault.This sorting is performed by SQLite using the ORDER BY key ASC clause.
Values Not ShownThe list command only displays keys, not their associated values. This is useful for:
  • Getting an overview of what’s stored without exposing sensitive values
  • Finding key names before using get to retrieve specific values
  • Checking which keys exist before adding, updating, or removing entries
To see a value, use vault get <key>.

Error Cases

Invalid ArgumentsProviding any arguments to the list command will result in:
Please enter a valid command, could not execute
The command must be called with zero arguments:
vault list        # ✓ Correct
vault list all    # ✗ Invalid - too many arguments

Use Cases

  • Inventory check: See all keys stored in your vault
  • Before cleanup: Review what keys exist before removing old entries
  • Script integration: Get a list of all available keys for automation
  • Memory aid: Recall what you’ve stored when you forget a key name
  • Audit: Verify which secrets or configuration values are present

Script Integration

The list command is particularly useful in shell scripts:
#!/bin/bash

# Get all keys and process them
for key in $(vault list); do
    if [ "$key" != "(no keys)" ]; then
        value=$(vault get "$key")
        echo "$key=$value"
    fi
done
Empty Vault DetectionWhen scripting, check for the “(no keys)” output to detect an empty vault:
output=$(vault list)
if [ "$output" = "(no keys)" ]; then
    echo "Vault is empty"
else
    echo "Vault contains keys"
fi
  • add - Add new keys to the vault
  • get - Retrieve values for keys shown in the list
  • remove - Delete keys from the vault
  • update - Update values for existing keys

Build docs developers (and LLMs) love