mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
feat(CLI:flavor): add flavor option to CLI
Add the option to pass a flavor preset to CLI. Ex: `showdown makehtml --flavor="github"`
This commit is contained in:
parent
3b3e9e7fbe
commit
2d6cd1e908
|
@ -60,6 +60,6 @@
|
||||||
"source-map-support": "^0.2.9"
|
"source-map-support": "^0.2.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"yargs": "^3.15.0"
|
"yargs": "^6.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var version = require('../../package.json').version,
|
var yargs = require('yargs');
|
||||||
yargs = require('yargs');
|
|
||||||
|
|
||||||
yargs
|
yargs
|
||||||
.version(version, 'v')
|
.version()
|
||||||
.alias('v', 'version')
|
.alias('v', 'version')
|
||||||
.option('h', {
|
.option('h', {
|
||||||
alias: 'help',
|
alias: 'help',
|
||||||
|
|
|
@ -7,7 +7,12 @@ yargs.reset()
|
||||||
.usage('Usage: showdown makehtml [options]')
|
.usage('Usage: showdown makehtml [options]')
|
||||||
.example('showdown makehtml -i', 'Reads from stdin and outputs to stdout')
|
.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\'')
|
.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', {
|
.option('i', {
|
||||||
alias : 'input',
|
alias : 'input',
|
||||||
describe: 'Input source. Usually a md file. If omitted or empty, reads from stdin',
|
describe: 'Input source. Usually a md file. If omitted or empty, reads from stdin',
|
||||||
|
@ -34,10 +39,11 @@ yargs.reset()
|
||||||
describe: 'Load the specified extensions. Should be valid paths to node compatible extensions',
|
describe: 'Load the specified extensions. Should be valid paths to node compatible extensions',
|
||||||
type: 'array'
|
type: 'array'
|
||||||
})
|
})
|
||||||
.config('c')
|
.option('p', {
|
||||||
.alias('c', 'config')
|
alias : 'flavor',
|
||||||
.help('h')
|
describe: 'Run with a predetermined flavor of options. Default is vanilla',
|
||||||
.alias('h', 'help');
|
type: 'string'
|
||||||
|
});
|
||||||
|
|
||||||
yargs.options(showdown.getDefaultOptions(false));
|
yargs.options(showdown.getDefaultOptions(false));
|
||||||
argv = yargs.argv;
|
argv = yargs.argv;
|
||||||
|
@ -81,6 +87,11 @@ function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load flavor
|
||||||
|
if (argv.p) {
|
||||||
|
converter.setFlavor(argv.p);
|
||||||
|
}
|
||||||
|
|
||||||
// parse and convert file
|
// parse and convert file
|
||||||
output = converter.makeHtml(input);
|
output = converter.makeHtml(input);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user