Skip to content

Commit

Permalink
cli adds version and json options. cli man page matches cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Oct 15, 2016
1 parent bb64ccd commit 889d072
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
35 changes: 26 additions & 9 deletions cli4/cli4.man
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ cli4 \- Command line access to CloudFlare v4 API

.SH SYNOPSIS
.B cli4
[\fB\-V\fR]
[\fB\-h\fR|\fB\-\-help]
[\fB\-v\fR|\fB\-\-verbose]
[\fB\-q\fR|\fB\-\-quiet]
[\fB\-j\fR|\fB\-\-json]
[\fB\-y\fR|\fB\-\-yaml]
[\fBitem\fR=\fIvalue\fR ...]
[\fB\-G\fR|\fB\-\-get]
[\fB\-P\fR|\fB\-\-patch]
[\fB\-O\fR|\fB\-\-post]
[\fB\-U\fR|\fB\-\-put]
[\fB\-D\fR|\fB\-\-delete]
.IR /command ...

.SH DESCRIPTION
Expand All @@ -19,27 +25,29 @@ provides command line access to CloudFlare v4 API

.SH OPTIONS
.TP
.IP "[\-V, \-\-version]"
Display program version number and exit.
.IP "[\-h, \-\-help]"
This information (in a terse form).
.IP "[\-v, \-\-verbose]"
Provide some protcol debugging information.
.IP "[\-q, \-\-quiet]"
Don't output any JSON/YAML responses
Don't output any JSON/YAML responses.
.IP "[\-j, \-\-json]"
Output in JSON format
Output response data in JSON format (the default).
.IP "[\-y, \-\-yaml]"
Output in YAML format
.IP \-\-get
Output response data in YAML format (if yaml package installed).
.IP "\-\-get"
Send HTTP request as a \fBGET\fR (the default).
.IP \-\-patch
.IP "\-\-patch"
Send HTTP request as a \fBPATCH\fR.
.IP \-\-post
.IP "\-\-post"
Send HTTP request as a \fBPOST\fR.
.IP \-\-put
.IP "\-\-put"
Send HTTP request as a \fBPUT\fR.
.IP \-\-delete
.IP "\-\-delete"
Send HTTP request as a \fBDELETE\fR.
.IP item=\fIvalue\fR
.IP "item=\fIvalue\fR"
Set a paramater or data value to send with a \fBGET\fR, \fBPATCH\fR, \fBPOST\fR, \fBPUT\fR or \fBDELETE\fR command. The value is sent as a string.
.IP item:=\fIvalue\fR
Set a paramater or data value to send with a \fBGET\fR, \fBPATCH\fR, \fBPOST\fR, \fBPUT\fR or \fBDELETE\fR command. The value is sent as an interger.
Expand All @@ -54,22 +62,31 @@ The output is either JSON or YAML formatted.
.SH EXAMPLES
.B cli4 /zones
List infomation for all zones.

.B cli4 /zones/:example.com
List specific zone info.

.B cli4 /zones/:example.com/settings
List settings for a specific zone.

.B cli4 --delete purge_everything=true /zones/:example.com/purge_cache
Purge cache for a specific zone.

.B cli4 --delete files='[http://example.com/css/styles.css]' /zones/:example.com/purge_cache
Purge cache for a specific zone.

.B cli4 --delete files='[http://example.com/css/styles.css,http://example.com/js/script.js] /zones/:example.com/purge_cache
Purge cache for a specific zone.

.B cli4 --delete tags='[tag1,tag2,tag3]' /zones/:example.com/purge_cache
Purge cache for a specific zone.

.B cli4 /zones/:example.com/available_plans
List available plans for a zone.

.B cli4 --patch status=active /zones/:example.com/dnssec
Make DNSSEC active for specfic zone.

.B cli4 /zones/:example.com/dnssec
List DNSSEC infomation and status for a specific zone.

Expand Down
9 changes: 6 additions & 3 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ def cli4(args):
method = 'GET'

usage = ('usage: cli4 '
+ '[-V|--version] [-h|--help] [-v|--verbose] [-q|--quiet] [-j|--json] [-y|--yaml]'
+ '[--get|--patch|--post|-put|--delete]'
+ '[item=value ...]'
+ '[-V|--version] [-h|--help] [-v|--verbose] [-q|--quiet] [-j|--json] [-y|--yaml] '
+ '[--get|--patch|--post|-put|--delete] '
+ '[item=value ...] '
+ '/command...')

try:
opts, args = getopt.getopt(args,
'VhvqjyGPOUD',
[
'version',
'help', 'version' 'verbose', 'quiet', 'json', 'yaml',
'get', 'patch', 'post', 'put', 'delete'
])
Expand All @@ -142,6 +143,8 @@ def cli4(args):
verbose = True
elif opt in ('-q', '--quiet'):
output = None
elif opt in ('-j', '--json'):
output = 'json'
elif opt in ('-y', '--yaml'):
output = 'yaml'
elif opt in ('-G', '--get'):
Expand Down

0 comments on commit 889d072

Please sign in to comment.