Compare commits
No commits in common. "main" and "v0.0.6" have entirely different histories.
1 changed files with 13 additions and 17 deletions
30
README.md
30
README.md
|
@ -1,14 +1,15 @@
|
||||||
### The "Help" package
|
### The "Version" package
|
||||||
|
|
||||||
This package provides --help flag feature to your cli.
|
This package provides --version flag feature to your cli.
|
||||||
It recognize both short and long flags.
|
It recognize both short and long flags. Version number is
|
||||||
|
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/help
|
go get code.foilhatguy.casa/pub/version
|
||||||
```
|
```
|
||||||
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:
|
||||||
|
@ -18,28 +19,23 @@ tools.go:
|
||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "code.foilhatguy.casa/pub/help"
|
_ "code.foilhatguy.casa/pub/version"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
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/help HELP.md
|
//go:generate go run code.foilhatguy.casa/pub/version
|
||||||
```
|
```
|
||||||
The last part in this directive is a name of the help file for
|
|
||||||
your application. It should be placed in the root directory
|
|
||||||
of your project along with **main.go** file. The help file
|
|
||||||
can be written ether in the MarkDown format, or in plain text.
|
|
||||||
MarkDown will be automatically converted in to plain text,
|
|
||||||
which is suitable for the console output.
|
|
||||||
|
|
||||||
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 generate a **help.go** file as a part of
|
The package will detect a version number from the latest git
|
||||||
the main package. It will contain code for --help flag detection.
|
tag from your project. Then it will generate a **version.go**
|
||||||
|
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 --help flag.
|
5. Build and run your application with the --version flag.
|
||||||
```shell
|
```shell
|
||||||
go run . --help
|
go run . --version
|
||||||
```
|
```
|
Loading…
Add table
Reference in a new issue