ssf-cli 1.0.1 [ci skip]
This commit is contained in:
parent
577070b8d7
commit
6cdd7ac629
1
packages/ssf-cli/.npmignore
Normal file
1
packages/ssf-cli/.npmignore
Normal file
@ -0,0 +1 @@
|
||||
*.tgz
|
48
packages/ssf-cli/README.md
Normal file
48
packages/ssf-cli/README.md
Normal file
@ -0,0 +1,48 @@
|
||||
# [SSF Command-Line Interface](http://sheetjs.com)
|
||||
|
||||
ssf (SpreadSheet Format) is a pure JS library to format data using ECMA-376
|
||||
spreadsheet format codes (used in popular spreadsheet software packages).
|
||||
|
||||
This CLI tool formats numbers from shell scripts and other command-line tools.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://www.npmjs.org/package/ssf-cli):
|
||||
|
||||
```bash
|
||||
$ npm install -g ssf-cli
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`ssf-cli` takes two arguments: the format string and the value to be formatted.
|
||||
|
||||
The value is formatted twice, once interpreting the value as a string and once
|
||||
interpreting the value as a number, and both results are printed to standard
|
||||
output, with a pipe character `|` after each value:
|
||||
|
||||
```bash
|
||||
$ bin/ssf.njs "#,##0.00" 12345
|
||||
12345|12,345.00|
|
||||
$ bin/ssf.njs "0;0;0;:@:" 12345
|
||||
:12345:|12345|
|
||||
```
|
||||
|
||||
Extracting the values in a pipeline is straightforward with AWK:
|
||||
|
||||
```bash
|
||||
$ bin/ssf.njs "#,##0.00" 12345 | awk -F\| '{print $2}'
|
||||
12,345.00
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Please consult the attached LICENSE file for details. All rights not explicitly
|
||||
granted by the Apache 2.0 license are reserved by the Original Author.
|
||||
|
||||
## Credits
|
||||
|
||||
Special thanks to [Garrett Luu](https://garrettluu.com/) for spinning off the
|
||||
command from the SSF module.
|
||||
|
||||
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/ssf?pixel)](https://github.com/SheetJS/ssf)
|
@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||
/* eslint-env node */
|
||||
/* eslint no-console:0 */
|
||||
@ -7,11 +6,11 @@ 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("usage: ssf-cli <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;
|
||||
module.exports = run;
|
||||
|
@ -1,14 +1,30 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
"name": "ssf-cli",
|
||||
"version": "1.1.0",
|
||||
"author": "Garrett Luu",
|
||||
"description": "Command-line interface for ssf",
|
||||
"keywords": [
|
||||
"format",
|
||||
"sprintf",
|
||||
"spreadsheet"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"bin": {
|
||||
"ssf-cli": "./bin/ssf.njs"
|
||||
},
|
||||
"dependencies": {
|
||||
"ssf": "^0.11.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/SheetJS/ssf.git"
|
||||
},
|
||||
"homepage": "http://sheetjs.com/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/SheetJS/ssf/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user