Update Man Page

This commit is contained in:
Fabrice Reix 2020-10-23 17:30:01 +02:00
parent 55ecea4894
commit 8a0fb80199
5 changed files with 100 additions and 64 deletions

View File

@ -3,6 +3,7 @@ import sys
import re
def header():
return '''---
layout: doc
@ -12,6 +13,24 @@ title: Man Page
'''
def process_code_block(s):
output = ''
in_code = False
for line in s.split('\n'):
if not in_code and line.startswith('```'):
output += '{% raw %}\n'
output += line + '\n'
in_code = True
elif in_code and line.startswith('```'):
output += line + '\n'
output += '{% endraw %}\n'
in_code = False
else:
output += line + '\n'
return output
def escape(s):
return s.replace('<', '&lt;').replace('--', '\\-\\-')
@ -36,6 +55,7 @@ def main():
s = ''.join(lines)
s = escape(s)
s = add_anchor_for_h2(s)
s = process_code_block(s)
print(header() + s)

View File

@ -8,16 +8,31 @@ def header(version):
def version():
s = open('../Cargo.toml', 'r').read()
p = re.compile('version(.*)"')
p = re.compile('(.*)', re.MULTILINE)
m = p.match(s)
return '0.99'
p = re.compile('version = "(.*)"')
for line in open('../Cargo.toml', 'r').readlines():
m = p.match(line)
if m:
return m.group(1)
return None
def process_code_block(s):
p = re.compile("```(.*?)```" , re.DOTALL )
return p.sub('\\\\f[C]\\1\\\\f[R]', s)
output = ''
indent = False
for line in s.split('\n'):
if indent and line.startswith('```'):
indent = False
elif not indent and line.startswith('```'):
indent = True
else:
if line != '':
if indent:
output += ' '
output += line
output += '\n'
return output
#p.sub('\\\\f[C]\\1\\\\f[R]', s)
def convert_md(s):
@ -49,7 +64,8 @@ def main():
print(header(version()))
s = ''.join([convert_md(line) for line in data])
#s = process_code_block(s)
s = process_code_block(s)
print(s)

View File

@ -1,4 +1,4 @@
.TH hurl 1 "DATE" "hurl 0.99" " Hurl Manual"
.TH hurl 1 "DATE" "hurl 0.99.13" " Hurl Manual"
.SH NAME
hurl - run and test HTTP requests.
@ -17,36 +17,32 @@ is an HTTP client that performs HTTP requests defined in a simple plain text for
Hurl is very versatile, it enables to chain HTTP requests, capture values from HTTP responses and make asserts.
$ hurl session.hurl
If no input-files are specified, input is read from stdin.
$ echo GET http://httpbin.org/get | hurl
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip",
"Content-Length": "0",
"Host": "httpbin.org",
"User-Agent": "hurl/0.99.10",
"X-Amzn-Trace-Id": "Root=1-5eedf4c7-520814d64e2f9249ea44e0f0"
},
"origin": "1.2.3.4",
"url": "http://httpbin.org/get"
}
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip",
"Content-Length": "0",
"Host": "httpbin.org",
"User-Agent": "hurl/0.99.10",
"X-Amzn-Trace-Id": "Root=1-5eedf4c7-520814d64e2f9249ea44e0f0"
},
"origin": "1.2.3.4",
"url": "http://httpbin.org/get"
}
Output goes to stdout by default. For output to a file, use the -o option:
$ hurl -o output input.hurl
By default, Hurl executes all the HTTP requests and output the response body of the last http call.
@ -61,7 +57,6 @@ It consists of one or several HTTP requests
GET http:/example.net/endpoint2
.IP "Capturing values"
A value from an HTTP response can be-reused for successive HTTP requests.
@ -78,7 +73,6 @@ A typical example occurs with csrf tokens.
POST https://example.net/login?user=toto&password=1234
X-CSRF-TOKEN: {{csrf_token}}
.IP "Asserts"
The HTTP response defined in the Hurl session are used to make asserts.
@ -88,14 +82,12 @@ At the minimum, the response includes the asserts on the HTTP version and status
GET http:/google.com
HTTP/1.1 302
It can also include asserts on the response headers
GET http:/google.com
HTTP/1.1 302
Location: http://www.google.com
You can also include explicit asserts combining query and predicate
GET http:/google.com
@ -103,7 +95,6 @@ You can also include explicit asserts combining query and predicate
[Asserts]
xpath "//title" equals "301 Moved"
Thanks to asserts, Hurl can be used as a testing tool to run scenarii.
@ -340,3 +331,4 @@ Assert Error.
curl(1) hurlfmt(1)

View File

@ -14,14 +14,14 @@ hurl - run and test HTTP requests.
Hurl is very versatile, it enables to chain HTTP requests, capture values from HTTP responses and make asserts.
$ hurl session.hurl
```
$ hurl session.hurl
```
If no input-files are specified, input is read from stdin.
$ echo GET http://httpbin.org/get | hurl
```
$ echo GET http://httpbin.org/get | hurl
{
"args": {},
"headers": {
@ -35,13 +35,15 @@ If no input-files are specified, input is read from stdin.
"origin": "1.2.3.4",
"url": "http://httpbin.org/get"
}
```
Output goes to stdout by default. For output to a file, use the -o option:
```
$ hurl -o output input.hurl
```
$ hurl -o output input.hurl
By default, Hurl executes all the HTTP requests and output the response body of the last http call.
@ -54,9 +56,10 @@ The Hurl file format is fully documented in [https://hurl.dev/docs/hurl-file.htm
It consists of one or several HTTP requests
GET http:/example.net/endpoint1
GET http:/example.net/endpoint2
```hurl
GET http:/example.net/endpoint1
GET http:/example.net/endpoint2
```
### Capturing values
@ -65,16 +68,17 @@ A value from an HTTP response can be-reused for successive HTTP requests.
A typical example occurs with csrf tokens.
GET https://example.net
HTTP/1.1 200
# Capture the CSRF token value from html body.
[Captures]
csrf_token: xpath "normalize-space(//meta[@name='_csrf_token']/@content)"
# Do the login !
POST https://example.net/login?user=toto&password=1234
X-CSRF-TOKEN: {{csrf_token}}
```hurl
GET https://example.net
HTTP/1.1 200
# Capture the CSRF token value from html body.
[Captures]
csrf_token: xpath "normalize-space(//meta[@name='_csrf_token']/@content)"
# Do the login !
POST https://example.net/login?user=toto&password=1234
X-CSRF-TOKEN: {{csrf_token}}
```
### Asserts
@ -82,24 +86,27 @@ The HTTP response defined in the Hurl session are used to make asserts.
At the minimum, the response includes the asserts on the HTTP version and status code.
GET http:/google.com
HTTP/1.1 302
```hurl
GET http:/google.com
HTTP/1.1 302
```
It can also include asserts on the response headers
GET http:/google.com
HTTP/1.1 302
Location: http://www.google.com
```hurl
GET http:/google.com
HTTP/1.1 302
Location: http://www.google.com
```
You can also include explicit asserts combining query and predicate
GET http:/google.com
HTTP/1.1 302
[Asserts]
xpath "//title" equals "301 Moved"
```hurl
GET http:/google.com
HTTP/1.1 302
[Asserts]
xpath "//title" equals "301 Moved"
```
Thanks to asserts, Hurl can be used as a testing tool to run scenarii.

View File

@ -1,4 +1,4 @@
.TH hurl 1 "DATE" "hurl 0.99" " Hurl Manual"
.TH hurl 1 "DATE" "hurl 0.99.13" " Hurl Manual"
.SH NAME
hurlfmt - format Hurl files
@ -64,3 +64,4 @@ Input File Parsing Error.
hurl(1)