2019-06-17 09:48:05 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-08-03 01:58:23 +00:00
|
|
|
"github.com/containous/traefik/v2/pkg/config/flag"
|
|
|
|
"github.com/containous/traefik/v2/pkg/log"
|
2019-06-17 09:48:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// FlagLoader loads configuration from flags.
|
|
|
|
type FlagLoader struct{}
|
|
|
|
|
|
|
|
// Load loads the command's configuration from flag arguments.
|
|
|
|
func (*FlagLoader) Load(args []string, cmd *Command) (bool, error) {
|
2019-06-24 14:40:06 +00:00
|
|
|
if len(args) == 0 {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2019-06-17 09:48:05 +00:00
|
|
|
if err := flag.Decode(args, cmd.Configuration); err != nil {
|
|
|
|
return false, fmt.Errorf("failed to decode configuration from flags: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.WithoutContext().Println("Configuration loaded from flags.")
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
}
|