Skip to content
This repository has been archived by the owner on Dec 29, 2024. It is now read-only.

Commit

Permalink
feat: allows users specifying a message when saving (#32)
Browse files Browse the repository at this point in the history
Closes #31.
  • Loading branch information
gsilvapt authored Jan 22, 2022
1 parent 62441c1 commit 3535c49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ It provides methods to add, search and save your changes into a git repository.
Full documentation can be found in the project's README: https://github.com/gsilvapt/pmz
`,
Version: "0.3",
Version: "0.4",
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down
7 changes: 6 additions & 1 deletion cmd/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func runSaveCommand(cmd *cobra.Command, args []string) {
gituser := viper.GetString("gituser")
gittoken := viper.GetString("repotoken")

cmsg, _ := cmd.Flags().GetString("message")

r, err := git.PlainOpen(ztlrepo)
if err != nil {
Logger.Error(fmt.Sprintf("failed opening the git repository: %s", err))
Expand All @@ -60,7 +62,7 @@ func runSaveCommand(cmd *cobra.Command, args []string) {
}
}

_, err = wt.Commit("updating your zettelkasten", &git.CommitOptions{})
_, err = wt.Commit(cmsg, &git.CommitOptions{})
if err != nil {
Logger.Error(fmt.Sprintf("failed committing changes: \n %s", err))
}
Expand All @@ -80,4 +82,7 @@ func runSaveCommand(cmd *cobra.Command, args []string) {

func init() {
rootCmd.AddCommand(saveCmd)

saveCmd.Flags().StringP("message", "m", "updating your zettelkasten",
"Provide a specific message if you prefer over the default one")
}

0 comments on commit 3535c49

Please sign in to comment.