]> Sergey Matveev's repositories - sgblog.git/commitdiff
sgblog-comment-add -dryrun option
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2020 20:25:18 +0000 (23:25 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2020 20:25:18 +0000 (23:25 +0300)
cmd/sgblog-comment-add/main.go

index b52e68a4347b230f67c9846cb66fce4e2062560f..728f34e2fe17e359cb2b3096a3864908932bb282 100644 (file)
@@ -44,6 +44,7 @@ func main() {
        gitDir := flag.String("git-dir", "", "Path to .git repository")
        notesRef := flag.String("ref", "comments", "notes reference name")
        umask := flag.String("umask", "027", "umask value")
+       dryRun := flag.Bool("dryrun", false, "Show comment, do not add")
        flag.Parse()
        uid := syscall.Geteuid()
        if err := syscall.Setuid(uid); err != nil {
@@ -107,6 +108,11 @@ func main() {
                strings.Join(lines, "\n"),
        )))
 
+       if *dryRun {
+               fmt.Print(buf.String())
+               os.Exit(0)
+       }
+
        cmd = exec.Command(
                *gitCmd, "--git-dir", *gitDir,
                "notes", "--ref", *notesRef, "add",