mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: add YAML support to server (#6934)
This commit is contained in:
27
cli/root.go
27
cli/root.go
@ -16,6 +16,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
@ -250,6 +251,26 @@ func (r *RootCmd) Command(subcommands []*clibase.Cmd) (*clibase.Cmd, error) {
|
||||
return nil, merr
|
||||
}
|
||||
|
||||
var debugOptions bool
|
||||
|
||||
// Add a wrapper to every command to enable debugging options.
|
||||
cmd.Walk(func(cmd *clibase.Cmd) {
|
||||
h := cmd.Handler
|
||||
cmd.Handler = func(i *clibase.Invocation) error {
|
||||
if !debugOptions {
|
||||
return h(i)
|
||||
}
|
||||
|
||||
tw := tabwriter.NewWriter(i.Stdout, 0, 0, 4, ' ', 0)
|
||||
_, _ = fmt.Fprintf(tw, "Option\tValue Source\n")
|
||||
for _, opt := range cmd.Options {
|
||||
_, _ = fmt.Fprintf(tw, "%q\t%v\n", opt.Name, opt.ValueSource)
|
||||
}
|
||||
tw.Flush()
|
||||
return nil
|
||||
}
|
||||
})
|
||||
|
||||
if r.agentURL == nil {
|
||||
r.agentURL = new(url.URL)
|
||||
}
|
||||
@ -269,6 +290,12 @@ func (r *RootCmd) Command(subcommands []*clibase.Cmd) (*clibase.Cmd, error) {
|
||||
Value: clibase.URLOf(r.clientURL),
|
||||
Group: globalGroup,
|
||||
},
|
||||
{
|
||||
Flag: "debug-options",
|
||||
Description: "Print all options, how they're set, then exit.",
|
||||
Value: clibase.BoolOf(&debugOptions),
|
||||
Group: globalGroup,
|
||||
},
|
||||
{
|
||||
Flag: varToken,
|
||||
Env: envSessionToken,
|
||||
|
Reference in New Issue
Block a user