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

add --publish option to push subcommand #134

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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
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
Loading