Skip to content
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

apps, apis, rules: first stab at generalizing picker options [CLI-82] #182

Merged
merged 11 commits into from
Mar 24, 2021

Conversation

cyx
Copy link
Contributor

@cyx cyx commented Mar 23, 2021

Description

  • Refactors the rules picker to be generic
  • Adds picker for apps
  • Adds picker for apis

Demo

asciicast

This is mostly an internal only change which extracts the behavior of
having `pickers`.

== TODO

- [ ] Try it out with apps
- [ ] Try it out with apis
@@ -0,0 +1,32 @@
package cli

type pickerOptions []pickerOption
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous iteration using maps had an undesirable behavior that options get randomized on every run. Formalizing this data structure to a list to have a deterministic order -- but also having methods on the list simplifies the call sites.

internal/cli/arguments.go Outdated Show resolved Hide resolved
@Widcket

This comment has been minimized.

@cyx cyx force-pushed the rule-generalize-picker-options branch from 4ef31b2 to 6520c3a Compare March 23, 2021 23:19
@cyx cyx force-pushed the rule-generalize-picker-options branch from 6520c3a to f6ef9a8 Compare March 23, 2021 23:32
@cyx cyx changed the title Rules: first stab at generalizing picker options apps, apis, rules: first stab at generalizing picker options Mar 23, 2021
internal/cli/arguments.go Outdated Show resolved Hide resolved
internal/cli/arguments.go Outdated Show resolved Hide resolved
internal/cli/rules.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only some small things to address.

internal/cli/apps.go Outdated Show resolved Hide resolved
internal/cli/apps.go Outdated Show resolved Hide resolved
internal/cli/apps.go Outdated Show resolved Hide resolved
internal/cli/apis.go Outdated Show resolved Hide resolved
internal/cli/apis.go Outdated Show resolved Hide resolved
internal/cli/apis.go Outdated Show resolved Hide resolved
internal/cli/apis.go Outdated Show resolved Hide resolved

return fmt.Errorf("Missing a required argument: %s", a.GetName())
}

func askArgument(cmd *cobra.Command, i commandInput, value interface{}) error {
if canPrompt(cmd) {
return ask(cmd, i, value, nil, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ask(cmd, i, value, nil, true)
return ask(cmd, i, value, nil, false)

Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@Widcket Widcket changed the title apps, apis, rules: first stab at generalizing picker options apps, apis, rules: first stab at generalizing picker options [CLI-82] Mar 24, 2021
@cyx cyx merged commit e613117 into main Mar 24, 2021
@cyx cyx deleted the rule-generalize-picker-options branch March 24, 2021 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants