|
| 1 | +# [cliargs][repo-url] [![Go Reference][pkg-dev-img]][pkg-dev-url] [![CI Status][ci-img]][ci-url] [![MIT License][mit-img]][mit-url] |
| 2 | + |
| 3 | +A library to parse command line arguments for Golang application. |
| 4 | + |
| 5 | +This library provides the following functionalities: |
| 6 | + |
| 7 | +- Supports [POSIX][posix-args] & [GNU][gnu-args] like short and long options. |
| 8 | + - This library supports `--` option. |
| 9 | + - This library doesn't support numeric short option. |
| 10 | + - This library supports not `-ofoo` but `-o=foo` as an alternative to `-o foo` for short option. |
| 11 | +- Supports parsing with option configurations. |
| 12 | +- Supports parsing with a struct which stores option values and has struct tags of fields. |
| 13 | +- Is able to parse command line arguments including sub commands. |
| 14 | +- Generates help text from option configurations. |
| 15 | + |
| 16 | + |
| 17 | +## Import this package |
| 18 | + |
| 19 | +``` |
| 20 | +import "github.com/sttk/cliargs" |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +The usage of this library is described on the overview in the go package document. |
| 26 | + |
| 27 | +See https://pkg.go.dev/github.com/sttk/cliargs#pkg-overview |
| 28 | + |
| 29 | + |
| 30 | +## Supporting Go versions |
| 31 | + |
| 32 | +This library supports Go 1.18 or later. |
| 33 | + |
| 34 | +### Actual test results for each Go version: |
| 35 | + |
| 36 | +```sh |
| 37 | +% gvm-fav |
| 38 | +Now using version go1.18.10 |
| 39 | +go version go1.18.10 darwin/amd64 |
| 40 | +ok github.com/sttk/cliargs 0.907s coverage: 97.6% of statements |
| 41 | +ok github.com/sttk/cliargs/errors 1.052s coverage: 100.0% of statements |
| 42 | +ok github.com/sttk/cliargs/validators 0.553s coverage: 100.0% of statements |
| 43 | + |
| 44 | +Now using version go1.19.13 |
| 45 | +go version go1.19.13 darwin/amd64 |
| 46 | +ok github.com/sttk/cliargs 0.915s coverage: 97.6% of statements |
| 47 | +ok github.com/sttk/cliargs/errors 1.085s coverage: 100.0% of statements |
| 48 | +ok github.com/sttk/cliargs/validators 0.569s coverage: 100.0% of statements |
| 49 | + |
| 50 | +Now using version go1.20.14 |
| 51 | +go version go1.20.14 darwin/amd64 |
| 52 | +ok github.com/sttk/cliargs 0.559s coverage: 97.6% of statements |
| 53 | +ok github.com/sttk/cliargs/errors 1.065s coverage: 100.0% of statements |
| 54 | +ok github.com/sttk/cliargs/validators 1.590s coverage: 100.0% of statements |
| 55 | + |
| 56 | +Now using version go1.21.13 |
| 57 | +go version go1.21.13 darwin/amd64 |
| 58 | +ok github.com/sttk/cliargs 1.613s coverage: 97.6% of statements |
| 59 | +ok github.com/sttk/cliargs/errors 0.537s coverage: 100.0% of statements |
| 60 | +ok github.com/sttk/cliargs/validators 1.061s coverage: 100.0% of statements |
| 61 | + |
| 62 | +Now using version go1.22.6 |
| 63 | +go version go1.22.6 darwin/amd64 |
| 64 | +ok github.com/sttk/cliargs 0.607s coverage: 97.6% of statements |
| 65 | +ok github.com/sttk/cliargs/errors 1.712s coverage: 100.0% of statements |
| 66 | +ok github.com/sttk/cliargs/validators 1.160s coverage: 100.0% of statements |
| 67 | + |
| 68 | +Now using version go1.23.0 |
| 69 | +go version go1.23.0 darwin/amd64 |
| 70 | +ok github.com/sttk/cliargs 1.743s coverage: 97.6% of statements |
| 71 | +ok github.com/sttk/cliargs/errors 0.599s coverage: 100.0% of statements |
| 72 | +ok github.com/sttk/cliargs/validators 1.160s coverage: 100.0% of statements |
| 73 | + |
| 74 | +Back to go1.22.6 |
| 75 | +Now using version go1.22.6 |
| 76 | +``` |
| 77 | + |
| 78 | +## License |
| 79 | + |
| 80 | +Copyright (C) 2023-2024 Takayuki Sato |
| 81 | + |
| 82 | +This program is free software under MIT License.<br> |
| 83 | +See the file LICENSE in this distribution for more details. |
| 84 | + |
| 85 | + |
| 86 | +[repo-url]: https://github.com/sttk/cliargs-go |
| 87 | +[pkg-dev-img]: https://pkg.go.dev/badge/github.com/sttk/cliargs.svg |
| 88 | +[pkg-dev-url]: https://pkg.go.dev/github.com/sttk/cliargs |
| 89 | +[ci-img]: https://github.com/sttk/cliargs-go/actions/workflows/go.yml/badge.svg?branch=main |
| 90 | +[ci-url]: https://github.com/sttk/cliargs-go/actions |
| 91 | +[mit-img]: https://img.shields.io/badge/license-MIT-green.svg |
| 92 | +[mit-url]: https://opensource.org/licenses/MIT |
| 93 | + |
| 94 | +[posix-args]: https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html#Argument-Syntax |
| 95 | +[gnu-args]: https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html |
0 commit comments