This commit is contained in:
2024-04-03 20:59:37 +03:00
parent 0376ce4e06
commit 6795fa089a
20 changed files with 38 additions and 95 deletions
+8 -8
View File
@@ -58,7 +58,7 @@ Can be represented by the following command-line structure:
```go
package main
import "github.com/alecthomas/kong"
import "git.company.lan/gopkg/kong"
var CLI struct {
Rm struct {
@@ -202,14 +202,14 @@ There are two ways to handle commands in Kong.
When you call `kong.Parse()` it will return a unique string representation of the command. Each command branch in the hierarchy will be a bare word and each branching argument or required positional argument will be the name surrounded by angle brackets. Here's an example:
There's an example of this pattern [here](https://github.com/alecthomas/kong/blob/master/_examples/shell/commandstring/main.go).
There's an example of this pattern [here](https://git.company.lan/gopkg/kong/blob/master/_examples/shell/commandstring/main.go).
eg.
```go
package main
import "github.com/alecthomas/kong"
import "git.company.lan/gopkg/kong"
var CLI struct {
Rm struct {
@@ -256,7 +256,7 @@ passed through to `kong.Context.Run(...)` are also bindable to the target's
Finally, hooks can also contribute bindings via `kong.Context.Bind()` and `kong.Context.BindTo()`.
There's a full example emulating part of the Docker CLI [here](https://github.com/alecthomas/kong/tree/master/_examples/docker).
There's a full example emulating part of the Docker CLI [here](https://git.company.lan/gopkg/kong/tree/master/_examples/docker).
eg.
@@ -345,7 +345,7 @@ package main
import (
"fmt"
"github.com/alecthomas/kong"
"git.company.lan/gopkg/kong"
"github.com/joho/godotenv"
)
@@ -566,7 +566,7 @@ Both can coexist with standard Tag parsing.
| `default:"1"` | On a command, make it the default. |
| `default:"withargs"` | On a command, make it the default and allow args/flags from that command |
| `short:"X"` | Short name, if flag. |
| `aliases:"X,Y"` | One or more aliases (for cmd or flag). |
| `aliases:"X,Y"` | One or more aliases (for cmd or flag). |
| `required:""` | If present, flag/arg is required. |
| `optional:""` | If present, flag/arg is optional. |
| `hidden:""` | If present, command or flag is hidden. |
@@ -690,7 +690,7 @@ eg.
kong.Parse(&cli, kong.Configuration(kong.JSON, "/etc/myapp.json", "~/.myapp.json"))
```
[See the tests](https://github.com/alecthomas/kong/blob/master/resolver_test.go#L206) for an example of how the JSON file is structured.
[See the tests](https://git.company.lan/gopkg/kong/blob/master/resolver_test.go#L206) for an example of how the JSON file is structured.
#### List of Configuration Loaders
@@ -703,7 +703,7 @@ kong.Parse(&cli, kong.Configuration(kong.JSON, "/etc/myapp.json", "~/.myapp.json
Resolvers are Kong's extension point for providing default values from external sources. As an example, support for environment variables via the `env` tag is provided by a resolver. There's also a builtin resolver for JSON configuration files.
Example resolvers can be found in [resolver.go](https://github.com/alecthomas/kong/blob/master/resolver.go).
Example resolvers can be found in [resolver.go](https://git.company.lan/gopkg/kong/blob/master/resolver.go).
### `*Mapper(...)` - customising how the command-line is mapped to Go values