Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ console.log(taxonomy(value))
// [ 'tier 1', 'numeric', 'non-redundant', 'flat' ]
```

Usage (CLI)
-----------

The published [npm](https://www.npmjs.com) package includes a simple
command-line interface program that can be globally installed as follows:

```sh
npm install --global @sourcemeta/json-taxonomy
```

The CLI program takes the path to a JSON document as an argument and outputs
the taxonomy to standard output:

```sh
json-taxonomy path/to/document.json
```

License
-------

Expand Down
17 changes: 17 additions & 0 deletions js/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

const fs = require('fs')
const taxonomy = require('..')
const INPUT = process.argv[2]

if (!INPUT) {
console.error(`${process.argv[0]} ${process.argv[1]} <document.json>`)
process.exit(1)
}

fs.accessSync(INPUT, fs.constants.R_OK)
const value = JSON.parse(fs.readFileSync(INPUT, 'utf8'))

console.log(taxonomy(value).map((qualifier) => {
return qualifier[0].toUpperCase() + qualifier.slice(1)
}).join(', '))
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "@sourcemeta/json-taxonomy",
"version": "1.0.1",
"version": "1.1.0",
"description": "A formal taxonomy to classify JSON documents based on their size, type of content, characteristics of their structure and redundancy criteria",
"main": "js/index.js",
"bin": {
"json-taxonomy": "./js/cli.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sourcemeta/json-taxonomy.git"
Expand Down