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

Commit

Permalink
Added ability to pass interger in JSON data via item==value in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed May 4, 2016
1 parent e222ad7 commit ac56c68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ All API calls can be called from the command line. The command will convert doma
$ cli4 [-h|--help] [-v|--verbose] [-q|--quiet] [--get|--patch|--post|-put|--delete] [item=value ...] /command...
```

For API calls that need a set of date or parameters passed there is a item=value format.
If you want a numeric value passed, then _**_ can be used to force the value to be treated as a numeric value.

The output from the CLI command is in json format (and human readable).

### Simple CLI examples
Expand Down
6 changes: 3 additions & 3 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ def cli4(args):
# next grab the params. These are in the form of tag=value
params = {}
while len(args) > 0 and '=' in args[0]:
tag, value = args.pop(0).split('=')
tag, value = args.pop(0).split('=', 1)
if value == 'true':
value = True
elif value == 'false':
value = False
elif digits_only.match(value):
value = int(value)
elif value[0] is '=' and digits_only.match(value[1:]):
value = int(value[1:])
elif value[0] is '[' and value[-1] is ']':
value = value[1:-1].split(',')
params[tag] = value
Expand Down

0 comments on commit ac56c68

Please sign in to comment.