Skip to content

Commit 889d072

Browse files
committed
cli adds version and json options. cli man page matches cli command
1 parent bb64ccd commit 889d072

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

cli4/cli4.man

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ cli4 \- Command line access to CloudFlare v4 API
55

66
.SH SYNOPSIS
77
.B cli4
8+
[\fB\-V\fR]
89
[\fB\-h\fR|\fB\-\-help]
910
[\fB\-v\fR|\fB\-\-verbose]
1011
[\fB\-q\fR|\fB\-\-quiet]
1112
[\fB\-j\fR|\fB\-\-json]
1213
[\fB\-y\fR|\fB\-\-yaml]
1314
[\fBitem\fR=\fIvalue\fR ...]
15+
[\fB\-G\fR|\fB\-\-get]
16+
[\fB\-P\fR|\fB\-\-patch]
17+
[\fB\-O\fR|\fB\-\-post]
18+
[\fB\-U\fR|\fB\-\-put]
19+
[\fB\-D\fR|\fB\-\-delete]
1420
.IR /command ...
1521

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

2026
.SH OPTIONS
2127
.TP
28+
.IP "[\-V, \-\-version]"
29+
Display program version number and exit.
2230
.IP "[\-h, \-\-help]"
2331
This information (in a terse form).
2432
.IP "[\-v, \-\-verbose]"
2533
Provide some protcol debugging information.
2634
.IP "[\-q, \-\-quiet]"
27-
Don't output any JSON/YAML responses
35+
Don't output any JSON/YAML responses.
2836
.IP "[\-j, \-\-json]"
29-
Output in JSON format
37+
Output response data in JSON format (the default).
3038
.IP "[\-y, \-\-yaml]"
31-
Output in YAML format
32-
.IP \-\-get
39+
Output response data in YAML format (if yaml package installed).
40+
.IP "\-\-get"
3341
Send HTTP request as a \fBGET\fR (the default).
34-
.IP \-\-patch
42+
.IP "\-\-patch"
3543
Send HTTP request as a \fBPATCH\fR.
36-
.IP \-\-post
44+
.IP "\-\-post"
3745
Send HTTP request as a \fBPOST\fR.
38-
.IP \-\-put
46+
.IP "\-\-put"
3947
Send HTTP request as a \fBPUT\fR.
40-
.IP \-\-delete
48+
.IP "\-\-delete"
4149
Send HTTP request as a \fBDELETE\fR.
42-
.IP item=\fIvalue\fR
50+
.IP "item=\fIvalue\fR"
4351
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.
4452
.IP item:=\fIvalue\fR
4553
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.
@@ -54,22 +62,31 @@ The output is either JSON or YAML formatted.
5462
.SH EXAMPLES
5563
.B cli4 /zones
5664
List infomation for all zones.
65+
5766
.B cli4 /zones/:example.com
5867
List specific zone info.
68+
5969
.B cli4 /zones/:example.com/settings
6070
List settings for a specific zone.
71+
6172
.B cli4 --delete purge_everything=true /zones/:example.com/purge_cache
6273
Purge cache for a specific zone.
74+
6375
.B cli4 --delete files='[http://example.com/css/styles.css]' /zones/:example.com/purge_cache
6476
Purge cache for a specific zone.
77+
6578
.B cli4 --delete files='[http://example.com/css/styles.css,http://example.com/js/script.js] /zones/:example.com/purge_cache
6679
Purge cache for a specific zone.
80+
6781
.B cli4 --delete tags='[tag1,tag2,tag3]' /zones/:example.com/purge_cache
6882
Purge cache for a specific zone.
83+
6984
.B cli4 /zones/:example.com/available_plans
7085
List available plans for a zone.
86+
7187
.B cli4 --patch status=active /zones/:example.com/dnssec
7288
Make DNSSEC active for specfic zone.
89+
7390
.B cli4 /zones/:example.com/dnssec
7491
List DNSSEC infomation and status for a specific zone.
7592

cli4/cli4.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,16 @@ def cli4(args):
119119
method = 'GET'
120120

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

127127
try:
128128
opts, args = getopt.getopt(args,
129129
'VhvqjyGPOUD',
130130
[
131+
'version',
131132
'help', 'version' 'verbose', 'quiet', 'json', 'yaml',
132133
'get', 'patch', 'post', 'put', 'delete'
133134
])
@@ -142,6 +143,8 @@ def cli4(args):
142143
verbose = True
143144
elif opt in ('-q', '--quiet'):
144145
output = None
146+
elif opt in ('-j', '--json'):
147+
output = 'json'
145148
elif opt in ('-y', '--yaml'):
146149
output = 'yaml'
147150
elif opt in ('-G', '--get'):

0 commit comments

Comments
 (0)