Merge #55: Document --lang in the README usage section
1 file+15−00/1 viewed
| 10 | 10 | | `--shout` | Upper-cases the greeting. | | |
| 11 | 11 | | `--version` | Prints the crate version and exits. | | |
| 12 | 12 | | `--times N` | Prints the greeting `N` times. Defaults to 1. | | |
| 13 | + | | `--lang LANG` | Greets in the given language. Supported values are `en`, `es` and `fr`. Defaults to `en`. | | |
| 13 | 14 | ||
| 14 | 15 | ```sh | |
| 15 | 16 | $ cargo run -- Ada | |
| 28 | 29 | ``` | |
| 29 | 30 | ||
| 30 | 31 | ```sh | |
| 32 | + | $ cargo run -- --lang es Ana | |
| 33 | + | ¡Hola, Ana! | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | ```sh | |
| 37 | + | $ cargo run -- --lang fr Luc | |
| 38 | + | Bonjour, Luc ! | |
| 39 | + | ``` | |
| 40 | + | ||
| 41 | + | ```sh | |
| 31 | 42 | $ cargo run -- --version | |
| 32 | 43 | 0.1.0 | |
| 33 | 44 | ``` | |
| 59 | 70 | ||
| 60 | 71 | An empty or whitespace-only name, such as `cargo run -- ""`, is treated as no name and the greeting uses `world`. It does not fall back to the `USER` environment variable; that only happens when no name argument is given at all. Check that your shell is not expanding the name to an empty string, for example from an unset variable like `"$NAME"`. | |
| 61 | 72 | ||
| 73 | + | **`error: --lang value must be one of en, es, fr, got "de"`** | |
| 74 | + | ||
| 75 | + | `--lang` only accepts `en`, `es` or `fr`. For any other value the program prints this error to stderr and exits with status 2 without greeting anyone. Pass one of the supported languages, for example `--lang es`. | |
| 76 | + | ||
| 62 | 77 | ## License | |
| 63 | 78 | ||
| 64 | 79 | This project is licensed under the MIT License. |