-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
24 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,39 @@ | ||
/* | ||
Copyright © 2023 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/fatih/color" | ||
"github.com/muandane/goji/pkg/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
globalFlag bool | ||
repoFlag bool | ||
) | ||
|
||
// initCmd represents the init command | ||
var initCmd = &cobra.Command{ | ||
Use: "init", | ||
Short: "Initialize your goji config", | ||
Long: `Initialize your goji config in your repository or globally in your home directory`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
color.Set(color.FgYellow) | ||
err := config.InitRepoConfig(globalFlag, repoFlag) | ||
if err != nil { | ||
fmt.Printf("Failed to initialize repository configuration: %v\n", err) | ||
return | ||
} | ||
color.Unset() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(initCmd) | ||
initCmd.Flags().BoolVar(&globalFlag, "global", false, "save the init file to your home directory") | ||
initCmd.Flags().BoolVar(&repoFlag, "repo", false, "save the init file in the repository") | ||
} |
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