Skip to content

Commit 911a7e9

Browse files
author
Rodrigo Fernandes
committed
Merge pull request #3 from rtfpessoa/better-cli-args-parsing
Use yargs to parse the cli arguments
2 parents 314a65e + 7f7de95 commit 911a7e9

File tree

5 files changed

+265
-121
lines changed

5 files changed

+265
-121
lines changed

README.md

+31-16
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,39 @@ Diff to Html generates pretty HTML diffs from git diff output in your terminal
3636

3737
## Usage
3838

39-
Usage: diff2html [git-diff options]
39+
diff2html [options]
4040

41-
Options:
42-
43-
-h, --help output usage information
44-
-V, --version output the version number
45-
-i, --input [file] Diff input file.
46-
-o, --output [file] Output to file path. Defaults to stdout.
47-
-p, --preview Open preview in the browser.
48-
-l, --line Line by Line diff.
49-
-s, --side Side by Side diff.
50-
-j, --json Export diff in json format.
51-
52-
Example:
5341

54-
diff2html -p -l "HEAD~1"
55-
56-
> NOTE: notice the " in the example
42+
Options:
43+
-s, --style Output style
44+
[string] [choices: "line", "side"] [default: "line"]
45+
-f, --format Output format
46+
[string] [choices: "html", "json"] [default: "html"]
47+
-d, --diff Diff style [string] [choices: "word", "char"] [default: "word"]
48+
-i, --input Diff input source
49+
[string] [choices: "file", "command"] [default: "command"]
50+
-o, --output Output destination
51+
[string] [choices: "preview", "stdout"] [default: "preview"]
52+
-F, --file Send output to file (overrides output option) [string]
53+
--version Show version number [boolean]
54+
-h, --help Show help [boolean]
55+
56+
57+
Examples:
58+
diff2html -s line -f html -d word -i diff last commit, line by line, word
59+
command -o preview -- -M HEAD~1 comparison between lines,previewed
60+
in the browser and input from git
61+
diff command
62+
diff2html -i file -- my-file-diff.diff reading the input from a file
63+
diff2html -f json -o stdout -- -M HEAD~1 print json format to stdout
64+
diff2html -F my-pretty-diff.html -- -M print to file
65+
HEAD~1
66+
67+
68+
© 2015 rtfpessoa
69+
For support, check out https://github.com/rtfpessoa/diff2html-cli
70+
71+
> NOTE: notice the `--` in the examples
5772
5873
## Contributions
5974

config.jscs.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"disallowKeywords": [
3+
"with"
4+
],
5+
"disallowKeywordsOnNewLine": [
6+
"else"
7+
],
8+
"disallowMixedSpacesAndTabs": true,
9+
"disallowMultipleVarDecl": "exceptUndefined",
10+
"disallowNewlineBeforeBlockStatements": true,
11+
"disallowQuotedKeysInObjects": null,
12+
"disallowSpaceAfterObjectKeys": true,
13+
"disallowSpaceAfterPrefixUnaryOperators": true,
14+
"disallowSpacesInFunction": {
15+
"beforeOpeningRoundBrace": true
16+
},
17+
"disallowSpacesInsideParentheses": true,
18+
"disallowTrailingWhitespace": true,
19+
"maximumLineLength": 90,
20+
"requireCamelCaseOrUpperCaseIdentifiers": true,
21+
"requireCapitalizedComments": true,
22+
"requireCapitalizedConstructors": true,
23+
"requireCurlyBraces": true,
24+
"requireSpaceAfterKeywords": [
25+
"if",
26+
"else",
27+
"for",
28+
"while",
29+
"do",
30+
"switch",
31+
"case",
32+
"return",
33+
"try",
34+
"catch",
35+
"typeof"
36+
],
37+
"requireSpaceAfterLineComment": true,
38+
"requireSpaceAfterBinaryOperators": true,
39+
"requireSpaceBeforeBinaryOperators": true,
40+
"requireSpaceBeforeBlockStatements": true,
41+
"requireSpaceBeforeObjectValues": true,
42+
"requireSpacesInFunction": {
43+
"beforeOpeningCurlyBrace": true
44+
},
45+
"requireTrailingComma": null,
46+
"validateIndentation": 2,
47+
"validateLineBreaks": "LF",
48+
"validateQuoteMarks": "'"
49+
}

dist/template.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
-->
1111

1212
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/github.min.css">
13-
<link rel="stylesheet" type="text/css" href="{{css}}">
13+
<!--css-->
1414

1515
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
1616
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/languages/scala.min.js"></script>
1717
<script>
18-
document.addEventListener("DOMContentLoaded", function () {
18+
document.addEventListener("DOMContentLoaded", function() {
1919
// collect all the distinct languages in the HTML
2020
var distinctLanguages = [];
21-
[].forEach.call(document.getElementsByClassName("d2h-file-wrapper"), function (file) {
21+
[].forEach.call(document.getElementsByClassName("d2h-file-wrapper"), function(file) {
2222
distinctLanguages.indexOf(file.dataset.lang) === -1 && distinctLanguages.push(file.dataset.lang);
2323
});
2424

@@ -27,7 +27,7 @@
2727

2828
// collect all the code lines and execute the highlight on them
2929
var codeLines = document.getElementsByClassName("d2h-code-line-ctn");
30-
[].forEach.call(codeLines, function (line) {
30+
[].forEach.call(codeLines, function(line) {
3131
hljs.highlightBlock(line);
3232
});
3333
});
@@ -37,7 +37,7 @@
3737
<h1>Diff to HTML by <a href="https://github.com/rtfpessoa">rtfpessoa</a></h1>
3838

3939
<div>
40-
{{diff}}
40+
<!--diff-->
4141
</div>
4242
</body>
4343
</html>

package.json

+22-36
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,55 @@
11
{
2-
"name": "diff2html-cli",
3-
"version": "0.2.4-1",
4-
2+
"name": "diff2html-cli",
3+
"version": "1.0.0",
54
"homepage": "https://www.github.com/rtfpessoa/diff2html-cli",
65
"description": "Fast Diff to colorized HTML",
76
"keywords": [
8-
"git",
9-
"diff",
10-
"pretty",
11-
"side",
12-
"line",
13-
"side-by-side",
14-
"line-by-line",
15-
"character",
16-
"highlight",
17-
"pretty",
18-
"color",
19-
"html",
20-
"diff2html",
21-
"difftohtml",
22-
"colorized"
23-
],
24-
7+
"git",
8+
"diff",
9+
"pretty",
10+
"side",
11+
"line",
12+
"side-by-side",
13+
"line-by-line",
14+
"character",
15+
"highlight",
16+
"pretty",
17+
"color",
18+
"html",
19+
"diff2html",
20+
"difftohtml",
21+
"colorized"
22+
],
2523
"author": {
26-
"name": "Rodrigo Fernandes",
24+
"name": "Rodrigo Fernandes",
2725
"email": "[email protected]"
2826
},
29-
3027
"repository": {
3128
"type": "git",
3229
"url": "https://www.github.com/rtfpessoa/diff2html-cli.git"
3330
},
34-
3531
"bugs": {
3632
"url": "https://www.github.com/rtfpessoa/diff2html-cli/issues"
3733
},
38-
3934
"engines": {
40-
"node": ">=0.12.2"
35+
"node": ">=0.12.0"
4136
},
42-
4337
"preferGlobal": "true",
44-
4538
"scripts": {
4639
"test": ""
4740
},
48-
4941
"bin": {
5042
"diff2html": "./bin/diff2html"
5143
},
52-
5344
"main": "./src/main.js",
54-
5545
"dependencies": {
56-
"commander": "2.8.1",
57-
"extend": "3.0.0",
58-
"pkginfo": "0.3.0",
46+
"yargs": "3.24.*",
47+
"extend": "3.0.*",
5948
"diff2html": "*"
6049
},
61-
6250
"devDependencies": {
6351
},
64-
6552
"license": "MIT",
66-
6753
"files": [
6854
"bin",
6955
"src",

0 commit comments

Comments
 (0)