Skip to content

Commit 23e2bb1

Browse files
remyleonejerome-quere
authored andcommitted
feat(config): add simple get extraction
1 parent 766cab4 commit 23e2bb1

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

internal/namespaces/config/commands.go

+13-27
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ func configGetCommand() *core.Command {
114114
},
115115
},
116116
Run: func(ctx context.Context, argsI interface{}) (i interface{}, e error) {
117-
// profileKeyValue is a custom type used for displaying configGetCommand result
118-
type profileKeyValue struct {
119-
Profile string `json:"profile"`
120-
Key string `json:"key"`
121-
Value string `json:"value"`
122-
}
123-
124117
config, err := scw.LoadConfig()
125118
if err != nil {
126119
return nil, err
@@ -129,27 +122,20 @@ func configGetCommand() *core.Command {
129122
if len(rawArgs) == 0 {
130123
return nil, notEnoughArgsForConfigGetError()
131124
}
132-
profileKeyValues := []*profileKeyValue(nil)
133-
for _, arg := range rawArgs {
134-
profileName, key, err := splitProfileKey(arg)
135-
if err != nil {
136-
return nil, err
137-
}
138-
profile, err := getProfile(config, profileName)
139-
if err != nil {
140-
return nil, err
141-
}
142-
value, err := getProfileValue(profile, key)
143-
if err != nil {
144-
return nil, err
145-
}
146-
profileKeyValues = append(profileKeyValues, &profileKeyValue{
147-
Profile: profileName,
148-
Key: key,
149-
Value: value,
150-
})
125+
126+
profileName, key, err := splitProfileKey(rawArgs.GetPositionalArgs()[0])
127+
if err != nil {
128+
return nil, err
129+
}
130+
profile, err := getProfile(config, profileName)
131+
if err != nil {
132+
return nil, err
133+
}
134+
value, err := getProfileValue(profile, key)
135+
if err != nil {
136+
return nil, err
151137
}
152-
return profileKeyValues, nil
138+
return value, nil
153139
},
154140
}
155141
}

0 commit comments

Comments
 (0)