Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding usage to json() #31

Closed
wants to merge 3 commits into from

2 participants

@drnic

I've also stripped out "json set to" as it wasn't implemented and I'm not sure what the API was supposed to be.

@drnic

I think this is the Usage. I've not gotten json() to work yet I think. I've gotten most of the error messages so i'm getting somewhere :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 5 deletions.
  1. +9 −5 core/api/shell/json/functions
View
14 core/api/shell/json/functions
@@ -1,5 +1,12 @@
#!/bin/sh
+# Usage:
+# {example} # => {result when applied to json below}
+# json get from ${json_file} string path/to/item # => 'found item'
+# json get from ${json_file} array path/to/list # => 'list of items'
+#
+# run against json in file ${json_file}:
+# { path: { to: { item: 'found item', list: ['list', 'of', 'items']}}}
json()
{
trace_filter json || set -o xtrace
@@ -8,7 +15,7 @@ json()
typeset -a _params
_command="$1" && shift ||
- __sm.log.fail "Usage: json {get|set} from file '{file}' ..."
+ __sm.log.fail "Usage: json get from file '{file}' ..."
_params=()
@@ -19,10 +26,7 @@ json()
(get|read)
_command="get"
;;
- (set|write)
- _command="set"
- ;;
- (from|to)
+ (from)
_json_file="${1}" && shift ||
__sm.log.fail "a json file path/name must follow keyword '${_token}'"
;;
Something went wrong with that request. Please try again.