Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix(cli): storage get/delete and state save/load/show/delete take the key or name as a positional, refuse it given twice, and a bare storage delete is refused naming storage clear instead of wiping the store (PIN-430)

Luigi Agosti0c428fbea9e8
diff --git a/cmd/pinchtab/cmd_cli_docs_test.go b/cmd/pinchtab/cmd_cli_docs_test.go
index 7b60e88a..ddb8d34e 100644
--- a/cmd/pinchtab/cmd_cli_docs_test.go
+++ b/cmd/pinchtab/cmd_cli_docs_test.go
@@ -145,14 +145,14 @@ func TestTheCookiesReferenceStatesTheBrowserWideClearEffect(t *testing.T) {
}
}
- // The same failure one verb over: `storage delete` with no --key runs storageObj.clear()
- // through the identical handler `storage clear` reaches, so a doc describing --key as
- // "a single item" reads narrower than a destructive command actually is. The last phrase
- // pins the FLAG ROW as well as the prose: reverting only the row is the exact shape the
- // defect had, and the sentence below the table does not stop it coming back.
- for _, want := range []string{"no `--key`", "clears the whole store", "same call", "omit it and the whole store is cleared"} {
+ for _, want := range []string{"pinchtab storage delete token", "bare `storage delete` is refused", "only verb that wipes a store", "pinchtab storage clear"} {
if !strings.Contains(storage, want) {
- t.Errorf("the storage section never says %q; `storage delete` with no --key clears the whole store, and a reader told only about single-key removal will run it expecting one item to go", want)
+ t.Errorf("the storage section never says %q; `storage delete` needs a key and `storage clear` is the one wipe verb, and the doc must teach both", want)
+ }
+ }
+ for _, stale := range []string{"no `--key`", "omit it and the whole store is cleared", "pinchtab storage delete "} {
+ if strings.Contains(storage, stale) {
+ t.Errorf("the storage section still says %q, teaching a bare `storage delete` wipe the CLI now refuses", stale)
}
}
}
diff --git a/cmd/pinchtab/cmd_cli_state.go b/cmd/pinchtab/cmd_cli_state.go
index f63b458a..ce3b3ad2 100644
--- a/cmd/pinchtab/cmd_cli_state.go
+++ b/cmd/pinchtab/cmd_cli_state.go
@@ -5,6 +5,8 @@ import (
"github.com/spf13/cobra"
)
+const stateListRemedy = `run "pinchtab state list" to see saved states`
+
var stateCmd = &cobra.Command{
Use: "state",
Short: "Show current browser state or manage saved state",
@@ -28,45 +30,53 @@ var stateListCmd = &cobra.Command{
}
var stateSaveCmd = &cobra.Command{
- Use: "save",
+ Use: "save [name]",
Short: "Save current browser state",
- Long: "Capture cookies, localStorage, and sessionStorage for the active tab and persist to disk. Requires security.allowStateExport=true.",
+ Long: "Capture cookies, localStorage, and sessionStorage for the active tab and persist to disk under the given name (or --name); omit it to auto-generate one. Requires security.allowStateExport=true.",
+ Args: optionalOperand("name"),
Run: func(cmd *cobra.Command, args []string) {
+ name := operandOrFlag(cmd, args, "name")
runCLI(func(rt cliRuntime) {
- browseractions.StateSave(rt.client, rt.base, rt.token, cmd)
+ browseractions.StateSave(rt.client, rt.base, rt.token, cmd, name)
})
},
}
var stateLoadCmd = &cobra.Command{
- Use: "load",
+ Use: "load <name>",
Short: "Load and restore a saved state",
- Long: "Restore cookies and storage from a previously saved state file. Supports exact name or prefix matching (most recent match is used). Requires security.allowStateExport=true.",
+ Long: "Restore cookies and storage from a previously saved state file, named as the argument (or --name). Supports exact name or prefix matching (most recent match is used). Requires security.allowStateExport=true.",
+ Args: requiredOperand("name", stateListRemedy),
Run: func(cmd *cobra.Command, args []string) {
+ name := operandOrFlag(cmd, args, "name")
runCLI(func(rt cliRuntime) {
- browseractions.StateLoad(rt.client, rt.base, rt.token, cmd)
+ browseractions.StateLoad(rt.client, rt.base, rt.token, cmd, name)
})
},
}
var stateShowCmd = &cobra.Command{
- Use: "show",
+ Use: "show <name>",
Short: "Show state file details",
- Long: "Display the full contents of a saved state file including cookies and storage. Requires security.allowStateExport=true.",
+ Long: "Display the full contents of a saved state file, named as the argument (or --name), including cookies and storage. Requires security.allowStateExport=true.",
+ Args: requiredOperand("name", stateListRemedy),
Run: func(cmd *cobra.Command, args []string) {
+ name := operandOrFlag(cmd, args, "name")
runCLI(func(rt cliRuntime) {
- browseractions.StateShow(rt.client, rt.base, rt.token, cmd)
+ browseractions.StateShow(rt.client, rt.base, rt.token, name)
})
},
}
var stateDeleteCmd = &cobra.Command{
- Use: "delete",
+ Use: "delete <name>",
Short: "Delete a saved state file",
- Long: "Remove a named state file from the state directory. Requires security.allowStateExport=true.",
+ Long: "Remove a state file, named as the argument (or --name), from the state directory. Requires security.allowStateExport=true.",
+ Args: requiredOperand("name", stateListRemedy),
Run: func(cmd *cobra.Command, args []string) {
+ name := operandOrFlag(cmd, args, "name")
runCLI(func(rt cliRuntime) {
- browseractions.StateDelete(rt.client, rt.base, rt.token, cmd)
+ browseractions.StateDelete(rt.client, rt.base, rt.token, name)
})
},
}
@@ -86,19 +96,16 @@ func init() {
stateCmd.AddCommand(stateListCmd, stateSaveCmd, stateLoadCmd, stateShowCmd, stateDeleteCmd, stateCleanCmd)
addTabFlag(stateCmd)
- stateSaveCmd.Flags().String("name", "", "Name for the saved state (auto-generated if omitted)")
+ stateSaveCmd.Flags().String("name", "", "Name for the saved state, same as the [name] argument (auto-generated if omitted)")
stateSaveCmd.Flags().Bool("encrypt", false, "Encrypt the state file (requires security.stateEncryptionKey in config)")
addTabFlag(stateSaveCmd)
- stateLoadCmd.Flags().String("name", "", "Exact name or prefix of the state file to load")
- _ = stateLoadCmd.MarkFlagRequired("name")
+ stateLoadCmd.Flags().String("name", "", "Exact name or prefix of the state file to load (same as the <name> argument)")
addTabFlag(stateLoadCmd)
- stateShowCmd.Flags().String("name", "", "Name of the state file to inspect")
- _ = stateShowCmd.MarkFlagRequired("name")
+ stateShowCmd.Flags().String("name", "", "Name of the state file to inspect (same as the <name> argument)")
- stateDeleteCmd.Flags().String("name", "", "Name of the state file to delete")
- _ = stateDeleteCmd.MarkFlagRequired("name")
+ stateDeleteCmd.Flags().String("name", "", "Name of the state file to delete (same as the <name> argument)")
stateCleanCmd.Flags().Int("older-than", 24, "Remove files older than this many hours")
}
diff --git a/cmd/pinchtab/cmd_cli_state_test.go b/cmd/pinchtab/cmd_cli_state_test.go
new file mode 100644
index 00000000..a0d53ad8
--- /dev/null
+++ b/cmd/pinchtab/cmd_cli_state_test.go
@@ -0,0 +1,44 @@
+package main
+
+import "testing"
+
+func TestStateSaveTakesTheNameAsArgumentOrFlag(t *testing.T) {
+ checkOperandRows(t, stateSaveCmd, "name", []operandRow{
+ {name: "positional name", argv: []string{"walk1"}, want: "walk1"},
+ {name: "--name alias", argv: []string{"--name", "walk1", "--encrypt"}, want: "walk1"},
+ {name: "no name auto-generates", argv: nil, want: ""},
+ bothGivenRow("name"),
+ {name: "two names", argv: []string{"a", "b"}, refuses: []string{"at most 1"}},
+ })
+}
+
+func TestStateLoadTakesTheNameOrPrefixAsArgumentOrFlag(t *testing.T) {
+ checkOperandRows(t, stateLoadCmd, "name", []operandRow{
+ {name: "positional name", argv: []string{"walk1"}, want: "walk1"},
+ {name: "positional prefix", argv: []string{"wal"}, want: "wal"},
+ {name: "--name alias", argv: []string{"--name", "walk1"}, want: "walk1"},
+ {name: "no name is refused", argv: nil, refuses: []string{"needs a name", "pinchtab state list"}},
+ bothGivenRow("name"),
+ {name: "two names", argv: []string{"a", "b"}, refuses: []string{"at most 1"}},
+ })
+}
+
+func TestStateShowNeedsExactlyOneName(t *testing.T) {
+ checkOperandRows(t, stateShowCmd, "name", []operandRow{
+ {name: "positional name", argv: []string{"walk1"}, want: "walk1"},
+ {name: "--name alias", argv: []string{"--name", "walk1"}, want: "walk1"},
+ {name: "no name is refused", argv: nil, refuses: []string{"needs a name", "pinchtab state show <name>"}},
+ bothGivenRow("name"),
+ {name: "two names", argv: []string{"a", "b"}, refuses: []string{"at most 1"}},
+ })
+}
+
+func TestStateDeleteNeedsExactlyOneName(t *testing.T) {
+ checkOperandRows(t, stateDeleteCmd, "name", []operandRow{
+ {name: "positional name", argv: []string{"walk1"}, want: "walk1"},
+ {name: "--name alias", argv: []string{"--name", "walk1"}, want: "walk1"},
+ {name: "no name is refused", argv: nil, refuses: []string{"needs a name", "pinchtab state delete <name>"}},
+ bothGivenRow("name"),
+ {name: "two names", argv: []string{"a", "b"}, refuses: []string{"at most 1"}},
+ })
+}
diff --git a/cmd/pinchtab/cmd_cli_storage.go b/cmd/pinchtab/cmd_cli_storage.go
index 1ef82e21..4d685b85 100644
--- a/cmd/pinchtab/cmd_cli_storage.go
+++ b/cmd/pinchtab/cmd_cli_storage.go
@@ -1,6 +1,8 @@
package main
import (
+ "fmt"
+
browseractions "github.com/pinchtab/pinchtab/internal/cli/actions"
"github.com/spf13/cobra"
)
@@ -12,12 +14,14 @@ var storageCmd = &cobra.Command{
}
var storageGetCmd = &cobra.Command{
- Use: "get",
+ Use: "get [key]",
Short: "Get storage items",
- Long: "Read localStorage or sessionStorage items for the active tab. Use --type to select local|session (default: both). Use --key to fetch a single item.",
+ Long: "Read localStorage or sessionStorage items for the active tab. Use --type to select local|session (default: both). Pass a key (or --key) to fetch a single item; omit it to list the store.",
+ Args: optionalOperand("key"),
Run: func(cmd *cobra.Command, args []string) {
+ key := operandOrFlag(cmd, args, "key")
runCLI(func(rt cliRuntime) {
- browseractions.StorageGet(rt.client, rt.base, rt.token, cmd)
+ browseractions.StorageGet(rt.client, rt.base, rt.token, cmd, key)
})
},
}
@@ -35,12 +39,14 @@ var storageSetCmd = &cobra.Command{
}
var storageDeleteCmd = &cobra.Command{
- Use: "delete",
+ Use: "delete <key>",
Short: "Delete a specific storage key",
- Long: "Remove a single key from localStorage or sessionStorage. Use --key and --type local|session.",
+ Long: "Remove a single key from localStorage or sessionStorage. Pass the key (or --key) and --type local|session. A key is required: to wipe a whole store use \"pinchtab storage clear\".",
+ Args: requiredOperand("key", `to wipe the whole store use "pinchtab storage clear"`),
Run: func(cmd *cobra.Command, args []string) {
+ key := operandOrFlag(cmd, args, "key")
runCLI(func(rt cliRuntime) {
- browseractions.StorageDelete(rt.client, rt.base, rt.token, cmd)
+ browseractions.StorageDelete(rt.client, rt.base, rt.token, cmd, key)
})
},
}
@@ -56,18 +62,52 @@ var storageClearCmd = &cobra.Command{
},
}
+func operandOrFlag(cmd *cobra.Command, args []string, flag string) string {
+ if len(args) > 0 {
+ return args[0]
+ }
+ value, _ := cmd.Flags().GetString(flag)
+ return value
+}
+
+func optionalOperand(flag string) cobra.PositionalArgs {
+ return func(cmd *cobra.Command, args []string) error {
+ if err := cobra.MaximumNArgs(1)(cmd, args); err != nil {
+ return err
+ }
+ if len(args) == 0 || !cmd.Flags().Changed(flag) {
+ return nil
+ }
+ value, _ := cmd.Flags().GetString(flag)
+ return fmt.Errorf("%s got the %s twice, %q as the <%s> argument and %q as --%s; pass it once, as the argument or as --%s",
+ cmd.CommandPath(), flag, args[0], flag, value, flag, flag)
+ }
+}
+
+func requiredOperand(flag, remedy string) cobra.PositionalArgs {
+ return func(cmd *cobra.Command, args []string) error {
+ if err := optionalOperand(flag)(cmd, args); err != nil {
+ return err
+ }
+ if operandOrFlag(cmd, args, flag) != "" {
+ return nil
+ }
+ return fmt.Errorf("%s needs a %s: %s <%s>; %s", cmd.CommandPath(), flag, cmd.CommandPath(), flag, remedy)
+ }
+}
+
func init() {
storageCmd.AddCommand(storageGetCmd, storageSetCmd, storageDeleteCmd, storageClearCmd)
addTabFlag(storageGetCmd, storageSetCmd, storageDeleteCmd, storageClearCmd)
storageGetCmd.Flags().String("type", "", "Storage type: local, session (default: both)")
- storageGetCmd.Flags().String("key", "", "Specific key to retrieve")
+ storageGetCmd.Flags().String("key", "", "Specific key to retrieve (same as the <key> argument)")
storageSetCmd.Flags().String("type", "local", "Storage type: local or session")
storageDeleteCmd.Flags().String("type", "local", "Storage type: local or session")
- storageDeleteCmd.Flags().String("key", "", "Key to remove (omit to clear entire store)")
+ storageDeleteCmd.Flags().String("key", "", "Key to remove (same as the <key> argument)")
storageClearCmd.Flags().String("type", "local", "Storage type: local or session")
storageClearCmd.Flags().Bool("all", false, "Clear both localStorage and sessionStorage")
diff --git a/cmd/pinchtab/cmd_cli_storage_test.go b/cmd/pinchtab/cmd_cli_storage_test.go
new file mode 100644
index 00000000..ffc206a2
--- /dev/null
+++ b/cmd/pinchtab/cmd_cli_storage_test.go
@@ -0,0 +1,90 @@
+package main
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+type operandRow struct {
+ name string
+ argv []string
+ want string
+ refuses []string
+}
+
+func resolveOperand(t *testing.T, verb *cobra.Command, flag string, argv ...string) (string, error) {
+ t.Helper()
+ t.Cleanup(func() {
+ verb.Flags().VisitAll(func(f *pflag.Flag) {
+ _ = f.Value.Set(f.DefValue)
+ f.Changed = false
+ })
+ })
+ if err := verb.ParseFlags(argv); err != nil {
+ t.Fatalf("%s cannot parse %v: %v", verb.CommandPath(), argv, err)
+ }
+ args := verb.Flags().Args()
+ if err := verb.ValidateArgs(args); err != nil {
+ return "", err
+ }
+ return operandOrFlag(verb, args, flag), nil
+}
+
+func checkOperandRows(t *testing.T, verb *cobra.Command, flag string, rows []operandRow) {
+ t.Helper()
+ for _, row := range rows {
+ t.Run(row.name, func(t *testing.T) {
+ got, err := resolveOperand(t, verb, flag, row.argv...)
+ invocation := verb.CommandPath() + " " + strings.Join(row.argv, " ")
+ if len(row.refuses) > 0 {
+ if err == nil {
+ t.Fatalf("`%s` was accepted with %s %q, want a refusal", invocation, flag, got)
+ }
+ for _, want := range row.refuses {
+ if !strings.Contains(err.Error(), want) {
+ t.Errorf("`%s` refusal %q does not say %q", invocation, err, want)
+ }
+ }
+ return
+ }
+ if err != nil {
+ t.Fatalf("`%s` was refused: %v", invocation, err)
+ }
+ if got != row.want {
+ t.Errorf("`%s` resolved %s %q, want %q", invocation, flag, got, row.want)
+ }
+ })
+ }
+}
+
+func bothGivenRow(flag string) operandRow {
+ return operandRow{
+ name: "argument and --" + flag + " together",
+ argv: []string{"k1", "--" + flag, "k2"},
+ refuses: []string{"twice", `"k1"`, `"k2"`, "--" + flag},
+ }
+}
+
+func TestStorageGetTakesTheKeyAsArgumentOrFlag(t *testing.T) {
+ checkOperandRows(t, storageGetCmd, "key", []operandRow{
+ {name: "positional key", argv: []string{"k1"}, want: "k1"},
+ {name: "--key alias", argv: []string{"--key", "k1"}, want: "k1"},
+ {name: "no key lists the store", argv: nil, want: ""},
+ bothGivenRow("key"),
+ {name: "two keys", argv: []string{"k1", "k2"}, refuses: []string{"at most 1"}},
+ })
+}
+
+func TestStorageDeleteNeedsExactlyOneKeyAndNeverWipes(t *testing.T) {
+ checkOperandRows(t, storageDeleteCmd, "key", []operandRow{
+ {name: "positional key", argv: []string{"k1"}, want: "k1"},
+ {name: "--key alias", argv: []string{"--key", "k1", "--type", "session"}, want: "k1"},
+ {name: "bare delete is refused, naming the wipe verb", argv: nil, refuses: []string{"needs a key", "pinchtab storage clear"}},
+ {name: "empty --key is refused like a bare delete", argv: []string{"--key", ""}, refuses: []string{"pinchtab storage clear"}},
+ bothGivenRow("key"),
+ {name: "two keys", argv: []string{"k1", "k2"}, refuses: []string{"at most 1"}},
+ })
+}
diff --git a/docs/commands.md b/docs/commands.md
index 2bf6f758..07d44336 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -351,6 +351,33 @@ pinchtab record stop # Stop recording and save
pinchtab record status # Check recording status
```
+## Storage And State
+
+The key or state name is the first argument. `--key` / `--name` are accepted as the same
+value for existing scripts; passing both the argument and the flag is refused.
+
+```bash
+pinchtab storage get # Both localStorage and sessionStorage for the tab's origin
+pinchtab storage get --type local # One store
+pinchtab storage get <key> # A single item (same as --key <key>)
+pinchtab storage set <key> <value> # Write an item (localStorage unless --type session)
+pinchtab storage delete <key> # Remove one key (same as --key <key>); a key is required
+pinchtab storage clear # Wipe localStorage (--type session for sessionStorage)
+pinchtab storage clear --all # Wipe both stores
+pinchtab state # Current browser state for the tab
+pinchtab state list # List saved state files
+pinchtab state save [name] # Save cookies and storage (name auto-generated if omitted)
+pinchtab state save <name> --encrypt # Save encrypted (needs security.stateEncryptionKey)
+pinchtab state load <name> # Restore a saved state; <name> may be a prefix (newest match)
+pinchtab state show <name> # Print a saved state file
+pinchtab state delete <name> # Delete a saved state file
+pinchtab state clean --older-than <h> # Remove state files older than <h> hours (default 24)
+```
+
+`storage delete` never wipes a store: a bare `pinchtab storage delete` is refused and names
+`storage clear`, the one wipe verb. Every storage verb takes `--tab <id>`, as do `state`,
+`state save` and `state load`. The `state` family requires `security.allowStateExport`.
+
## Instances, Profiles, And Activity
```bash
diff --git a/internal/cli/actions/actions_state.go b/internal/cli/actions/actions_state.go
index 469b596a..ad6b42be 100644
--- a/internal/cli/actions/actions_state.go
+++ b/internal/cli/actions/actions_state.go
@@ -8,6 +8,8 @@ import (
"github.com/spf13/cobra"
)
+const stateNameRequired = "Error: a state name is required, as <name> or --name"
+
func StateCurrent(client *http.Client, base, token string, cmd *cobra.Command) {
tabID, _ := cmd.Flags().GetString("tab")
params := url.Values{}
@@ -26,8 +28,7 @@ func StateList(client *http.Client, base, token string) {
printIndented(buf)
}
-func StateSave(client *http.Client, base, token string, cmd *cobra.Command) {
- name, _ := cmd.Flags().GetString("name")
+func StateSave(client *http.Client, base, token string, cmd *cobra.Command, name string) {
encrypt, _ := cmd.Flags().GetBool("encrypt")
tabID, _ := cmd.Flags().GetString("tab")
@@ -43,12 +44,11 @@ func StateSave(client *http.Client, base, token string, cmd *cobra.Command) {
}
// StateLoad supports exact name or prefix-based loading (most recent match).
-func StateLoad(client *http.Client, base, token string, cmd *cobra.Command) {
- name, _ := cmd.Flags().GetString("name")
+func StateLoad(client *http.Client, base, token string, cmd *cobra.Command, name string) {
tabID, _ := cmd.Flags().GetString("tab")
if name == "" {
- exitErr(1, "Error: --name is required")
+ exitErr(1, stateNameRequired)
}
body := map[string]any{
@@ -61,10 +61,9 @@ func StateLoad(client *http.Client, base, token string, cmd *cobra.Command) {
requireMap(apiclient.DoPost(client, base, token, "/state/load", body), 1, "Failed to load state")
}
-func StateShow(client *http.Client, base, token string, cmd *cobra.Command) {
- name, _ := cmd.Flags().GetString("name")
+func StateShow(client *http.Client, base, token string, name string) {
if name == "" {
- exitErr(1, "Error: --name is required")
+ exitErr(1, stateNameRequired)
}
params := url.Values{}
@@ -75,10 +74,9 @@ func StateShow(client *http.Client, base, token string, cmd *cobra.Command) {
printIndented(buf)
}
-func StateDelete(client *http.Client, base, token string, cmd *cobra.Command) {
- name, _ := cmd.Flags().GetString("name")
+func StateDelete(client *http.Client, base, token string, name string) {
if name == "" {
- exitErr(1, "Error: --name is required")
+ exitErr(1, stateNameRequired)
}
params := url.Values{}
diff --git a/internal/cli/actions/actions_storage.go b/internal/cli/actions/actions_storage.go
index 213c5195..b75dd57b 100644
--- a/internal/cli/actions/actions_storage.go
+++ b/internal/cli/actions/actions_storage.go
@@ -9,13 +9,13 @@ import (
)
// StorageGet retrieves localStorage and/or sessionStorage items for the active tab.
-func StorageGet(client *http.Client, base, token string, cmd *cobra.Command) {
+func StorageGet(client *http.Client, base, token string, cmd *cobra.Command, key string) {
params := url.Values{}
if t, _ := cmd.Flags().GetString("type"); t != "" {
params.Set("type", t)
}
- if k, _ := cmd.Flags().GetString("key"); k != "" {
- params.Set("key", k)
+ if key != "" {
+ params.Set("key", key)
}
if tab, _ := cmd.Flags().GetString("tab"); tab != "" {
params.Set("tabId", tab)
@@ -46,11 +46,21 @@ func StorageSet(client *http.Client, base, token string, cmd *cobra.Command, key
requireMap(apiclient.DoPost(client, base, token, "/storage", body), 1, "Failed to set storage item")
}
-// StorageDelete removes a storage item, clears a store, or clears both (--all).
-// It calls DELETE /storage so the server-side delete/clear handler is used.
-func StorageDelete(client *http.Client, base, token string, cmd *cobra.Command) {
+// StorageDelete removes a single storage key.
+func StorageDelete(client *http.Client, base, token string, cmd *cobra.Command, key string) {
+ if key == "" {
+ exitErr(1, `Error: storage delete needs a key; to wipe the whole store use "pinchtab storage clear"`)
+ }
+ deleteStorage(client, base, token, cmd, key)
+}
+
+// StorageClear clears storage (--type, or both stores with --all).
+func StorageClear(client *http.Client, base, token string, cmd *cobra.Command) {
+ deleteStorage(client, base, token, cmd, "")
+}
+
+func deleteStorage(client *http.Client, base, token string, cmd *cobra.Command, key string) {
storageType, _ := cmd.Flags().GetString("type")
- key, _ := cmd.Flags().GetString("key")
all, _ := cmd.Flags().GetBool("all")
tabID, _ := cmd.Flags().GetString("tab")
@@ -73,8 +83,3 @@ func StorageDelete(client *http.Client, base, token string, cmd *cobra.Command)
requireMap(apiclient.DoDeleteJSON(client, base, token, "/storage", body), 1, "Failed to delete storage")
}
-
-// StorageClear clears storage (alias: passes type=all or the given type).
-func StorageClear(client *http.Client, base, token string, cmd *cobra.Command) {
- StorageDelete(client, base, token, cmd)
-}
diff --git a/plugins/grok/skills/pinchtab/references/commands.md b/plugins/grok/skills/pinchtab/references/commands.md
index a214cd0e..e96985c6 100644
--- a/plugins/grok/skills/pinchtab/references/commands.md
+++ b/plugins/grok/skills/pinchtab/references/commands.md
@@ -319,22 +319,22 @@ Read and write `localStorage` and `sessionStorage` for the active tab's origin.
```bash
pinchtab storage get # both stores
pinchtab storage get --type local # one store
-pinchtab storage get --key token # a single item
+pinchtab storage get token # a single item
pinchtab storage set token abc123 # writes to localStorage by default
pinchtab storage set token abc123 --type session
-pinchtab storage delete --key token # remove one key
-pinchtab storage delete # no --key: clears the whole store
+pinchtab storage delete token # remove one key
+pinchtab storage clear # wipe localStorage (--type session for the other store)
pinchtab storage clear --all # both stores in one call
```
| Flag | Command | Description |
|------|---------|-------------|
| `--type <local\|session>` | `get`, `set`, `delete`, `clear` | Which store. `get` defaults to both; the write verbs default to `local` |
-| `--key <key>` | `get`, `delete` | `get`: return only this item. `delete`: the key to remove — omit it and the whole store is cleared |
+| `--key <key>` | `get`, `delete` | Same as the `<key>` argument; give one or the other, never both |
| `--all` | `clear` | Clear both stores in one call |
| `--tab <id>` | all | Target a specific tab |
-`storage delete` with no `--key` clears the whole store `--type` selects — localStorage unless you pass `--type session` — for the tab's origin. It is the same call `storage clear` makes. `--all` is registered on `clear` only: `clear --all` empties both stores, while `delete --all` is refused as an unknown flag. `storage clear` without `--all` clears localStorage alone.
+`storage delete` needs a key: a bare `storage delete` is refused and names `storage clear`, which is the only verb that wipes a store. `storage clear` clears the store `--type` selects — localStorage unless you pass `--type session` — for the tab's origin, and `clear --all` empties both. `--all` is registered on `clear` only; `delete --all` is refused as an unknown flag.
---
diff --git a/skills/pinchtab/references/commands.md b/skills/pinchtab/references/commands.md
index a214cd0e..e96985c6 100644
--- a/skills/pinchtab/references/commands.md
+++ b/skills/pinchtab/references/commands.md
@@ -319,22 +319,22 @@ Read and write `localStorage` and `sessionStorage` for the active tab's origin.
```bash
pinchtab storage get # both stores
pinchtab storage get --type local # one store
-pinchtab storage get --key token # a single item
+pinchtab storage get token # a single item
pinchtab storage set token abc123 # writes to localStorage by default
pinchtab storage set token abc123 --type session
-pinchtab storage delete --key token # remove one key
-pinchtab storage delete # no --key: clears the whole store
+pinchtab storage delete token # remove one key
+pinchtab storage clear # wipe localStorage (--type session for the other store)
pinchtab storage clear --all # both stores in one call
```
| Flag | Command | Description |
|------|---------|-------------|
| `--type <local\|session>` | `get`, `set`, `delete`, `clear` | Which store. `get` defaults to both; the write verbs default to `local` |
-| `--key <key>` | `get`, `delete` | `get`: return only this item. `delete`: the key to remove — omit it and the whole store is cleared |
+| `--key <key>` | `get`, `delete` | Same as the `<key>` argument; give one or the other, never both |
| `--all` | `clear` | Clear both stores in one call |
| `--tab <id>` | all | Target a specific tab |
-`storage delete` with no `--key` clears the whole store `--type` selects — localStorage unless you pass `--type session` — for the tab's origin. It is the same call `storage clear` makes. `--all` is registered on `clear` only: `clear --all` empties both stores, while `delete --all` is refused as an unknown flag. `storage clear` without `--all` clears localStorage alone.
+`storage delete` needs a key: a bare `storage delete` is refused and names `storage clear`, which is the only verb that wipes a store. `storage clear` clears the store `--type` selects — localStorage unless you pass `--type session` — for the tab's origin, and `clear --all` empties both. `--all` is registered on `clear` only; `delete --all` is refused as an unknown flag.
---