forked from toolshed/abra
feat: add git-user and git-email flags to recipe new
This commit is contained in:
@ -248,6 +248,22 @@ var RemoteUserFlag = &cli.StringFlag{
|
||||
Destination: &RemoteUser,
|
||||
}
|
||||
|
||||
var GitName string
|
||||
var GitNameFlag = &cli.StringFlag{
|
||||
Name: "git-name, gn",
|
||||
Value: "",
|
||||
Usage: "Git (user) name to do commits with",
|
||||
Destination: &GitName,
|
||||
}
|
||||
|
||||
var GitEmail string
|
||||
var GitEmailFlag = &cli.StringFlag{
|
||||
Name: "git-email, ge",
|
||||
Value: "",
|
||||
Usage: "Git email name to do commits with",
|
||||
Destination: &GitEmail,
|
||||
}
|
||||
|
||||
// SubCommandBefore wires up pre-action machinery (e.g. --debug handling).
|
||||
func SubCommandBefore(c *cli.Context) error {
|
||||
if Debug {
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
@ -37,6 +36,8 @@ var recipeNewCommand = cli.Command{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.OfflineFlag,
|
||||
internal.GitNameFlag,
|
||||
internal.GitEmailFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
Usage: "Create a new recipe",
|
||||
@ -92,14 +93,14 @@ recipe and domain in the sample environment config).
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||
if err := git.Init(newGitRepo, true); err != nil {
|
||||
if err := git.Init(newGitRepo, true, internal.GitName, internal.GitEmail); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user