src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/prog/flags.go (about) 1 package prog 2 3 import "flag" 4 5 type FlagSet struct { 6 *flag.FlagSet 7 daemonPaths *DaemonPaths 8 json *bool 9 } 10 11 type DaemonPaths struct { 12 DB, Sock string 13 } 14 15 func (fs *FlagSet) DaemonPaths() *DaemonPaths { 16 if fs.daemonPaths == nil { 17 var dp DaemonPaths 18 fs.StringVar(&dp.DB, "db", "", 19 "[internal flag] Path to the database file") 20 fs.StringVar(&dp.Sock, "sock", "", 21 "[internal flag] Path to the daemon's Unix socket") 22 fs.daemonPaths = &dp 23 } 24 return fs.daemonPaths 25 } 26 27 func (fs *FlagSet) JSON() *bool { 28 if fs.json == nil { 29 var json bool 30 fs.BoolVar(&json, "json", false, 31 "Show the output from -buildinfo, -compileonly or -version in JSON") 32 fs.json = &json 33 } 34 return fs.json 35 }