nv-cli-hson 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/TEST/h +6 -0
- package/TEST/j +8 -0
- package/cli.js +66 -0
- package/index.js +0 -0
- package/package.json +27 -0
package/README.md
ADDED
package/TEST/h
ADDED
package/TEST/j
ADDED
package/cli.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
ppend_fmt_sary,
|
|
7
|
+
apend_fmt_sary
|
|
8
|
+
} = require("nv-string-basic");
|
|
9
|
+
|
|
10
|
+
const nvison = require("nvison");
|
|
11
|
+
const nvhson = require("nvhson");
|
|
12
|
+
const paint = require("nv-html-term-paint");
|
|
13
|
+
const neatify = require("nv-json-beautify").to_str;
|
|
14
|
+
|
|
15
|
+
const creat_argv = require("nv-cli-basic");
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const cfg = {
|
|
20
|
+
alias: {
|
|
21
|
+
'no_output_color' :'n',
|
|
22
|
+
'input_type' :'t',
|
|
23
|
+
'input' :'i',
|
|
24
|
+
'output' :'o',
|
|
25
|
+
'help' :'h',
|
|
26
|
+
},
|
|
27
|
+
description: {
|
|
28
|
+
'no_output_color' :'no color when output when input type is json, default false',
|
|
29
|
+
'input_type' :'input type: json | html | j | h ,default is j',
|
|
30
|
+
'input' :'input string ,default stdin',
|
|
31
|
+
'output' :'output string,default stdout',
|
|
32
|
+
'help':"usage",
|
|
33
|
+
},
|
|
34
|
+
defaults: {
|
|
35
|
+
input_type: "json"
|
|
36
|
+
},
|
|
37
|
+
boolean: ["help","no_output_color"]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var argv = creat_argv(cfg);
|
|
44
|
+
////
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if(argv.h) {
|
|
48
|
+
var _usage = argv.usage("nv_cli_hson");
|
|
49
|
+
console.log(_usage)
|
|
50
|
+
} else {
|
|
51
|
+
var handler = (src)=> {
|
|
52
|
+
if(argv.t.toLowerCase().includes("j")) {
|
|
53
|
+
let j = nvison.parse_from_str(src);
|
|
54
|
+
let h = nvhson.ser(j);
|
|
55
|
+
if(argv.no_output_color) {
|
|
56
|
+
return h + "\n\n";
|
|
57
|
+
} else {
|
|
58
|
+
return paint(h)+"\n";
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
var j = nvhson.der(src);
|
|
62
|
+
return neatify(j);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
argv.rwstream(handler,argv.i,argv.o);
|
|
66
|
+
}
|
package/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"nv-cli-basic": "^1.0.18",
|
|
4
|
+
"nv-cli-jfetch": "^1.0.2",
|
|
5
|
+
"nv-cli-user": "1.0.1",
|
|
6
|
+
"nv-facutil-surl": "^1.0.2",
|
|
7
|
+
"nv-file-sync-reader": "^1.0.4",
|
|
8
|
+
"nv-html-term-paint": "^1.0.1",
|
|
9
|
+
"nv-json-beautify": "^1.0.0",
|
|
10
|
+
"nv-server-simple-stream": "^1.0.36",
|
|
11
|
+
"nv-string-basic": "^1.0.51",
|
|
12
|
+
"nvhson": "^1.0.2",
|
|
13
|
+
"nvison": "^1.0.28"
|
|
14
|
+
},
|
|
15
|
+
"name": "nv-cli-hson",
|
|
16
|
+
"description": "",
|
|
17
|
+
"version": "1.0.3",
|
|
18
|
+
"main": "index.js",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"nv_cli_hson": "cli.js"
|
|
24
|
+
},
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "ISC"
|
|
27
|
+
}
|