nv-cli-cat 1.0.1
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 +30 -0
- package/cli.js +81 -0
- package/index.js +0 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
nv-cli-cat
|
|
3
|
+
==========
|
|
4
|
+
- same as cat, just with color AND range
|
|
5
|
+
|
|
6
|
+
install
|
|
7
|
+
=======
|
|
8
|
+
- npm install nv-cli-cat -g
|
|
9
|
+
|
|
10
|
+
usage
|
|
11
|
+
=====
|
|
12
|
+
|
|
13
|
+
Usage: nv_cli_cat [options]
|
|
14
|
+
Options:
|
|
15
|
+
-l, --start_line start_line, default 1
|
|
16
|
+
-c, --start_col start_col, default 1
|
|
17
|
+
-L, --end_line end_line, default Infinity
|
|
18
|
+
-C, --end_col end_col, default Infinity
|
|
19
|
+
-r, --seg_color color, default red
|
|
20
|
+
-R, --list_colors list colors,default false
|
|
21
|
+
-p, --file_paths file paths, multi
|
|
22
|
+
-h, --help usage
|
|
23
|
+
|
|
24
|
+
example
|
|
25
|
+
========
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
LICENSE
|
|
29
|
+
=======
|
|
30
|
+
- ISC
|
package/cli.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
|
|
12
|
+
|
|
13
|
+
const creat_argv = require("nv-cli-basic");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const {_sync_console_paint,COLOR_MAP}= require("nv-file-range");
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const cfg = {
|
|
21
|
+
alias: {
|
|
22
|
+
'start_line' :'l',
|
|
23
|
+
'start_col' :'c',
|
|
24
|
+
'end_line' :'L',
|
|
25
|
+
'end_col' :'C',
|
|
26
|
+
|
|
27
|
+
'seg_color' :'r',
|
|
28
|
+
'list_colors' :'R',
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
'file_paths' :'p',
|
|
32
|
+
'help' :'h',
|
|
33
|
+
},
|
|
34
|
+
description: {
|
|
35
|
+
'start_line' :'start_line, default 1',
|
|
36
|
+
'start_col' :'start_col, default 1',
|
|
37
|
+
'end_line' :'end_line, default Infinity',
|
|
38
|
+
'end_col' :'end_col, default Infinity',
|
|
39
|
+
'seg_color' :'color, default red',
|
|
40
|
+
"list_colors" :'list colors,default false',
|
|
41
|
+
'file_paths' :'file paths',
|
|
42
|
+
'help':"usage",
|
|
43
|
+
},
|
|
44
|
+
defaults: {
|
|
45
|
+
'seg_color' :'red',
|
|
46
|
+
'start_line' :1,
|
|
47
|
+
'start_col' :1,
|
|
48
|
+
'end_line' :Infinity,
|
|
49
|
+
'end_col' :Infinity,
|
|
50
|
+
},
|
|
51
|
+
boolean: ["help","list_colors"]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var argv = creat_argv(cfg);
|
|
58
|
+
////
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if(argv.h) {
|
|
62
|
+
var _usage = argv.usage("nv_cli_cat");
|
|
63
|
+
console.log(_usage)
|
|
64
|
+
} else if(argv.R) {
|
|
65
|
+
var ks = Object.keys(COLOR_MAP);
|
|
66
|
+
console.log(JSON.stringify(ks,null,2))
|
|
67
|
+
} else {
|
|
68
|
+
console.log()
|
|
69
|
+
var config = {seg:argv.r};
|
|
70
|
+
var fns = creat_argv.force_to_ary(argv.p);
|
|
71
|
+
for(let fn of fns) {
|
|
72
|
+
fn = path.resolve(fn);
|
|
73
|
+
if(fs.existsSync(fn)) {
|
|
74
|
+
var sz = fs.lstatSync(fn).size;
|
|
75
|
+
console.log(`<${fn}>`);
|
|
76
|
+
if(sz>0) {console.log(_sync_console_paint(fn,argv.l,argv.c,argv.L,argv.C,config));}
|
|
77
|
+
console.log(`</${fn}>`);
|
|
78
|
+
} else {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
package/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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-range": "^1.0.2",
|
|
8
|
+
"nv-file-sync-reader": "^1.0.4",
|
|
9
|
+
"nv-server-simple-stream": "^1.0.36",
|
|
10
|
+
"nv-string-basic": "^1.0.51",
|
|
11
|
+
"nvison": "^1.0.28"
|
|
12
|
+
},
|
|
13
|
+
"name": "nv-cli-cat",
|
|
14
|
+
"description": "",
|
|
15
|
+
"version": "1.0.1",
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"nv_cli_cat": "cli.js"
|
|
22
|
+
},
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "ISC"
|
|
25
|
+
}
|