add config example (#3)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Co-authored-by: andrey1s <andrey@4devs.pro> Reviewed-on: #3 Co-authored-by: andrey <andrey@4devs.io> Co-committed-by: andrey <andrey@4devs.io>
This commit was merged in pull request #3.
This commit is contained in:
37
example/cmd/config/main.go
Normal file
37
example/cmd/config/main.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitoa.ru/go-4devs/config"
|
||||
"gitoa.ru/go-4devs/config/provider/env"
|
||||
"gitoa.ru/go-4devs/console"
|
||||
"gitoa.ru/go-4devs/console/example/pkg/command"
|
||||
"gitoa.ru/go-4devs/console/input"
|
||||
"gitoa.ru/go-4devs/console/input/cfg"
|
||||
)
|
||||
|
||||
const (
|
||||
Namespace = "fdevs"
|
||||
AppName = "console"
|
||||
)
|
||||
|
||||
// FDEVS_CONSOLE_CAT=env go run cmd/config/main.go fdevs:console:arg -b tmp.
|
||||
func main() {
|
||||
env := config.New(Namespace, AppName, []config.Provider{
|
||||
env.New(),
|
||||
})
|
||||
|
||||
console.
|
||||
New(console.WithInput(
|
||||
input.Chain(
|
||||
input.NewArgs(0),
|
||||
cfg.New(env.Value),
|
||||
),
|
||||
)).
|
||||
Add(
|
||||
command.Long(),
|
||||
command.Args(),
|
||||
).
|
||||
Execute(context.Background())
|
||||
}
|
||||
Reference in New Issue
Block a user