@nullcc/diff2html-cli
Version:
Fast Diff to colorized HTML
239 lines • 7.51 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var yargs = require("yargs");
function setup() {
var currentYear = new Date().getFullYear();
var styleChoices = ["line", "side"];
var summaryChoices = ["closed", "open", "hidden"];
var matchingChoices = ["lines", "words", "none"];
var formatChoices = ["html", "json"];
var inputChoices = ["file", "command", "stdin"];
var outputChoices = ["preview", "stdout"];
var diffyChoices = ["browser", "pbcopy", "print"];
var coverageReporterChoices = ["auto", "json", "cobertura", "jacoco", "xccov"];
var displayModeChoices = ["standard", "simplify"];
var argv = yargs
.usage("Usage: diff2html [options] -- [diff args]")
.options({
style: {
alias: "s",
describe: "Output style",
nargs: 1,
type: "string",
choices: styleChoices,
default: "line"
}
})
.options({
synchronisedScroll: {
alias: "sc",
describe: "Synchronised horizontal scroll",
type: "boolean",
default: true
}
})
.options({
summary: {
alias: "su",
describe: "Show files summary",
type: "string",
choices: summaryChoices,
default: "closed"
}
})
.options({
matching: {
alias: "lm",
describe: "Diff line matching type",
nargs: 1,
type: "string",
choices: matchingChoices,
default: "none"
}
})
.options({
matchWordsThreshold: {
alias: "lmt",
describe: "Diff line matching word threshold",
nargs: 1,
type: "number",
default: 0.25
}
})
.options({
matchingMaxComparisons: {
alias: "lmm",
describe: "Diff line matching maximum line comparisons of a block of changes",
nargs: 1,
type: "number",
default: 1000
}
})
.options({
format: {
alias: "f",
describe: "Output format",
nargs: 1,
type: "string",
choices: formatChoices,
default: "html"
}
})
.options({
input: {
alias: "i",
describe: "Diff input source",
nargs: 1,
type: "string",
choices: inputChoices,
default: "command"
}
})
.options({
output: {
alias: "o",
describe: "Output destination",
nargs: 1,
type: "string",
choices: outputChoices,
default: "preview"
}
})
.options({
diffy: {
alias: "u",
describe: "Upload to diffy.org",
nargs: 1,
type: "string",
choices: diffyChoices
}
})
.options({
file: {
alias: "F",
describe: "Send output to file (overrides output option)",
nargs: 1,
type: "string"
}
})
.options({
htmlWrapperTemplate: {
alias: "hwt",
describe: "Use a custom template when generating markup",
nargs: 1,
type: "string"
}
})
.options({
ignore: {
alias: "ig",
describe: "ignore a file",
nargs: 1,
type: "array"
}
})
.options({
coverage: {
alias: "c",
describe: "Coverage JSON file",
nargs: 1,
type: "string",
}
})
.options({
coverageFilePatterns: {
alias: "p",
describe: "Coverage files patterns",
nargs: 1,
type: "string",
}
})
.options({
workspace: {
alias: "ws",
describe: "Workspace of project",
nargs: 1,
type: "string",
}
})
.options({
coverageReporter: {
alias: "cr",
describe: "Coverage reporter type of coverage file",
nargs: 1,
type: "string",
choices: coverageReporterChoices,
default: "auto"
}
})
.options({
customFileNameGeneratorFile: {
alias: "cfng",
describe: "Generate file name by rules to match file name in coverage",
nargs: 1,
type: "string",
}
})
.options({
displayMode: {
alias: "dm",
describe: "Display mode",
nargs: 1,
choices: displayModeChoices,
}
})
.options({
strict: {
alias: "strict",
describe: "Strict mode",
type: "boolean",
default: false
}
})
.options({
saveDebug: {
alias: "saveDebug",
describe: "Save debug data, git diff and coverage file will be saved",
type: "boolean",
default: false
}
})
.options({
caseInsensitive: {
alias: "caseInsensitive",
describe: "coverage file path case insensitive",
type: "boolean",
default: false
}
})
.example("diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1", "diff last commit, line by line, word comparison between lines," +
"previewed in the browser and input from git diff command")
.example("diff2html -i file -- my-file-diff.diff", "reading the input from a file")
.example("diff2html -f json -o stdout -- -M HEAD~1", "print json format to stdout")
.example("diff2html -F my-pretty-diff.html -- -M HEAD~1", "print to file")
.example("diff2html --ig package-lock.json --ig yarn.lock", "ignore two particular files when generating the diff")
.help("h")
.alias("v", "version")
.alias("h", "help")
.epilog("\u00A9 2014-" + currentYear + " rtfpessoa\n For more information, check out https://diff2html.xyz/\n For support, check out https://github.com/rtfpessoa/diff2html-cli")
.strict(true)
.recommendCommands().argv;
return __assign(__assign({}, argv), { style: argv.style, summary: argv.summary, matching: argv.matching, format: argv.format, input: argv.input, output: argv.output, diffy: argv.diffy, ignore: (argv.ignore || []).map(function (e) { return e.toString(); }), extraArguments: argv._ || [], coverage: argv.coverage, coverageFilePatterns: argv.coverageFilePatterns, workspace: argv.workspace, coverageReporter: argv.coverageReporter, customFileNameGeneratorFile: argv.customFileNameGeneratorFile, displayMode: argv.displayMode, strict: argv.strict, saveDebug: argv.saveDebug });
}
exports.setup = setup;
function help() {
yargs.showHelp("log");
}
exports.help = help;
//# sourceMappingURL=yargs.js.map