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

48 lines
856 B
Go
Raw Normal View History

2022-07-22 14:09:34 +00:00
package cli
import (
"log"
2023-09-05 17:12:12 +00:00
"github.com/google/go-github/v55/github"
2022-07-22 14:09:34 +00:00
"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 {
2023-08-15 10:59:16 +00:00
ghClient *github.Client
flags struct {
2022-07-22 14:09:34 +00:00
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-24 15:38:51 +00:00
a.log("Flags %+v\n", 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...)
}
}