wpsync

wpsync is a command-line tool to sync a local directory to your WordPress.

I really like markdown and vim. My publishing process was create a draft in markdown, when ready copy-paste up to WordPress, the editor converts it nicely, and then publish. However, when a revision is needed, it must be done in WordPress not in my markdown/vim tools.

After publishing my Working with Vim tutorial, there was a lot of revisions and additions I needed to make, and I couldn’t use vim.

I love the WordPress block editor, I wrote various parts of it, and have worked on it for past year or two. But sometimes I just need markdown and vim.

Here’s a demo:

wpsync demo

Install and Setup

The program is written in Go, I probably should of written in JavaScript then I could use some of the markdown libraries that WordPress uses to convert, but this is a personal project and I like writing Golang.

See the code and download release binaries at github.com/mkaz/wpsync

Authentication on the command-line is the tricky bit. JWT Authentication plugin is required and makes it possible. For now this does not work for WordPress.com sites. For wpcom, it is possible to use a similar token for authentication, however I don’t think it is possible to retrieve this token via the command-line.

Usage

Create a directory for your site, and subdirectories media and posts. Any files in media and posts will be uploaded.

Run wpsync --init for initial setup

Run wpsync -confirm to confirm each upload

See the readme in Github for full documentation.

Usage: wpsync [args]

Arguments:

  -confirm
        Confirm prompt before upload
  -debug
        Display debug messages
  -dryrun
        Test run, shows what will happen
  -help
        Display help and quit
  -init
        Create settings for blog and auth
  -quiet
        Do not display info messages
  -test
        Test config and authentication
  -version
        Display version and quit

Next Steps

I’ll probably keep tweaking away on this, right now there is only one way sync from local to remote. It would be nice to be able to pull down existing posts, edit, and publish.

Any feedback, comments, issues, or even pull requests are welcome.