2022-02-05 22:48:55 +08:00
|
|
|
package prog
|
|
|
|
|
|
|
|
import "flag"
|
|
|
|
|
|
|
|
type FlagSet struct {
|
|
|
|
*flag.FlagSet
|
|
|
|
daemonPaths *DaemonPaths
|
|
|
|
json *bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type DaemonPaths struct {
|
|
|
|
DB, Sock string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FlagSet) DaemonPaths() *DaemonPaths {
|
|
|
|
if fs.daemonPaths == nil {
|
|
|
|
var dp DaemonPaths
|
2022-03-03 08:29:49 +08:00
|
|
|
fs.StringVar(&dp.DB, "db", "",
|
|
|
|
"[internal flag] Path to the database file")
|
|
|
|
fs.StringVar(&dp.Sock, "sock", "",
|
|
|
|
"[internal flag] Path to the daemon's UNIX socket")
|
2022-02-05 22:48:55 +08:00
|
|
|
fs.daemonPaths = &dp
|
|
|
|
}
|
|
|
|
return fs.daemonPaths
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FlagSet) JSON() *bool {
|
|
|
|
if fs.json == nil {
|
|
|
|
var json bool
|
2022-03-03 08:29:49 +08:00
|
|
|
fs.BoolVar(&json, "json", false,
|
|
|
|
"Show the output from -buildinfo, -compileonly or -version in JSON")
|
2022-02-05 22:48:55 +08:00
|
|
|
fs.json = &json
|
|
|
|
}
|
|
|
|
return fs.json
|
|
|
|
}
|