-
Notifications
You must be signed in to change notification settings - Fork 4
/
flags.go
27 lines (22 loc) · 1003 Bytes
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package flags
import (
"github.com/loft-sh/api/v4/pkg/product"
"github.com/loft-sh/loftctl/v4/pkg/client"
flag "github.com/spf13/pflag"
)
// GlobalFlags is the flags that contains the global flags
type GlobalFlags struct {
Config string
LogOutput string
Silent bool
Debug bool
}
// SetGlobalFlags applies the global flags
func SetGlobalFlags(flags *flag.FlagSet) *GlobalFlags {
globalFlags := &GlobalFlags{}
flags.StringVar(&globalFlags.LogOutput, "log-output", "plain", "The log format to use. Can be either plain, raw or json")
flags.StringVar(&globalFlags.Config, "config", client.DefaultCacheConfig, product.Replace("The loft config to use (will be created if it does not exist)"))
flags.BoolVar(&globalFlags.Debug, "debug", false, "Prints additional log messages to the output. Useful for debugging.")
flags.BoolVar(&globalFlags.Silent, "silent", false, product.Replace("Run in silent mode and prevents any loft log output except panics & fatals"))
return globalFlags
}