X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/65d379f5db381423165e0da8cc788f85112873b8..10a76a5bf0a9d051aa9432566088034c5ced714b:/bin/blog.js diff --git a/bin/blog.js b/bin/blog.js index 8f0ab70..3f5db43 100755 --- a/bin/blog.js +++ b/bin/blog.js @@ -1,14 +1,21 @@ #!/usr/bin/env node -'use strict'; - -const Package = require('../package.json'); -const Config = require('../config/config'); -const Blog = require('..'); -const Minimist = require('minimist'); +import Config from '../config/config.js'; +import Blog from '../lib/blog.js'; +import Minimist from 'minimist'; const internals = { blog: new Blog(Config), - expectedKeys: ['add', 'generate', 'update', 'publish', 'publish-archive', 'version'], + expectedKeys: [ + 'add', + 'generate', + 'update', + 'publish', + 'publish-archive', + 'add-remote', + 'remove-remote', + 'sync-up', + 'sync-down', + 'version'], // Application entry point. Reads arguments and calls the // corresponding method from the blog lib @@ -24,7 +31,7 @@ const internals = { const value = parsedArguments[argument]; if (argument === 'version') { - console.log(Package.version); + console.log('6.0.0'); return; } @@ -52,6 +59,26 @@ const internals = { await internals.blog.publishArchive(value); return; } + + if (argument === 'add-remote') { + await internals.blog.addRemote(value); + return; + } + + if (argument === 'remove-remote') { + await internals.blog.removeRemote(); + return; + } + + if (argument === 'sync-up') { + await internals.blog.syncUp(); + return; + } + + if (argument === 'sync-down') { + await internals.blog.syncDown(); + return; + } } } @@ -91,11 +118,15 @@ const internals = { _printUsage() { console.error('\nUsage:\n'); - console.error('blog --add path/to/blog_post\t\t(creates new blog post)'); - console.error('blog --update path/to/blog_post\t\t(updates latest blog post)'); + console.error('blog --add \t\t(creates new blog post)'); + console.error('blog --update \t\t(updates latest blog post)'); console.error('blog --generate \t\t\t(generates the blog assets)'); console.error('blog --publish \t\t(publishes the blog to an S3 bucket)'); console.error('blog --publish-archive \t(publishes the archive to a remote host)'); + console.error('blog --add-remote \t\t(adds or updates a git remote to sync with)'); + console.error('blog --remove-remote \t\t\t(removes the git remote)'); + console.error('blog --sync-up \t\t\t\t(pushes to the git remote if configured)'); + console.error('blog --sync-down \t\t\t(pulls from the git remote if configured)'); console.error('blog --version \t\t\t\t(print the version)'); } };