CLI refactor

* Moved cli to packages/ssf-cli

* Modified bin in package.json files
This commit is contained in:
Garrett Luu 2020-06-24 12:40:26 -07:00
parent 885b27fda5
commit 15c017bc5b
6 changed files with 40 additions and 16 deletions

@ -1,13 +0,0 @@
#!/usr/bin/env node
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* eslint no-console:0 */
/*jshint node:true */
var X = require('../');
var argv = process.argv.slice(2);
if(argv.length < 2 || argv[0] == "-h" || argv[0] == "--help") {
console.error("usage: ssf <format> <value>");
console.error("output: format_as_string|format_as_number|");
process.exit(0);
}
console.log(X.format(argv[0],argv[1]) + "|" + X.format(argv[0],+(argv[1])) + "|");

@ -8,9 +8,6 @@
"sprintf",
"spreadsheet"
],
"bin": {
"ssf": "./bin/ssf.njs"
},
"main": "./ssf",
"types": "types",
"dependencies": {

1
packages/ssf-cli/.gitignore vendored Normal file

@ -0,0 +1 @@
node_modules/

8
packages/ssf-cli/bin/ssf.njs Executable file

@ -0,0 +1,8 @@
#!/usr/bin/env node
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* eslint no-console:0 */
/*jshint node:true */
var cli = require('../');
cli();

17
packages/ssf-cli/index.js Normal file

@ -0,0 +1,17 @@
#!/usr/bin/env node
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* eslint no-console:0 */
/*jshint node:true */
var X = require('ssf');
function run() {
var argv = process.argv.slice(2);
if (argv.length < 2 || argv[0] == "-h" || argv[0] == "--help") {
console.error("usage: ssf <format> <value>");
console.error("output: format_as_string|format_as_number|");
process.exit(0);
}
console.log(X.format(argv[0], argv[1]) + "|" + X.format(argv[0], +(argv[1])) + "|");
}
module.exports = run;

@ -0,0 +1,14 @@
{
"name": "ssf-cli",
"version": "1.0.0",
"description": "Command-line interface for ssf",
"bin": {
"ssf-cli": "./bin/ssf.njs"
},
"main": "index.js",
"author": "Garrett Luu",
"license": "Apache-2.0",
"dependencies": {
"ssf": "^0.11.1"
}
}