implement --help options (#2017)

This commit is contained in:
Alex Lam S.L
2017-05-28 18:21:44 +08:00
committed by GitHub
parent fec14379f6
commit c6c9f4f5a8
4 changed files with 36 additions and 24 deletions

View File

@@ -25,6 +25,18 @@ program.version(info.name + ' ' + info.version);
program.parseArgv = program.parse;
program.parse = undefined;
if (process.argv.indexOf("ast") >= 0) program.helpInformation = UglifyJS.describe_ast;
else if (process.argv.indexOf("options") >= 0) program.helpInformation = function() {
var text = [];
var options = UglifyJS.default_options();
for (var option in options) {
text.push("--" + (option == "output" ? "beautify" : option == "sourceMap" ? "source-map" : option) + " options:");
Object.keys(options[option]).forEach(function(name) {
text.push(" " + name);
});
text.push("");
}
return text.join("\n");
};
program.option("-p, --parse <options>", "Specify parser options.", parse_js("parse", true));
program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js("compress", true));
program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js("mangle", true));