Skip to content

Commit e5a715e

Browse files
rkpattnaik780Enda Phelan
authored andcommitted
fix: prompts for interactive mode
1 parent 8a6fcdf commit e5a715e

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

pkg/cmd/registry/rule/enable/enable.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
1919
"github.com/spf13/cobra"
2020

21+
artifactutil "github.com/redhat-developer/app-services-cli/pkg/cmd/registry/artifact/util"
22+
2123
registryinstanceclient "github.com/redhat-developer/app-services-sdk-go/registryinstance/apiv1internal/client"
2224
)
2325

@@ -231,5 +233,36 @@ func runInteractivePrompt(opts *options) (err error) {
231233
return err
232234
}
233235

236+
instanceIDPrompt := &survey.Input{
237+
Message: opts.localizer.MustLocalize("registry.rule.enable.input.instanceID.message"),
238+
Help: opts.localizer.MustLocalize("registry.rule.enable.input.instanceID.help"),
239+
}
240+
241+
err = survey.AskOne(instanceIDPrompt, &opts.registryID)
242+
if err != nil {
243+
return err
244+
}
245+
246+
artifactIDPrompt := &survey.Input{
247+
Message: opts.localizer.MustLocalize("registry.rule.enable.input.artifactID.message"),
248+
Help: opts.localizer.MustLocalize("registry.rule.enable.input.artifactID.help"),
249+
}
250+
251+
err = survey.AskOne(artifactIDPrompt, &opts.artifactID)
252+
if err != nil {
253+
return err
254+
}
255+
256+
groupPrompt := &survey.Input{
257+
Message: opts.localizer.MustLocalize("registry.rule.enable.input.group.message"),
258+
Help: opts.localizer.MustLocalize("registry.rule.enable.input.group.help"),
259+
Default: artifactutil.DefaultArtifactGroup,
260+
}
261+
262+
err = survey.AskOne(groupPrompt, &opts.group)
263+
if err != nil {
264+
return err
265+
}
266+
234267
return nil
235268
}

pkg/core/localize/locales/en/cmd/rule.en.toml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,25 @@ one='Rule type determines how the content of an artifact can evolve over time'
5555
one='Config:'
5656

5757
[registry.rule.common.flag.config]
58-
one='Configuration value for a rule'
58+
one='Configuration value for a rule'
59+
60+
[registry.rule.enable.input.instanceID.message]
61+
one='Instance ID:'
62+
63+
[registry.rule.enable.input.instanceID.help]
64+
one='ID of the Service Registry instance to be used. Leave blank to use the currently selected instance'
65+
66+
[registry.rule.enable.input.artifactID.message]
67+
one='Artifact ID:'
68+
69+
[registry.rule.enable.input.artifactID.help]
70+
one='ID of the artifact. Leave blank for global rule'
71+
72+
[registry.rule.enable.input.group.message]
73+
one='Group:'
74+
75+
[registry.rule.enable.input.group.help]
76+
one='Artifact group. Leave blank for global rule'
5977

6078
[registry.rule.common.error.invalidRuleConfig]
6179
one = 'invalid configuration value "{{.Config}}" for rule type "{{.RuleType}}". Valid operations are: {{.ValidConfigList}}'

0 commit comments

Comments
 (0)