Skip to content

Commit c2929e5

Browse files
committed
PR feedback
Signed-off-by: Grant Linville <[email protected]>
1 parent ce7d238 commit c2929e5

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

docs/docs/03-tools/04-credentials.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name: my-credential-tool
1818

1919
#!/usr/bin/env bash
2020

21-
output=$(gptscript -q --cache=false sys.prompt '{"message":"Please enter your fake credential.","fields":"credential"}')
21+
output=$(gptscript -q --cache=false sys.prompt '{"message":"Please enter your fake credential.","fields":"credential","sensitive":"true"}')
2222
credential=$(echo $output | jq -r '.credential')
2323
echo "{\"env\":{\"MY_ENV_VAR\":\"$credential\"}}"
2424
```
@@ -76,11 +76,11 @@ context is basically a namespace for credentials. If you have multiple credentia
7676
switch between them by defining them in different credential contexts. The default context is called `default`, and this
7777
is used if none is specified.
7878

79-
You can set the credential context to use with the `--credential-context` or `-c` flag when running GPTScript. For
79+
You can set the credential context to use with the `--credential-context` flag when running GPTScript. For
8080
example:
8181

8282
```bash
83-
gptscript -c my-azure-workspace my-azure-script.gpt
83+
gptscript --credential-context my-azure-workspace my-azure-script.gpt
8484
```
8585

8686
Any credentials fetched for that script will be stored in the `my-azure-workspace` context. If you were to call it again
@@ -89,11 +89,11 @@ with a different context, you would be able to give it a different set of creden
8989
## Listing and Deleting Stored Credentials
9090

9191
The `gptscript credential` command can be used to list and delete stored credentials. Running the command with no
92-
`--credential-context` (or `-c`) set will use the `default` credential context. You can also specify that it should list
93-
credentials in all contexts with `--all-contexts` or `-A`.
92+
`--credential-context` set will use the `default` credential context. You can also specify that it should list
93+
credentials in all contexts with `--all-contexts`.
9494

9595
You can delete a credential by running the following command:
9696

9797
```bash
98-
gptscript credential delete -c <credential context> <credential tool name>
98+
gptscript credential delete --credential-context <credential context> <credential tool name>
9999
```

pkg/cli/credential.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@ import (
66
"sort"
77
"text/tabwriter"
88

9-
"github.com/acorn-io/cmd"
9+
cmd2 "github.com/acorn-io/cmd"
1010
"github.com/gptscript-ai/gptscript/pkg/config"
1111
"github.com/gptscript-ai/gptscript/pkg/credentials"
12+
"github.com/gptscript-ai/gptscript/pkg/version"
1213
"github.com/spf13/cobra"
1314
)
1415

1516
type Credential struct {
1617
root *GPTScript
17-
AllContexts bool `short:"A" usage:"List credentials for all contexts" local:"true"`
18+
AllContexts bool `usage:"List credentials for all contexts" local:"true"`
1819
}
1920

20-
func NewCredential(root *GPTScript) *cobra.Command {
21-
c := cmd.Command(&Credential{root: root}, cobra.Command{
22-
Use: "credential",
23-
Aliases: []string{"cred", "creds", "credentials"},
24-
Short: "List stored credentials",
25-
Args: cobra.NoArgs,
26-
})
27-
c.AddCommand(NewDelete(root))
28-
return c
21+
func (c *Credential) Customize(cmd *cobra.Command) {
22+
cmd.Use = "credential"
23+
cmd.Version = version.Get().String()
24+
cmd.Aliases = []string{"cred", "creds", "credentials"}
25+
cmd.Short = "List stored credentials"
26+
cmd.Args = cobra.NoArgs
27+
cmd.AddCommand(cmd2.Command(&Delete{root: c.root}))
2928
}
3029

3130
func (c *Credential) Run(_ *cobra.Command, _ []string) error {

pkg/cli/credential_delete.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli
33
import (
44
"fmt"
55

6-
"github.com/acorn-io/cmd"
76
"github.com/gptscript-ai/gptscript/pkg/config"
87
"github.com/gptscript-ai/gptscript/pkg/credentials"
98
"github.com/spf13/cobra"
@@ -13,13 +12,11 @@ type Delete struct {
1312
root *GPTScript
1413
}
1514

16-
func NewDelete(root *GPTScript) *cobra.Command {
17-
return cmd.Command(&Delete{root: root}, cobra.Command{
18-
Use: "delete <tool name>",
19-
SilenceUsage: true,
20-
Short: "Delete a stored credential",
21-
Args: cobra.ExactArgs(1),
22-
})
15+
func (c *Delete) Customize(cmd *cobra.Command) {
16+
cmd.Use = "delete <tool name>"
17+
cmd.SilenceUsage = true
18+
cmd.Short = "Delete a stored credential"
19+
cmd.Args = cobra.ExactArgs(1)
2320
}
2421

2522
func (c *Delete) Run(_ *cobra.Command, args []string) error {

pkg/cli/gptscript.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ type GPTScript struct {
5353
Chdir string `usage:"Change current working directory" short:"C"`
5454
Daemon bool `usage:"Run tool as a daemon" local:"true" hidden:"true"`
5555
Ports string `usage:"The port range to use for ephemeral daemon ports (ex: 11000-12000)" hidden:"true"`
56-
CredentialContext string `usage:"Context name in which to store credentials" default:"default" short:"c"`
56+
CredentialContext string `usage:"Context name in which to store credentials" default:"default"`
5757
}
5858

5959
func New() *cobra.Command {
6060
root := &GPTScript{}
6161
return cmd.Command(root, &Eval{
6262
gptscript: root,
63-
}, NewCredential(root))
63+
}, &Credential{root: root})
6464
}
6565

6666
func (r *GPTScript) NewRunContext(cmd *cobra.Command) context.Context {

pkg/gptscript/gptscript.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Options struct {
2626
OpenAI openai.Options
2727
Monitor monitor.Options
2828
Runner runner.Options
29-
CredentialContext string `usage:"Context name in which to store credentials" default:"default" short:"c"`
29+
CredentialContext string `usage:"Context name in which to store credentials" default:"default"`
3030
Quiet *bool `usage:"No output logging (set --quiet=false to force on even when there is no TTY)" short:"q"`
3131
Env []string `usage:"-"`
3232
}

0 commit comments

Comments
 (0)