README.md updated.
This commit is contained in:
parent
e0a8e22fea
commit
4a628ccc7e
1 changed files with 10 additions and 13 deletions
23
README.md
23
README.md
|
@ -1,15 +1,14 @@
|
||||||
### The "Version" package
|
### The "Help" package
|
||||||
|
|
||||||
This package provides --version flag feature to your cli.
|
This package provides --help flag feature to your cli.
|
||||||
It recognize both short and long flags. Version number is
|
It recognize both short and long flags.
|
||||||
automatically added from the latest tag in your git repository.
|
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
1. Download the package by **go get** command:
|
1. Download the package by **go get** command:
|
||||||
```shell
|
```shell
|
||||||
go get code.foilhatguy.casa/pub/version
|
go get code.foilhatguy.casa/pub/help
|
||||||
```
|
```
|
||||||
2. Add the package as a tool dependency to your project in
|
2. Add the package as a tool dependency to your project in
|
||||||
tools.go:
|
tools.go:
|
||||||
|
@ -19,23 +18,21 @@ tools.go:
|
||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "code.foilhatguy.casa/pub/version"
|
_ "code.foilhatguy.casa/pub/help"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
3. In the main package add a go:generate directive:
|
3. In the main package add a go:generate directive:
|
||||||
```go
|
```go
|
||||||
//go:generate go run code.foilhatguy.casa/pub/version
|
//go:generate go run code.foilhatguy.casa/pub/help
|
||||||
```
|
```
|
||||||
4. Run code generator by **go generate** command:
|
4. Run code generator by **go generate** command:
|
||||||
```shell
|
```shell
|
||||||
go generate ./...
|
go generate ./...
|
||||||
```
|
```
|
||||||
The package will detect a version number from the latest git
|
The package will generate a **help.go** file as a part of
|
||||||
tag from your project. Then it will generate a **version.go**
|
the main package. It will contain code for --help flag detection.
|
||||||
file as a part of the main package. It will contain a version
|
|
||||||
number as a constant and code for --version flag detection.
|
|
||||||
|
|
||||||
5. Build and run your application with the --version flag.
|
5. Build and run your application with the --help flag.
|
||||||
```shell
|
```shell
|
||||||
go run . --version
|
go run . --help
|
||||||
```
|
```
|
Loading…
Add table
Reference in a new issue