-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from silphid/refactor-structure
fixed cmd dependency tree and made start readable
- Loading branch information
Showing
18 changed files
with
850 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
package get | ||
|
||
import ( | ||
"github.com/silphid/yey/src/cmd/get/containers" | ||
"github.com/silphid/yey/src/cmd/get/context" | ||
"github.com/silphid/yey/src/cmd/get/contexts" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// New creates a cobra command | ||
func New() *cobra.Command { | ||
c := &cobra.Command{ | ||
return &cobra.Command{ | ||
Use: "get", | ||
Short: "Displays value(s) of entity or variable", | ||
} | ||
c.AddCommand(containers.New()) | ||
c.AddCommand(context.New()) | ||
c.AddCommand(contexts.New()) | ||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/AlecAivazis/survey/v2" | ||
yey "github.com/silphid/yey/src/internal" | ||
) | ||
|
||
func PromptContext(contexts yey.Contexts) (string, error) { | ||
// Get context names | ||
names := contexts.GetNames() | ||
if len(names) == 0 { | ||
return "", fmt.Errorf("no context defined") | ||
} | ||
|
||
// Only one context defined, no need to prompt | ||
if len(names) == 1 { | ||
return names[0], nil | ||
} | ||
|
||
// Show selection prompt | ||
prompt := &survey.Select{ | ||
Message: "Select context:", | ||
Options: names, | ||
} | ||
|
||
selectedIndex := 0 | ||
if err := survey.AskOne(prompt, &selectedIndex); err != nil { | ||
return "", err | ||
} | ||
|
||
return names[selectedIndex], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.