@@ -19,7 +19,11 @@ func newSecretCommand() *cobra.Command {
19
19
cmd := & cobra.Command {
20
20
Use : "secret" ,
21
21
Short : "Manage secrets" ,
22
- Long : "The secret command provides subcommands to set, get, delete, and list secrets." ,
22
+ Long : `Manage secrets using the configured secrets provider.
23
+
24
+ The secret command provides subcommands to configure, store, retrieve, and manage secrets securely.
25
+
26
+ Run "thv secret setup" first to configure a secrets provider before using any secret operations.` ,
23
27
}
24
28
25
29
cmd .AddCommand (
@@ -38,12 +42,18 @@ func newSecretCommand() *cobra.Command {
38
42
func newSecretProviderCommand () * cobra.Command {
39
43
return & cobra.Command {
40
44
Use : "provider <name>" ,
41
- Short : "Configure the secrets provider directly" ,
42
- Long : `For most users, it is recommended to use "thv secret setup" instead.
43
- Configure the secrets provider.
44
- Valid secrets providers are:
45
- - encrypted: Full read-write secrets provider
46
- - 1password: Read-only secrets provider` ,
45
+ Short : "Set the secrets provider directly" ,
46
+ Long : `Configure the secrets provider directly.
47
+
48
+ Note: The "thv secret setup" command is recommended for interactive configuration.
49
+
50
+ Use this command to set the secrets provider directly without interactive prompts,
51
+ making it suitable for scripted deployments and automation.
52
+
53
+ Valid secrets providers:
54
+ - encrypted: Full read-write secrets provider using AES-256-GCM encryption
55
+ - 1password: Read-only secrets provider (requires OP_SERVICE_ACCOUNT_TOKEN)
56
+ - none: Disables secrets functionality` ,
47
57
Args : cobra .ExactArgs (1 ),
48
58
RunE : func (_ * cobra.Command , args []string ) error {
49
59
provider := args [0 ]
@@ -57,15 +67,17 @@ func newSecretSetupCommand() *cobra.Command {
57
67
Use : "setup" ,
58
68
Short : "Set up secrets provider" ,
59
69
Long : fmt .Sprintf (`Interactive setup for configuring a secrets provider.
60
- This command will guide you through selecting and configuring
61
- a secrets provider for storing and retrieving secrets.
70
+
71
+ This command guides you through selecting and configuring a secrets provider
72
+ for storing and retrieving secrets. The setup process validates your
73
+ configuration and ensures the selected provider initializes properly.
62
74
63
75
Available providers:
64
- - %s: Stores secrets in an encrypted file using AES-256-GCM using the OS Keyring
65
- - %s: Read-only access to 1Password secrets (requires OP_SERVICE_ACCOUNT_TOKEN)
76
+ - %s: Stores secrets in an encrypted file using AES-256-GCM using the OS keyring
77
+ - %s: Read-only access to 1Password secrets (requires OP_SERVICE_ACCOUNT_TOKEN environment variable )
66
78
- %s: Disables secrets functionality
67
79
68
- You must run this command before using any other secrets functionality.` ,
80
+ Run this command before using any other secrets functionality.` ,
69
81
string (secrets .EncryptedType ), string (secrets .OnePasswordType ), string (secrets .NoneType )), //nolint:gofmt,gci
70
82
Args : cobra .NoArgs ,
71
83
RunE : runSecretsSetup ,
@@ -76,21 +88,29 @@ func newSecretSetCommand() *cobra.Command {
76
88
return & cobra.Command {
77
89
Use : "set <name>" ,
78
90
Short : "Set a secret" ,
79
- Long : `Set a secret with the given name.
80
-
81
- Input Methods:
82
- - Piped Input: If data is piped to the command, the secret value will be read from stdin.
83
- Examples:
84
- echo "my-secret-value" | thv secret set my-secret
85
- cat secret-file.txt | thv secret set my-secret
86
-
87
- - Interactive Input: If no data is piped, you will be prompted to enter the secret value securely
88
- (input will be hidden).
89
- Example:
90
- thv secret set my-secret
91
- Enter secret value (input will be hidden): _
92
-
93
- The secret will be stored securely using the configured secrets provider.` ,
91
+ Long : `Create or update a secret with the specified name.
92
+
93
+ This command supports two input methods for maximum flexibility:
94
+
95
+ Piped input:
96
+
97
+ When you pipe data to the command, it reads the secret value from stdin.
98
+ Examples:
99
+
100
+ $ echo "my-secret-value" | thv secret set my-secret
101
+ $ cat secret-file.txt | thv secret set my-secret
102
+
103
+ Interactive input:
104
+
105
+ When you don't pipe data, the command prompts you to enter the secret value securely.
106
+ The input remains hidden for security.
107
+ Example:
108
+
109
+ $ thv secret set my-secret
110
+ Enter secret value (input will be hidden): _
111
+
112
+ The command stores the secret securely using your configured secrets provider.
113
+ Note that some providers (like 1Password) are read-only and do not support setting secrets.` ,
94
114
Args : cobra .ExactArgs (1 ),
95
115
Run : func (cmd * cobra.Command , args []string ) {
96
116
name := args [0 ]
@@ -166,7 +186,14 @@ func newSecretGetCommand() *cobra.Command {
166
186
return & cobra.Command {
167
187
Use : "get <name>" ,
168
188
Short : "Get a secret" ,
169
- Args : cobra .ExactArgs (1 ),
189
+ Long : `Retrieve and display the value of a secret by name.
190
+
191
+ This command fetches the specified secret from your configured secrets provider
192
+ and displays its value. The secret value prints to stdout, making it
193
+ suitable for use in scripts or command substitution.
194
+
195
+ The secret must exist in your configured secrets provider, otherwise the command returns an error.` ,
196
+ Args : cobra .ExactArgs (1 ),
170
197
Run : func (cmd * cobra.Command , args []string ) {
171
198
ctx := cmd .Context ()
172
199
name := args [0 ]
@@ -197,7 +224,14 @@ func newSecretDeleteCommand() *cobra.Command {
197
224
return & cobra.Command {
198
225
Use : "delete <name>" ,
199
226
Short : "Delete a secret" ,
200
- Args : cobra .ExactArgs (1 ),
227
+ Long : `Remove a secret from the configured secrets provider.
228
+
229
+ This command permanently deletes the specified secret from your secrets provider.
230
+ Once you delete a secret, you cannot recover it unless you have a backup.
231
+
232
+ Note that some secrets providers may not support deletion operations.
233
+ If your provider is read-only or doesn't support deletion, this command returns an error.` ,
234
+ Args : cobra .ExactArgs (1 ),
201
235
Run : func (cmd * cobra.Command , args []string ) {
202
236
ctx := cmd .Context ()
203
237
name := args [0 ]
@@ -235,7 +269,11 @@ func newSecretListCommand() *cobra.Command {
235
269
return & cobra.Command {
236
270
Use : "list" ,
237
271
Short : "List all available secrets" ,
238
- Args : cobra .NoArgs ,
272
+ Long : `Display all secrets available in the configured secrets provider.
273
+
274
+ This command shows the names of all secrets stored in your secrets provider.
275
+ If descriptions exist for the secrets, the command displays them alongside the names.` ,
276
+ Args : cobra .NoArgs ,
239
277
Run : func (cmd * cobra.Command , _ []string ) {
240
278
ctx := cmd .Context ()
241
279
manager , err := getSecretsManager ()
@@ -278,8 +316,23 @@ func newSecretListCommand() *cobra.Command {
278
316
func newSecretResetKeyringCommand () * cobra.Command {
279
317
return & cobra.Command {
280
318
Use : "reset-keyring" ,
281
- Short : "Reset the keyring secret" ,
282
- Args : cobra .NoArgs ,
319
+ Short : "Reset the keyring password" ,
320
+ Long : `Reset the keyring password used to encrypt secrets.
321
+
322
+ This command resets the master password stored in your OS keyring that
323
+ encrypts and decrypts secrets when using the 'encrypted' secrets provider.
324
+
325
+ Use this command if:
326
+ - You've forgotten your keyring password
327
+ - You want to change your encryption password
328
+ - Your keyring has become corrupted
329
+
330
+ Warning: Resetting the keyring password makes any existing encrypted secrets
331
+ inaccessible unless you remember the previous password. You will need to set up
332
+ your secrets again after resetting.
333
+
334
+ This command only works with the 'encrypted' secrets provider.` ,
335
+ Args : cobra .NoArgs ,
283
336
Run : func (_ * cobra.Command , _ []string ) {
284
337
if err := secrets .ResetKeyringSecret (); err != nil {
285
338
fmt .Fprintf (os .Stderr , "Failed to reset keyring secret: %v\n " , err )
0 commit comments