Skip to content

Commit

Permalink
update: add apikey to every subcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
dantegarden committed Oct 8, 2024
1 parent d6fbb93 commit 9c5efe5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 15 deletions.
1 change: 1 addition & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func Init() *cli.App {
app.Flags = []cli.Flag{
&verboseFlag,
&baseDomainFlag,
&apiKeyFlag,
}

// Commands
Expand Down
11 changes: 8 additions & 3 deletions cmd/ls_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ func ListModel(c *cli.Context) error {
return err
}

apiKey, err := lib.NewSfFolder().GetKey()
if err != nil {
return err
var apiKey string
if args.ApiKey != "" {
apiKey = args.ApiKey
} else {
apiKey, err = lib.NewSfFolder().GetKey()
if err != nil {
return err
}
}

client := lib.NewClient(args.BaseDomain, apiKey)
Expand Down
11 changes: 8 additions & 3 deletions cmd/lsfiles_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ func ListFilesModel(c *cli.Context) error {
return err
}

apiKey, err := lib.NewSfFolder().GetKey()
if err != nil {
return err
var apiKey string
if args.ApiKey != "" {
apiKey = args.ApiKey
} else {
apiKey, err = lib.NewSfFolder().GetKey()
if err != nil {
return err
}
}

client := lib.NewClient(args.BaseDomain, apiKey)
Expand Down
11 changes: 8 additions & 3 deletions cmd/rm_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ func RemoveModel(c *cli.Context) error {
return err
}

apiKey, err := lib.NewSfFolder().GetKey()
if err != nil {
return err
var apiKey string
if args.ApiKey != "" {
apiKey = args.ApiKey
} else {
apiKey, err = lib.NewSfFolder().GetKey()
if err != nil {
return err
}
}

client := lib.NewClient(args.BaseDomain, apiKey)
Expand Down
11 changes: 8 additions & 3 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ func Upload(c *cli.Context) error {
return cli.Exit(fmt.Errorf("check path failed: %s", err), meta.LoadError)
}

apiKey, err := lib.NewSfFolder().GetKey()
if err != nil {
return err
var apiKey string
if args.ApiKey != "" {
apiKey = args.ApiKey
} else {
apiKey, err = lib.NewSfFolder().GetKey()
if err != nil {
return err
}
}

client := lib.NewClient(args.BaseDomain, apiKey)
Expand Down
11 changes: 8 additions & 3 deletions cmd/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ func Whoami(c *cli.Context) error {
setLogVerbose(args.Verbose)
logs.Debugf("args: %#v\n", args)

apiKey, err := lib.NewSfFolder().GetKey()
if err != nil {
return err
var apiKey string
if args.ApiKey != "" {
apiKey = args.ApiKey
} else {
apiKey, err = lib.NewSfFolder().GetKey()
if err != nil {
return err
}
}

client := lib.NewClient(meta.AuthDomain, apiKey)
Expand Down
2 changes: 2 additions & 0 deletions meta/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
TypeClip UploadFileType = "bizyair/clip"
TypeClipVision UploadFileType = "bizyair/clip_vision"
TypeUpscale UploadFileType = "bizyair/upscale"
TypeDataset UploadFileType = "bizyair/dataset"
TypeOther UploadFileType = "other"
)

Expand All @@ -52,6 +53,7 @@ var ModelTypes = []UploadFileType{
TypeClip,
TypeClipVision,
TypeUpscale,
TypeDataset,
TypeOther,
}

Expand Down

0 comments on commit 9c5efe5

Please sign in to comment.