Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Functional
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Sep 10, 2013
1 parent 4f18c6a commit 37f4ff3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

_wip / nonfunctional_

### example
### usage

npm install -g geojsonio-cli
Read or pipe a file

geojsonio map.geojson
cat map.geojson | geojsonio

Options:

```
geojsonio map.geojson
cat map.geojson | geojsonio
```
--print prints the url rather than opening it
--domain="http://custominstancedomain.com/"

### installation

npm install -g geojsonio-cli
16 changes: 15 additions & 1 deletion geojsonio.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
#!/usr/bin/env node

var concat = require('concat-stream'),
opener = require('opener'),
fs = require('fs'),
argv = require('minimist')(process.argv.slice(2));


if (argv.help || argv.h) return help();

((argv._[0] && fs.createReadStream(argv._[0])) || process.stdin).pipe(concat(openData));

function openData(body) {
opener('http://geojson.io/#?id=data&data=' + encodeURIComponent(body.toString()));
try {
(argv.print ? console.log : opener)((argv.domain || 'http://geojson.io/') +
'#data=data:application/json,' + encodeURIComponent(
JSON.stringify(JSON.parse(body.toString()))));
} catch(e) {
console.error('Valid GeoJSON file required as input.');
help();
}
}

function help() { fs.createReadStream('README.md').pipe(process.stdout); }
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"geojsonio": "geojsonio.js"
},
"repository": {
"type": "git",
"url": "https://github.com/mapbox/geojsonio-cli.git"
Expand Down

0 comments on commit 37f4ff3

Please sign in to comment.