mirror of
https://github.com/dilllxd/gitfolio.git
synced 2024-08-14 22:28:09 +00:00
Cli feature (#29)
* Move all cli options to single bin file, export fns from each file instead * Make username/title required in cli itself * fix username not being parsed, set desc separately * read outDir from env var, defaults to dist * set outDir env var in cli to cwd * Move default configs to default dir * handle blog.json not existing * fix assets path * make build function async * update clean command * added defaults to CLI
This commit is contained in:
parent
2ec61a9132
commit
e62e4c05b3
10 changed files with 169 additions and 99 deletions
44
bin/gitfolio.js
Normal file
44
bin/gitfolio.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
#! /usr/bin/env node
|
||||
/* Argument parser */
|
||||
const program = require('commander');
|
||||
|
||||
process.env.OUT_DIR = process.env.OUT_DIR || process.cwd();
|
||||
|
||||
const {buildCommand} = require('../build');
|
||||
const {updateCommand} = require('../update');
|
||||
const {blogCommand} = require('../blog');
|
||||
const {version} = require('../package.json');
|
||||
|
||||
program
|
||||
.command('build <username>')
|
||||
.description('Build site with your GitHub username. This will be used to customize your site')
|
||||
.option('-t, --theme [theme]', 'specify a theme to use', 'light')
|
||||
.option('-b, --background [background]', 'set the background image')
|
||||
.option('-f, --fork', 'includes forks with repos')
|
||||
.option('-s, --sort [sort]', 'set default sort for repository', 'created')
|
||||
.option('-o, --order [order]', 'set default order on sort', 'asc')
|
||||
.action(buildCommand)
|
||||
|
||||
program
|
||||
.command('update')
|
||||
.action(updateCommand);
|
||||
|
||||
program
|
||||
.command('blog <title>')
|
||||
.description('Create blog with specified title')
|
||||
.option('-s, --subtitle [subtitle]', 'give blog a subtitle', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
|
||||
.option('-p, --pagetitle [pagetitle]', 'give blog page a title')
|
||||
.option('-f, --folder [folder]', 'give folder a title (use "-" instead of spaces)')
|
||||
.action(blogCommand);
|
||||
|
||||
program.on('command:*', () => {
|
||||
console.log('Unknown Command: ' + program.args.join(' '))
|
||||
program.help()
|
||||
});
|
||||
|
||||
program
|
||||
.version(version, '-v --version')
|
||||
.usage('<command> [options]')
|
||||
.parse(process.argv);
|
||||
|
||||
if (program.args.length === 0) program.help();
|
Loading…
Add table
Add a link
Reference in a new issue