table-printer-cli
Advanced tools
Comparing version 0.0.11 to 1.0.0
@@ -5,2 +5,17 @@ #!/usr/bin/env node | ||
const service_1 = require("./src/service"); | ||
service_1.default(process.argv); | ||
const commander_1 = require("commander"); | ||
const fs = require("fs"); | ||
commander_1.program | ||
.option('-i, --input <value>', 'input string') | ||
.option('-s, --stdin', 'read input from stdin') | ||
.parse(process.argv); | ||
if (commander_1.program.input) { | ||
console.log('program.input', commander_1.program.input); | ||
service_1.default(commander_1.program.input); | ||
} | ||
else if (commander_1.program.stdin) { | ||
service_1.default(fs.readFileSync(0).toString()); | ||
} | ||
else { | ||
console.log('Error: Cant detect input option'); | ||
} |
@@ -1,2 +0,2 @@ | ||
declare const verifyInput: (args: string[]) => Boolean; | ||
export declare const verifyInput: (inp: string) => Boolean; | ||
export default verifyInput; |
@@ -7,3 +7,3 @@ "use strict"; | ||
if (!Array.isArray(jsonObj)) { | ||
console.log('c'); | ||
console.log('input Not an array'); | ||
return false; | ||
@@ -18,12 +18,8 @@ } | ||
}; | ||
const verifyInput = (args) => { | ||
if (args.length !== 3) { | ||
console.log('only one param allowed'); | ||
exports.verifyInput = (inp) => { | ||
if (!isValidJson(inp)) { | ||
return false; | ||
} | ||
if (!isValidJson(args[2])) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
exports.default = verifyInput; | ||
exports.default = exports.verifyInput; |
@@ -1,2 +0,2 @@ | ||
declare const printTableFromArgs: (args: string[]) => string | void; | ||
export default printTableFromArgs; | ||
declare const printTableFromInp: (inp: string) => string | void; | ||
export default printTableFromInp; |
@@ -5,11 +5,10 @@ "use strict"; | ||
const inputVerifier_1 = require("./inputVerifier"); | ||
const banner_1 = require("./banner"); | ||
const printTableFromArgs = (args) => { | ||
if (!inputVerifier_1.default(args)) { | ||
console.log(banner_1.default); | ||
const printTableFromInp = (inp) => { | ||
if (!inputVerifier_1.default(inp)) { | ||
console.log(`not a valid input ${inp}`); | ||
return; | ||
} | ||
const jsonInp = JSON.parse(args[2]); | ||
const jsonInp = JSON.parse(inp); | ||
console_table_printer_1.printTable(jsonInp); | ||
}; | ||
exports.default = printTableFromArgs; | ||
exports.default = printTableFromInp; |
{ | ||
"name": "table-printer-cli", | ||
"version": "0.0.11", | ||
"version": "1.0.0", | ||
"description": "console table printer cli. Print table on bash terminal", | ||
@@ -35,2 +35,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"commander": "^5.1.0", | ||
"console-table-printer": "^1.4.3" | ||
@@ -37,0 +38,0 @@ }, |
@@ -46,3 +46,3 @@ <h1 align="center">table-printer-cli</h1> | ||
```bash | ||
ctp '[{ "id":3, "text":"like" }, {"id":4, "text":"tea"}]' | ||
ctp -i '[{ "id":3, "text":"like" }, {"id":4, "text":"tea"}]' | ||
``` | ||
@@ -54,4 +54,21 @@ | ||
You can also pipe the input from stdin | ||
```bash | ||
echo '[{ "id":3, "text":"like" }, {"id":4, "text":"tea"}]' | ctp -s | ||
``` | ||
## Detailed usage | ||
```text | ||
Usage: ctp [options] | ||
Options: | ||
-i, --input <value> input string | ||
-s, --stdin read input from stdin | ||
-h, --help display help for command | ||
``` | ||
## License | ||
[MIT](https://github.com/ayonious/table-printer-cli/blob/master/LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
73
6494
2
9
62
1
+ Addedcommander@^5.1.0
+ Addedcommander@5.1.0(transitive)