From 6cdd7ac6294bb4ba31eca5a9da78506774c0d678 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sat, 27 Jun 2020 18:42:21 -0400 Subject: [PATCH] ssf-cli 1.0.1 [ci skip] --- packages/ssf-cli/.npmignore | 1 + packages/ssf-cli/README.md | 48 +++++++++++++++++++++++++++++++++++ packages/ssf-cli/index.js | 5 ++-- packages/ssf-cli/package.json | 40 ++++++++++++++++++++--------- 4 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 packages/ssf-cli/.npmignore create mode 100644 packages/ssf-cli/README.md diff --git a/packages/ssf-cli/.npmignore b/packages/ssf-cli/.npmignore new file mode 100644 index 0000000..aa1ec1e --- /dev/null +++ b/packages/ssf-cli/.npmignore @@ -0,0 +1 @@ +*.tgz diff --git a/packages/ssf-cli/README.md b/packages/ssf-cli/README.md new file mode 100644 index 0000000..0991d24 --- /dev/null +++ b/packages/ssf-cli/README.md @@ -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) diff --git a/packages/ssf-cli/index.js b/packages/ssf-cli/index.js index 12e78ed..2ee95fd 100644 --- a/packages/ssf-cli/index.js +++ b/packages/ssf-cli/index.js @@ -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 "); + console.error("usage: ssf-cli "); 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; \ No newline at end of file +module.exports = run; diff --git a/packages/ssf-cli/package.json b/packages/ssf-cli/package.json index 40d2291..b5b9a09 100644 --- a/packages/ssf-cli/package.json +++ b/packages/ssf-cli/package.json @@ -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" + } }