-
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.
- more logging - add tests for: - parsing goals yaml - cli rendering - normalizing arguments - fix rendering non-args CLI
- Loading branch information
Showing
10 changed files
with
586 additions
and
257 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/aaabramov/goal/lib" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// cliCmd represents the cli command | ||
var cliCmd = &cobra.Command{ | ||
Use: "cli GOAL [--on env]", | ||
Short: "Show CLI for specific goal", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
goal := args[0] | ||
if cmd, exists := commands.GetWithEnv(strings.TrimSpace(goal), env); exists { | ||
lib.Info(cmd.Cli()) | ||
} else { | ||
msg := fmt.Sprintf("No such goal: %s", goal) | ||
if env != "" { | ||
msg += fmt.Sprintf(" on env \"%s\"", env) | ||
} | ||
lib.Fatal(msg) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(cliCmd) | ||
|
||
cliCmd.Flags().StringVarP(&env, "on", "e", "", "Environment to use, example: goal cli tf-apply --on dev") | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var env string | ||
|
||
// runCmd represents the run command | ||
var runCmd = &cobra.Command{ | ||
Use: "run GOAL [--on env]", | ||
Short: "Run specified goal", | ||
//Long: `TODO`, | ||
Args: cobra.ExactArgs(1), | ||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
res := make([]string, len(commands.Commands)) | ||
for _, command := range commands.Commands { | ||
res = append(res, command.Name) | ||
} | ||
return res, cobra.ShellCompDirectiveNoFileComp | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) > 0 { | ||
commands.Exec(strings.TrimSpace(args[0]), env) | ||
} else { | ||
cmd.Help() | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(runCmd) | ||
|
||
runCmd.Flags().StringVarP(&env, "on", "e", "", "Environment to use, example: goal tf-apply --on dev") | ||
} |
Oops, something went wrong.