|
89 | 89 | parse Markdown files, and the [pflag](https://github.com/spf13/pflag) |
90 | 90 | package to parse the command line arguments. |
91 | 91 |
|
| 92 | +## Options |
| 93 | + |
| 94 | +Regular code blocks do not have a way to specify options. The only |
| 95 | +thing that can be specified about them are the commands and the |
| 96 | +responses. That means the expected return code must always be zero for |
| 97 | +the test to succeed≥ |
| 98 | + |
| 99 | +Sometimes, however, things are more complicated. Some commands are |
| 100 | +expected to return a different exit code than zero. Some commands |
| 101 | +return exit codes that are unknown up-front. Both options can be |
| 102 | +handled by specifying tests in fenced code blocks. Fenced code blocks |
| 103 | +may have an info string after the opening characters. This info string |
| 104 | +is usually used to specify the language of the following code. After |
| 105 | +the language specifier however, other information may |
| 106 | +follow. `shelldoc` uses this opportunity to allow the user to specify |
| 107 | +options about the test. These options are: |
| 108 | + |
| 109 | + ```shell {shelldocwhatever} |
| 110 | + % echo Hello && false |
| 111 | + Hello |
| 112 | + ``` |
| 113 | +Try executing this test: |
| 114 | + |
| 115 | +```shell {shelldocwhatever} |
| 116 | +> echo Hello && false |
| 117 | +Hello |
| 118 | +``` |
| 119 | + |
| 120 | +The _shelldocwhatever_ options tells `shelldoc` that the exit code of |
| 121 | +the following command does not matter. If any expected response is |
| 122 | +specified, it will still be evaluated. |
| 123 | + |
| 124 | + ```shell {shelldocexitcode=2} |
| 125 | + % (exit 2) |
| 126 | + ``` |
| 127 | + |
| 128 | +This executes the test, for tests: |
| 129 | + |
| 130 | +```shell {shelldocexitcode=2} |
| 131 | +> (exit 2) |
| 132 | +``` |
| 133 | + |
| 134 | +The _shelldocexitcode_ specifies an exact exit code that is |
| 135 | +expected. The test fails if the exit code of the command does not |
| 136 | +match the specified one, or if the response does not match the |
| 137 | +expected response. |
| 138 | + |
92 | 139 | ## Contributing |
93 | 140 |
|
94 | 141 | *shelldoc* |
|
0 commit comments