-
Notifications
You must be signed in to change notification settings - Fork 0
/
base_flag_set.go
29 lines (23 loc) · 1.16 KB
/
base_flag_set.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
28
29
package upstart
import (
"flag"
"fmt"
"os"
)
// BaseFlagSet provides a *flag.FlagSet which corresponds with BaseConfig.
// Extend with additional flags to suit needs.
func BaseFlagSet(name string) *flag.FlagSet {
flagSet := flag.NewFlagSet(name, flag.ExitOnError)
flagSet.String("config", "", "path to .toml config file")
// Installation flags.
flagSet.Bool("install", false, "install the logserver service")
flagSet.String("install-with-custom-pipe", "", `when installing service: pipe flux-capacitor output to specified additional shell command; e.g. 'sudo -E -u $USER bash -c "~${USER}/go/bin/some-binary -application 1-1-my-app -process $(hostname)' would result in an upstart definition with 'flux-capacitor -flags | sudo -E -u $USER bash -c "~${USER}/go/bin/logger -application 1-1-my-app -process $(hostname)'. (optional)`)
flagSet.String("user", "", "specify the name of user the service will be run as (required when installing system service)")
flagSet.Bool("uninstall", false, "uninstall the logserver service")
flagSet.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %v:\n", name)
flagSet.SetOutput(os.Stderr)
flagSet.PrintDefaults()
}
return flagSet
}