Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dtm commit Command Cannot Get The Message From -m Flag #1500

Merged
merged 1 commit into from
May 9, 2023
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
12 changes: 8 additions & 4 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/devstream-io/devstream/internal/log"
"github.com/devstream-io/devstream/internal/pkg/commit"
"github.com/devstream-io/devstream/internal/response"
)

// commit message got from the command line by -m flag
var message string

// commitCmd represents the commit command
var commitCmd = &cobra.Command{
Use: "commit",
Expand All @@ -22,9 +24,11 @@ e.g.
1. dtm commit -m "commit message"
`,
Run: func(cmd *cobra.Command, args []string) {
message := viper.GetString("message")
if message == "" {
log.Error("message is required")
errStr := "message is required"
log.Error(errStr)
r := response.New(response.StatusError, response.MessageError, errStr)
r.Print(OutputFormat)
os.Exit(1)
}
err := commit.Commit(message)
Expand All @@ -41,5 +45,5 @@ e.g.

func init() {
rootCmd.AddCommand(commitCmd)
commitCmd.Flags().StringP("message", "m", "", "commit message")
commitCmd.Flags().StringVarP(&message, "message", "m", "", "commit message")
}
5 changes: 4 additions & 1 deletion cmd/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ e.g.
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
log.Error("Incorrect number of arguments")
errMsg := "Incorrect number of arguments"
log.Error(errMsg)
r := response.New(response.StatusError, response.MessageError, errMsg)
r.Print(OutputFormat)
os.Exit(1)
}
err := patch.Patch(args[0])
Expand Down
4 changes: 1 addition & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"os"

"github.com/sirupsen/logrus"

"github.com/devstream-io/devstream/internal/log"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/devstream-io/devstream/internal/log"
"github.com/devstream-io/devstream/internal/option"
)

Expand Down