Skip to content

Commit 034c7e9

Browse files
committed
Update docs
1 parent 9550a44 commit 034c7e9

File tree

5 files changed

+76
-32
lines changed

5 files changed

+76
-32
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ It is comprised of three sub-commands:
1414

1515
acts as a one-shot web server - useful in testing you applications
1616

17+
* `please identify`
18+
19+
given structured data on standard input, this will output the format used (e.g. "json", "yaml")
20+
1721
* `please parse`
1822

1923
understands the data exchange formats of the web and can translate between them

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ It is comprised of three sub-commands:
1414

1515
acts as a one-shot web server - useful in testing you applications
1616

17+
* `please identify`
18+
19+
given structured data on standard input, this will output the format used (e.g. "json", "yaml")
20+
1721
* `please parse`
1822

1923
understands the data exchange formats of the web and can translate between them

docs/parse.md

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,80 @@ If you're not familiar with associative arrays in bash or how `declare` works, i
2525

2626
## Usage
2727

28-
please parse [-i type] [-o type] [path...]
28+
please parse [-i <INPUT FORMAT>] [-o <OUTPUT FORMAT>] [PATH]
2929

30-
-i type Parse the input as 'type' (default: auto)
31-
-o type Use 'type' as the output format (default: bash)
30+
If INPUT TYPE is omitted, it defaults to "auto".
3231

33-
If path is given, only output data from the path downwards.
32+
If OUTPUT TYPE is omitted, it will default to the same as the input type - effectively acting as a pretty-printer.
33+
34+
If PATH is provided, it should be given in dot-notation, e.g. orders.*.id
35+
36+
Available input types:
37+
auto
38+
csv
39+
html
40+
json
41+
mime
42+
xml
43+
yaml
44+
45+
Available output types:
46+
bash
47+
dot
48+
json
49+
xml
50+
yaml
3451

3552
## Examples
3653

3754
Parsing a whole tree:
3855

3956
$ echo '{"this":{"is":["some","json"],"that":"we"},"will":"parse"}' | please parse
40-
([this]="([is]=\"([0]=some [1]=json)\" [that]=we)" [will]=parse)
57+
{
58+
"this": {
59+
"is": [
60+
"some",
61+
"json"
62+
],
63+
"that": "we"
64+
},
65+
"will": "parse"
66+
}
4167

4268
Getting a single value:
4369

4470
$ echo '{"this":{"is":["some","json"],"that":"we"},"will":"parse"}' | please parse this.that
45-
we
71+
"we"
4672

4773
Specifying the input format:
4874

4975
Note the `-i` flag
5076

5177
$ echo '<xml example="true"><child>one</child><child>two</child></xml>' | please parse -i xml
52-
([xml]="([-example]=\"true\" [child]=\"([0]=\\\"one\\\" [1]=\\\"two\\\")\")")
78+
<xml example="true">
79+
<child>one</child>
80+
<child>two</child>
81+
</xml>
5382

5483
Specifying the output format:
5584

5685
Note the `-o` flag
5786

5887
$ echo '{"json": ["input", "here"], "yaml": "output"}' | please parse -o yaml
59-
'json':
60-
- "input"
61-
- "here"
62-
'yaml': "output"
88+
json:
89+
- input
90+
- here
91+
yaml: output
6392

6493
Making use of the bash-declare output format
6594

66-
$ echo '{"json": ["array", "values"]}' | please parse json | (declare -A data=$(cat -); echo ${data[1]})
95+
$ echo '["array", "values"]' | please parse -o bash | (declare -A data=$(cat -); echo ${data[1]})
6796
values
6897

6998
Generating a graph from some json (you need graphviz installed)
7099

71100
$ echo '{"vars": ["foo", "bar", "baz"], "cake": {"is_lie": true}}' | please parse -o dot | dot -Tpng > graph.png
101+
102+
Will result in:
103+
104+
![A nice graph](dot-output.png)

docs/request.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@ Probably the most important thing you will need to do with a web service is to c
66

77
## Usage
88

9-
please request <method> [options...] <url>
9+
please request <METHOD> [option...] <URL>
1010

11-
-i Headers included in the input
11+
Makes a web request to URL using METHOD
1212

13-
-s Output HTTP status line with the response
14-
-h Output headers with the response
13+
Shortcut aliases:
14+
please get
15+
please post
16+
please put
17+
please delete
1518

16-
There are aliases for the most common methods:
19+
Input options:
20+
-i Include headers from input
1721

18-
please get <url>
19-
please post <url>
20-
please put <url>
21-
please delete <url>
22-
23-
For any other methods, you will need to specify the method directly:
24-
25-
please request head <url>
26-
please request info <url>
27-
please request patch <url>
22+
Output options:
23+
-s Output HTTP status line
24+
-h Output headers
2825

2926
## Examples
3027

docs/respond.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
## Usage
66

7-
please respond [options...] <status> [<address>[:<port>]]
7+
please respond [option...] <STATUS> [<ADDRESS>[:<PORT>]]
88

9-
-i Headers included in the input
9+
Listens on the specified address and port and responds with the chosen status code.
10+
Any data on stdin will be used as the body of the response.
11+
The request body will be printed to stdout.
1012

11-
-m Include request method in output
12-
-u Include URL in output
13-
-h Include headers in output
13+
Input options:
14+
-i Include headers from input
15+
16+
Output options:
17+
-m Output the request method
18+
-u Output the requested path
19+
-h Output headers with the request
1420

1521
## Examples
1622

0 commit comments

Comments
 (0)