Skip to content

Commit

Permalink
Add command to print arguments in use (#1541)
Browse files Browse the repository at this point in the history
add command to print args used to launch minimega
  • Loading branch information
jacdavi authored Aug 15, 2024
1 parent c4adf79 commit 7bc31ac
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/minimega/misc_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"bufio"
"errors"
"flag"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -140,6 +141,16 @@ you can get without restarting minimega. Restarting minimega is preferable.`,
},
Call: wrapSimpleCLI(cliClearAll),
},
{ // args
HelpShort: "display arguments used",
HelpLong: `
Displays the CLI arguments minimega is using to run.
If an argument was not set by CLI, the default value is displayed.`,
Patterns: []string{
"args",
},
Call: wrapSimpleCLI(cliPrintArgs),
},
}

func cliQuit(ns *Namespace, c *minicli.Command, resp *minicli.Response) error {
Expand Down Expand Up @@ -401,3 +412,14 @@ func cliClearAll(ns *Namespace, c *minicli.Command, resp *minicli.Response) erro

return consume(runCommands(cmds...))
}

func cliPrintArgs(ns *Namespace, c *minicli.Command, resp *minicli.Response) error {
var header, values []string
flag.VisitAll(func(f *flag.Flag) {
header = append(header, f.Name)
values = append(values, f.Value.String())
})
resp.Header = header
resp.Tabular = [][]string{values}
return nil
}

0 comments on commit 7bc31ac

Please sign in to comment.