Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cmd/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,28 @@ var rootCmd = &cobra.Command{
Use: "gh-commit",
Short: "gh-commit: commit files easily to git using the Github API",
Long: "gh-commit: a CLI tool for committing changes via the Github API, especially useful for working in ephemeral environments.",
RunE: func(cmd *cobra.Command, args []string) error {
version, _ := cmd.Flags().GetBool("version")
PreRunE: func(cmd *cobra.Command, args []string) error {
message, _ := cmd.Flags().GetString(MessageFlag.Long)
branch, _ := cmd.Flags().GetString(BranchFlag.Long)
versionFlag, _ := cmd.Flags().GetBool("version")

if version {
if versionFlag {
fmt.Printf("%s %s %s\n",
color.New(color.FgBlue, color.Bold).Sprint("🔖 gh-commit"),
color.New(color.FgGreen).Sprint(VERSION),
color.New(color.Faint).Sprint("(CLI tool)"),
)
return nil
os.Exit(0)
}

if message == "" || branch == "" {
return fmt.Errorf("--message and --branch are both required flags")
}

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {

path, err := ValidateLocalGit()
if err != nil {
return err
Expand Down
5 changes: 1 addition & 4 deletions cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// VERSION number: changed in CI
const VERSION = "v0.1.0"
const VERSION = "v0.1.1"

var rootPath string
var repo repository.Repository
Expand All @@ -33,9 +33,6 @@ func init() {
case "stringSlice":
rootCmd.Flags().StringSliceP(flag.Long, flag.Short, []string{}, flag.Description)
}
if flag.Required {
_ = rootCmd.MarkFlagRequired(flag.Long)
}
}

rootCmd.Flags().BoolP("version", "V", false, "Print current version")
Expand Down