update-go-mod/internal/cli/action.go

46 lines
784 B
Go
Raw Normal View History

2022-07-22 14:09:34 +00:00
package cli
import (
"log"
"github.com/urfave/cli/v2"
)
2022-08-16 03:34:55 +00:00
const (
defaultDepsFile = ".deps"
)
2022-07-22 14:09:34 +00:00
type action struct {
flags struct {
depsFile string
2022-07-22 15:50:51 +00:00
depsURL string
2022-07-22 14:09:34 +00:00
verbose bool
dryRun bool
}
}
func (a *action) RunHelp(c *cli.Context) error {
return cli.ShowAppHelp(c)
}
func (a *action) getFlags(c *cli.Context) {
2022-08-16 03:34:55 +00:00
a.flags.verbose = c.Bool(flagVerboseName)
a.flags.depsFile = c.String(flagDepsFileName)
if a.flags.depsFile == "" {
a.log("Fallback to default deps file [%s]\n", defaultDepsFile)
a.flags.depsFile = defaultDepsFile
}
a.flags.depsURL = c.String(flagDepsURLName)
2022-07-22 14:09:34 +00:00
a.flags.dryRun = c.Bool(flagDryRun)
2022-08-16 03:34:55 +00:00
a.log("Flags %+v", a.flags)
2022-07-22 14:09:34 +00:00
}
func (a *action) log(format string, v ...interface{}) {
if a.flags.verbose {
log.Printf(format, v...)
}
}