improved: aliases
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
abs3nt 2023-03-08 13:46:44 -08:00
parent 8f9ff1dada
commit 32d1074fd9
Signed by: abs3nt
GPG Key ID: FDC6662313FA9386
6 changed files with 30 additions and 25 deletions

View File

@ -14,6 +14,7 @@ var addConfig config.Flags
var addCmd = &cobra.Command{
Use: "add",
Aliases: []string{"a", "create", "new"},
Short: "Adds a project by name",
Long: "Adds a project by name, if path is provided it will use 'cmd/name', all flags provided will be saved in the config file. By default go install and go run will be ran",
Args: cobra.MatchAll(cobra.ExactArgs(1)),

View File

@ -10,6 +10,7 @@ import (
// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Aliases: []string{"c"},
Short: "Deletes the haunt config file",
RunE: clean,
}

View File

@ -13,6 +13,7 @@ import (
// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Aliases: []string{"i"},
Short: "Generates a haunt config file using sane defaults",
Long: "Generates a haunt config file using sane defaults, haunt will look for a main.go file and any directories inside the relative path 'cmd' and add them all as projects",
RunE: defaultConfig,

View File

@ -10,6 +10,7 @@ import (
var removeCmd = &cobra.Command{
Use: "remove [names]",
Aliases: []string{"delete", "r"},
Short: "Removes all projects by name from config file",
Args: cobra.MatchAll(cobra.MinimumNArgs(1), cobra.OnlyValidArgs),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

View File

@ -10,18 +10,19 @@ import (
"github.com/spf13/cobra"
)
var runCmd = &cobra.Command{
Use: "run",
var startCmd = &cobra.Command{
Use: "start",
Aliases: []string{"s", "run"},
Short: "run haunt, optionally provide the name of projects to only run those otherwise will run all configured projects",
Args: cobra.MatchAll(cobra.OnlyValidArgs),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return getProjectNamesToRun(toComplete), cobra.ShellCompDirectiveNoFileComp
},
RunE: run,
RunE: start,
}
func init() {
rootCmd.AddCommand(runCmd)
rootCmd.AddCommand(startCmd)
}
func getProjectNamesToRun(input string) []string {
@ -41,7 +42,7 @@ func getProjectNamesToRun(input string) []string {
}
// haunt workflow
func run(cmd *cobra.Command, args []string) (err error) {
func start(cmd *cobra.Command, args []string) (err error) {
h := haunt.NewHaunt()
// read a config if exist
@ -89,6 +90,6 @@ func run(cmd *cobra.Command, args []string) (err error) {
}
}
// run workflow
return h.Run()
// start workflow
return h.Start()
}

View File

@ -145,8 +145,8 @@ func (h *Haunt) Stop() error {
return nil
}
// Run haunt workflow
func (h *Haunt) Run() error {
// Start haunt workflow
func (h *Haunt) Start() error {
if len(h.Projects) > 0 {
var wg sync.WaitGroup
wg.Add(len(h.Projects))