@@ -3,6 +3,8 @@ package main
33import (
44 "encoding/json"
55 "fmt"
6+ "os"
7+ "strings"
68
79 "github.com/onecli/onecli-cli/internal/api"
810 "github.com/onecli/onecli-cli/pkg/output"
@@ -45,8 +47,9 @@ func (c *OrgSecretsListCmd) Run(out *output.Writer) error {
4547// OrgSecretsCreateCmd is `onecli org secrets create`.
4648type OrgSecretsCreateCmd struct {
4749 Name string `required:"" help:"Display name for the secret."`
48- Type string `required:"" help:"Secret type: 'anthropic', 'openai', or 'generic'."`
49- Value string `required:"" help:"Secret value (e.g. API key)."`
50+ Type string `required:"" help:"Secret type: 'anthropic', 'openai', 'codex', or 'generic'."`
51+ Value string `optional:"" help:"Secret value (e.g. API key). Required unless --file is provided."`
52+ File string `optional:"" name:"file" type:"existingfile" help:"Read secret value from a file (e.g. ~/.codex/auth.json)."`
5053 HostPattern string `required:"" name:"host-pattern" help:"Host pattern to match (e.g. 'api.anthropic.com')."`
5154 PathPattern string `optional:"" name:"path-pattern" help:"Path pattern to match (e.g. '/v1/*')."`
5255 HeaderName string `optional:"" name:"header-name" help:"Header name for injection (e.g. 'Authorization')."`
@@ -64,13 +67,27 @@ func (c *OrgSecretsCreateCmd) Run(out *output.Writer) error {
6467 return fmt .Errorf ("invalid JSON payload: %w" , err )
6568 }
6669 } else {
70+ if c .Value != "" && c .File != "" {
71+ return fmt .Errorf ("--value and --file are mutually exclusive" )
72+ }
6773 if c .HeaderName != "" && c .ParamName != "" {
6874 return fmt .Errorf ("--header-name and --param-name are mutually exclusive" )
6975 }
76+ value := c .Value
77+ if c .File != "" {
78+ data , err := os .ReadFile (c .File )
79+ if err != nil {
80+ return fmt .Errorf ("reading file %s: %w" , c .File , err )
81+ }
82+ value = strings .TrimSpace (string (data ))
83+ }
84+ if value == "" {
85+ return fmt .Errorf ("either --value or --file is required" )
86+ }
7087 input = api.CreateSecretInput {
7188 Name : c .Name ,
7289 Type : c .Type ,
73- Value : c . Value ,
90+ Value : value ,
7491 HostPattern : c .HostPattern ,
7592 PathPattern : c .PathPattern ,
7693 }
@@ -87,8 +104,8 @@ func (c *OrgSecretsCreateCmd) Run(out *output.Writer) error {
87104 }
88105 }
89106
90- if input .Type != "anthropic" && input .Type != "openai" && input .Type != "generic" {
91- return fmt .Errorf ("invalid type %q: must be 'anthropic', 'openai', or 'generic'" , input .Type )
107+ if input .Type != "anthropic" && input .Type != "openai" && input .Type != "codex" && input . Type != " generic" {
108+ return fmt .Errorf ("invalid type %q: must be 'anthropic', 'openai', 'codex', or 'generic'" , input .Type )
92109 }
93110
94111 if c .DryRun {
0 commit comments