mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
33a04f8dc1
Instead of putting all possible flags in prog.Flags, flags are now registered by the individual subprograms. The 3 flags -sock, -db and -json are shared by multiple subprograms and still handled by the prog package. This new design allows separating the support for -cpuprofile into a separate subprogram, which is no longer included by the default entry point, making the binary slightly smaller. A new entrypoint "withpprof" is created. Also include the LSP subprogram in the nodaemon entry point.
33 lines
673 B
Go
33 lines
673 B
Go
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
|
|
fs.StringVar(&dp.DB, "db", "", "[internal flag] path to the database")
|
|
fs.StringVar(&dp.Sock, "sock", "", "[internal flag] path to the daemon socket")
|
|
fs.daemonPaths = &dp
|
|
}
|
|
return fs.daemonPaths
|
|
}
|
|
|
|
func (fs *FlagSet) JSON() *bool {
|
|
if fs.json == nil {
|
|
var json bool
|
|
fs.BoolVar(&json, "json", false, "show output in JSON. Useful with -buildinfo and -compileonly")
|
|
fs.json = &json
|
|
}
|
|
return fs.json
|
|
}
|