-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add multi-profile credential support #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
87648d3
c70a4e6
07b0621
70a4d7c
c4ab908
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/solapi/solactl/pkg/config" | ||
| ) | ||
|
|
||
| func init() { | ||
| configureCmd.AddCommand(&cobra.Command{ | ||
| Use: "delete <profile>", | ||
| Short: "저장된 프로필을 삭제합니다", | ||
| Args: cobra.ExactArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| profileName := args[0] | ||
|
|
||
| if err := config.DeleteProfile(profileName); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| _, _ = fmt.Fprintf(errOut(), "프로필 '%s'이(가) 삭제되었습니다.\n", profileName) | ||
| return nil | ||
| }, | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/solapi/solactl/pkg/config" | ||
| ) | ||
|
|
||
| func init() { | ||
| configureCmd.AddCommand(&cobra.Command{ | ||
| Use: "list", | ||
| Short: "저장된 프로필 목록을 표시합니다", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| profiles, err := config.ListProfiles() | ||
| if err != nil { | ||
| if os.IsNotExist(err) { | ||
| _, _ = fmt.Fprintf(errOut(), "프로필이 없습니다. 'solactl configure'를 실행하세요.\n") | ||
| return nil | ||
| } | ||
| return fmt.Errorf("프로필 목록 조회 실패: %w", err) | ||
| } | ||
|
Comment on lines
+18
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation swallows all errors from if err != nil {
if os.IsNotExist(err) {
_, _ = fmt.Fprintf(errOut(), "프로필이 없습니다. 'solactl configure'를 실행하세요.\n")
return nil
}
return err
} |
||
|
|
||
| if len(profiles) == 0 { | ||
| _, _ = fmt.Fprintf(errOut(), "프로필이 없습니다. 'solactl configure'를 실행하세요.\n") | ||
| return nil | ||
| } | ||
|
|
||
| p := printer() | ||
| for _, prof := range profiles { | ||
| active := "" | ||
| if prof.Active { | ||
| active = " *" | ||
| } | ||
| p.PrintKeyValue( | ||
| "Profile", prof.Name+active, | ||
| "API Key", prof.Config.APIKey, | ||
| "API Secret", config.MaskSecret(prof.Config.APISecret), | ||
| ) | ||
| _, _ = fmt.Fprintln(out()) | ||
| } | ||
| return nil | ||
| }, | ||
| }) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ospackage needs to be imported to check for file existence errors usingos.IsNotExist.