| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Command line interface for Drafts. Requires Drafts Pro.
demo.mp4brew install ernstwi/tap/drafts
brew install --cask --no-quarantine ernstwi/tap/drafts-helper
$ drafts --help Usage: drafts <command> [<args>] Options: --help, -h display this help and exit Commands: new create new draft prepend prepend to draft append append to draft replace replace content of draft edit edit draft in $EDITOR get get content of draft select select active draft using fzf list list drafts
See further: drafts <command> --help
It is easy to send commands to Drafts. This is done using actions defined in Drafts' URL scheme. Using a custom action, we can send arbitrary JavaScript to be executed in Drafts.
The more difficult thing is how to get a response back from Drafts to the CLI. Drafts' URL scheme offers a x-success parameter which can be used to call a separate URL with the result of an action. The problem is that the drafts CLI process can't catch this call directly.
My solution to this problem was to make a separate macOS app (Drafts CLI Helper) whose only purpose is to catch x-success calls from Drafts, and forward them via Unix socket to the appropriate drafts CLI process. The resulting system is illustrated below.
graph LR;
cli[Drafts CLI]-- URL scheme -->drafts[Drafts]
drafts-- URL scheme -->cbh[Drafts CLI Helper]
cbh-- Unix socket -->cli
ln -s "$PWD/dist/Drafts CLI Helper.app" /Applications/ PATH=$PATH:$PWD/dist/drafts_darwin_all ./build.sh # To build ./release.sh # To build and publish a new release
| Back | FazBrowse Home | New Git URL |