Skip to content

Commit 1db0ceb

Browse files
author
Fred
committed
Add command line help
1 parent a798c23 commit 1db0ceb

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,19 @@ As we saw earlier, for each test, you will have to define the expected result. o
170170
To launch okapi, please run the following:
171171

172172
```shell
173-
okapi <options> test_directory
173+
okapi [options] <test_directory>
174174
```
175175

176176
where options are one or more of the following:
177177

178-
- `test_directory`: the directory where all the test files are located
179-
- `--servers-file` or `-s` (mandatory): allows to point to the configuration file
180-
- `--timeout` (default 30s): allows to set a default timeout for all HTTP requests
181-
- `--verbose` (`--no-verbose`) or `-v` (default no): verbose mode
182-
- `--parallel` (`--no-parallel`) or `-p` (default yes): run tests in parallel
183-
- `--user-agent` (default okapi ua): to set the default user agent
184-
- `--content-type` (default application/json): to set the default content type for requests
185-
- `--accept` (default application/json): to set the default accept header for responses
178+
- `--servers-file`, `-s` (mandatory): point to the configuration file's location
179+
- `--timeout` (default 30s): set a default timeout for all HTTP requests
180+
- `--verbose`, `-v` (default no): enable verbose mode
181+
- `--no-parallel` (default parallel): prevent tests from running in parallel
182+
- `--user-agent` (default okapi UA): set the default user agent
183+
- `--content-type` (default application/json): set the default content type for requests
184+
- `--accept` (default application/json): set the default accept header for responses
185+
- `test_directory`: point to the directory where all the test files are located
186186

187187
## Output example
188188

main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,41 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"log"
67
"os"
78

89
"github.com/fred1268/okapi/testing"
910
)
1011

12+
func help() {
13+
fmt.Println("okapi is a tool to help make API tests as easy as table driven tests.")
14+
fmt.Println()
15+
fmt.Println("Usage:")
16+
fmt.Println()
17+
fmt.Println("\tokapi [options] <test_directory>")
18+
fmt.Println()
19+
fmt.Println("The options are:")
20+
fmt.Println()
21+
fmt.Println("\t--servers-file, -s (mandatory):\t\t\t\tpoint to the configuration file's location")
22+
fmt.Println("\t--timeout (default 30s):\t\t\t\tset a default timeout for all HTTP requests")
23+
fmt.Println("\t--verbose, -v (default no):\t\t\t\tenable verbose mode")
24+
fmt.Println("\t--no-parallel (default parallel):\t\t\tprevent tests from running in parallel")
25+
fmt.Println("\t--user-agent (default okapi UA):\t\t\tset the default user agent")
26+
fmt.Println("\t--content-type (default application/json):\t\tset the default content type for requests")
27+
fmt.Println("\t--accept (default application/json):\t\t\tset the default accept header for responses")
28+
fmt.Println()
29+
fmt.Println("The parameters are:")
30+
fmt.Println()
31+
fmt.Println("\ttest_directory:\t\t\t\t\t\tpoint to the directory where all the test files are located")
32+
fmt.Println()
33+
}
34+
1135
func main() {
36+
if len(os.Args) == 1 || len(os.Args) > 1 && (os.Args[1] == "--help" || os.Args[1] == "help" || os.Args[1] == "-h") {
37+
help()
38+
return
39+
}
1240
cfg, err := testing.LoadConfig(os.Args)
1341
if err != nil {
1442
log.Fatalf("Cannot read command line parameters: %s\n", err)

0 commit comments

Comments
 (0)