Skip to content

Commit 7f8d7f0

Browse files
committed
interactive prompt enhancements for the registry and vulnerability commands
Signed-off-by: Kyle Quest <[email protected]>
1 parent ba25cc0 commit 7f8d7f0

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

pkg/app/master/command/cliprompt.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ var GlobalFlagSuggestions = []prompt.Suggest{
359359
{Text: FullFlagName(FlagLogLevel), Description: FlagLogLevelUsage},
360360
{Text: FullFlagName(FlagLog), Description: FlagLogUsage},
361361
{Text: FullFlagName(FlagLogFormat), Description: FlagLogFormatUsage},
362+
{Text: FullFlagName(FlagQuietCLIMode), Description: FlagQuietCLIModeUsage},
362363
{Text: FullFlagName(FlagOutputFormat), Description: FlagOutputFormatUsage},
363364
{Text: FullFlagName(FlagUseTLS), Description: FlagUseTLSUsage},
364365
{Text: FullFlagName(FlagVerifyTLS), Description: FlagVerifyTLSUsage},
@@ -371,6 +372,8 @@ var GlobalFlagSuggestions = []prompt.Suggest{
371372
}
372373

373374
var GlobalFlagValueSuggestions = map[string]CompleteValue{
375+
FullFlagName(FlagQuietCLIMode): CompleteBool,
376+
FullFlagName(FlagOutputFormat): CompleteOutputFormat,
374377
FullFlagName(FlagDebug): CompleteBool,
375378
FullFlagName(FlagVerbose): CompleteBool,
376379
FullFlagName(FlagNoColor): CompleteBool,
@@ -434,7 +437,7 @@ func CompleteContinueAfter(ia *InteractiveApp, token string, params prompt.Docum
434437
return prompt.FilterHasPrefix(continueAfterValues, token, true)
435438
}
436439

437-
func CompleteConsoleOutput(ia *InteractiveApp, token string, params prompt.Document) []prompt.Suggest {
440+
func CompleteOutputFormat(ia *InteractiveApp, token string, params prompt.Document) []prompt.Suggest {
438441
return prompt.FilterHasPrefix(consoleOutputValues, token, true)
439442
}
440443

pkg/app/master/command/registry/prompt.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ package registry
22

33
import (
44
"github.com/c-bata/go-prompt"
5+
6+
"github.com/slimtoolkit/slim/pkg/app/master/command"
57
)
68

79
var CommandSuggestion = prompt.Suggest{
810
Text: Name,
911
Description: Usage,
1012
}
13+
14+
var CommandFlagSuggestions = &command.FlagSuggestions{
15+
Names: []prompt.Suggest{
16+
{Text: command.FullFlagName(FlagUseDockerCreds), Description: FlagUseDockerCredsUsage},
17+
{Text: command.FullFlagName(FlagCredsAccount), Description: FlagCredsAccountUsage},
18+
{Text: command.FullFlagName(FlagCredsSecret), Description: FlagCredsSecretUsage},
19+
//including sub-commands here too
20+
{Text: PullCmdName, Description: PullCmdNameUsage},
21+
{Text: PushCmdName, Description: PushCmdNameUsage},
22+
{Text: ImageIndexCreateCmdName, Description: ImageIndexCreateCmdNameUsage},
23+
{Text: ServerCmdName, Description: ServerCmdNameUsage},
24+
},
25+
Values: map[string]command.CompleteValue{},
26+
}

pkg/app/master/command/registry/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ func RegisterCommand() {
99
Name,
1010
CLI,
1111
CommandSuggestion,
12-
nil)
12+
CommandFlagSuggestions)
1313
}

pkg/app/master/command/vulnerability/prompt.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ package vulnerability
22

33
import (
44
"github.com/c-bata/go-prompt"
5+
6+
"github.com/slimtoolkit/slim/pkg/app/master/command"
57
)
68

79
var CommandSuggestion = prompt.Suggest{
810
Text: Name,
911
Description: Usage,
1012
}
13+
14+
var CommandFlagSuggestions = &command.FlagSuggestions{
15+
Names: []prompt.Suggest{
16+
{Text: command.FullFlagName(FlagCVE), Description: FlagCVEUsage},
17+
//including sub-commands here too
18+
{Text: EpssCmdName, Description: EpssCmdNameUsage},
19+
},
20+
Values: map[string]command.CompleteValue{},
21+
}

pkg/app/master/command/vulnerability/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ func RegisterCommand() {
99
Name,
1010
CLI,
1111
CommandSuggestion,
12-
nil)
12+
CommandFlagSuggestions)
1313
}

0 commit comments

Comments
 (0)