Skip to content

Commit

Permalink
Merge pull request #134 from x-motemen/publish
Browse files Browse the repository at this point in the history
add --publish option to push subcommand
  • Loading branch information
Songmu authored Nov 3, 2023
2 parents b37e0b6 + 894d77e commit d17cd14
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"sort"
"strings"
"time"

"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -189,12 +190,16 @@ var commandFetch = &cli.Command{
var commandPush = &cli.Command{
Name: "push",
Usage: "Push local entries to remote",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "publish"},
},
Action: func(c *cli.Context) error {
first := c.Args().First()
if first == "" {
cli.ShowCommandHelp(c, "push")
return errCommandHelp
}
publish := c.Bool("publish")

conf, err := loadConfiguration()
if err != nil {
Expand All @@ -212,6 +217,12 @@ var commandPush = &cli.Command{
if err != nil {
return err
}
if publish && entry.IsDraft {
entry.IsDraft = false
// Assume it has been edited and update modtime.
ti := time.Now()
entry.LastModified = &ti
}

if entry.EditURL == "" {
// post new entry
Expand Down

0 comments on commit d17cd14

Please sign in to comment.