Skip to content

Commit

Permalink
ssf-cli 1.0.1 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
SheetJSDev committed Jun 28, 2020
1 parent 577070b commit 6cdd7ac
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/ssf-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tgz
48 changes: 48 additions & 0 deletions packages/ssf-cli/README.md
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 2 additions & 3 deletions packages/ssf-cli/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* eslint no-console:0 */
Expand All @@ -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;
40 changes: 28 additions & 12 deletions packages/ssf-cli/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 6cdd7ac

Please sign in to comment.