Skip to content

Commit

Permalink
The set command now supports piping into it. Closes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
nodesocket committed May 15, 2016
1 parent 32377f9 commit 03a346d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
CHANGELOG
=========

## 0.8.0 - *5/15/2016*

- The `set` command now supports piping into it. Closes [issue #14](https://github.com/nodesocket/jsonlite/issues/14).

````shell
echo '{"key":"value"}' | jsonlite set
4472B861-4C10-4C0A-A63B-E5D45AA679C0
````
````shell
cat foobar.json | jsonlite set
9DF4DC1F-121E-46DC-B580-E1663B645AED
````

## 0.7.1 - *5/15/2016*

- Running `jsonlite` with no command displays the current version, `JSONLITE_PATH` environment variable, and invokes the `help` command.
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export JSONLITE_PATH=/tmp/jsonlite.data
666B81D6-3F8A-4D57-BA3F-11FA8FC47246
````

`set` also supports piping into it:

````shell
echo '{"key":"value"}' | jsonlite set
4472B861-4C10-4C0A-A63B-E5D45AA679C0
````
````shell
cat foobar.json | jsonlite set
9DF4DC1F-121E-46DC-B580-E1663B645AED
````

### get

> get \<document-id\> - Retrieves a json document by document id
Expand Down Expand Up @@ -84,7 +95,7 @@ export JSONLITE_PATH=/tmp/jsonlite.data
Drop database '/jsonlite.data'? [Y/n] Y
````

````
````shell
➜ jsonlite drop --force
````

Expand Down Expand Up @@ -114,7 +125,7 @@ Usage: jsonlite command <command-specific-options>
````shell
➜ jsonlite version
0.7.1
0.8.0
````

## Changelog
Expand Down
9 changes: 8 additions & 1 deletion jsonlite.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

set -eo pipefail; [[ $TRACE ]] && set -x

readonly VERSION="0.7.1"
readonly VERSION="0.8.0"
export JSONLITE_PATH=${JSONLITE_PATH:="$PWD/jsonlite.data"}

jsonlite_version() {
Expand Down Expand Up @@ -58,6 +58,13 @@ jsonlite_is_valid_uuid() {

jsonlite_set() {
local value="$1"

if [[ -z "$value" && ! -t 0 ]]; then
while read -r piped; do
value+=$piped
done;
fi

if [[ -z "$value" ]]; then
echo "Missing required argument json document" 1>&2
exit 4
Expand Down

0 comments on commit 03a346d

Please sign in to comment.