https://github.com/mrtazz/kong-ini
ini file configuration resolver for alecthomas/kong
https://github.com/mrtazz/kong-ini
cli command-line golang golang-library kong
Last synced: about 1 year ago
JSON representation
ini file configuration resolver for alecthomas/kong
- Host: GitHub
- URL: https://github.com/mrtazz/kong-ini
- Owner: mrtazz
- License: mit
- Created: 2020-12-26T23:19:22.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-26T23:49:53.000Z (over 5 years ago)
- Last Synced: 2025-02-02T00:27:39.831Z (over 1 year ago)
- Topics: cli, command-line, golang, golang-library, kong
- Language: Go
- Homepage:
- Size: 432 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# kong-ini
 [](http://godoc.org/github.com/alecthomas/kong)
A [kong](https://github.com/alecthomas/kong) configuration resolver for `.ini`
files.
## Usage
```go
var cli struct {
Config kong.ConfigFlag `help:"Load configuration."`
}
parser, err := kong.New(&cli, kong.Configuration(kongini.Loader, "/etc/myapp/config.ini", "~/.myapp.ini))
```
### Config Format
Given the following app definition:
```go
var cli struct {
Config kong.ConfigFlag `help:"Load configuration."`
Debug bool `kong:"name='debug'"`
String string `kong:"name='string'"`
Int int `kong:"name='int'"`
Slice []string `kong:"name='slice'"`
Intslice []int `kong:"name='intslice'"`
Floatslice []float64 `kong:"name='floatslice'"`
Map map[string]int `kong:"name='map'"`
Command struct {
IsFoo bool `kong:"name='isFoo'"`
Value string `kong:"name='value'"`
} `kong:"cmd"`
Default struct {
} `kong:"cmd"`
}
```
This would be the corresponding `.ini` file:
```ini
debug = true
string = "a string"
int = 1
slice = bla,foo bar,test
intslice = 1,2,3
floatslice = 1.2,2.3,3.4
map = """a=1;b=2;c=3"""
[command]
isFoo = false
value = bar
```
## Installation
```
go get github.com/mrtazz/kong-ini
```
## Inspiration
- [kong yaml resolver](https://github.com/alecthomas/kong-yaml)
- [globalconf](https://github.com/rakyll/globalconf)