Replace flag text with const (#1391)

This commit is contained in:
Ta-Ching Chen
2019-11-09 22:13:35 +08:00
committed by GitHub
parent 6f5f6900b6
commit d3d8ff6c1b
73 changed files with 867 additions and 926 deletions
+3 -3
View File
@@ -30,9 +30,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(View),
}
wrapper.SetFlags(viewCmd, flag.FlagSet{
Optional: []flag.Flag{flag.RecordsFilterTimeToFlag, flag.RecordsFilterTimeFromFlag,
flag.RecordsFilterFunctionFlag, flag.RecordsFilterTriggerFlag, flag.RecordsVerbosityFlag,
flag.RecordsVvFlag},
Optional: []flag.Flag{flag.RecordsFilterTimeTo, flag.RecordsFilterTimeFrom,
flag.RecordsFilterFunction, flag.RecordsFilterTrigger, flag.RecordsVerbosity,
flag.RecordsVv},
})
command := &cobra.Command{
+13 -13
View File
@@ -33,37 +33,37 @@ type ViewSubCommand struct {
client *client.Client
}
func View(flags cli.Input) error {
c, err := util.GetServer(flags)
func View(flaginput cli.Input) error {
c, err := util.GetServer(flaginput)
if err != nil {
return err
}
opts := ViewSubCommand{
client: c,
}
return opts.do(flags)
return opts.do(flaginput)
}
func (opts *ViewSubCommand) do(flags cli.Input) error {
return opts.run(flags)
func (opts *ViewSubCommand) do(input cli.Input) error {
return opts.run(input)
}
func (opts *ViewSubCommand) run(flags cli.Input) error {
func (opts *ViewSubCommand) run(input cli.Input) error {
var verbosity int
if flags.Bool("v") && flags.Bool("vv") {
if input.Bool("v") && input.Bool("vv") {
return errors.New("conflicting verbosity levels, use either --v or --vv")
}
if flags.Bool("v") {
if input.Bool("v") {
verbosity = 1
}
if flags.Bool("vv") {
if input.Bool("vv") {
verbosity = 2
}
function := flags.String("function")
trigger := flags.String("trigger")
from := flags.String("from")
to := flags.String("to")
function := input.String("function")
trigger := input.String("trigger")
from := input.String("from")
to := input.String("to")
//Refuse multiple filters for now
if multipleFiltersSpecified(function, trigger, from+to) {