Skip to content

Commit

Permalink
feat(CLI:flavor): add flavor option to CLI
Browse files Browse the repository at this point in the history
Add the option to pass a flavor preset to CLI. Ex:
`showdown makehtml --flavor="github"`
  • Loading branch information
tivie committed Jan 8, 2017
1 parent 3b3e9e7 commit 2d6cd1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -60,6 +60,6 @@
"source-map-support": "^0.2.9"
},
"dependencies": {
"yargs": "^3.15.0"
"yargs": "^6.6.0"
}
}
5 changes: 2 additions & 3 deletions src/cli/cli.js
@@ -1,10 +1,9 @@
'use strict';

var version = require('../../package.json').version,
yargs = require('yargs');
var yargs = require('yargs');

yargs
.version(version, 'v')
.version()
.alias('v', 'version')
.option('h', {
alias: 'help',
Expand Down
21 changes: 16 additions & 5 deletions src/cli/makehtml.cmd.js
Expand Up @@ -7,7 +7,12 @@ yargs.reset()
.usage('Usage: showdown makehtml [options]')
.example('showdown makehtml -i', 'Reads from stdin and outputs to stdout')
.example('showdown makehtml -i foo.md -o bar.html', 'Reads \'foo.md\' and writes to \'bar.html\'')
//.demand(['i'])
.config('c')
.alias('c', 'config')
.help('h')
.alias('h', 'help')
.version()
.alias('v', 'version')
.option('i', {
alias : 'input',
describe: 'Input source. Usually a md file. If omitted or empty, reads from stdin',
Expand All @@ -34,10 +39,11 @@ yargs.reset()
describe: 'Load the specified extensions. Should be valid paths to node compatible extensions',
type: 'array'
})
.config('c')
.alias('c', 'config')
.help('h')
.alias('h', 'help');
.option('p', {
alias : 'flavor',
describe: 'Run with a predetermined flavor of options. Default is vanilla',
type: 'string'
});

yargs.options(showdown.getDefaultOptions(false));
argv = yargs.argv;
Expand Down Expand Up @@ -81,6 +87,11 @@ function run() {
}
}

// Load flavor
if (argv.p) {
converter.setFlavor(argv.p);
}

// parse and convert file
output = converter.makeHtml(input);

Expand Down

0 comments on commit 2d6cd1e

Please sign in to comment.