feat: add flag force-indirect

main
sudo pacman -Syu 2024-06-06 01:13:22 +07:00
parent 076fe2056d
commit 964ace5a01
3 changed files with 16 additions and 7 deletions

View File

@ -14,10 +14,11 @@ const (
type action struct {
ghClient *github.Client
flags struct {
depsFile string
depsURL string
verbose bool
dryRun bool
depsFile string
depsURL string
verbose bool
dryRun bool
forceIndirect bool
}
}
@ -36,6 +37,7 @@ func (a *action) getFlags(c *cli.Context) {
a.flags.depsURL = c.String(flagDepsURLName)
a.flags.dryRun = c.Bool(flagDryRun)
a.flags.forceIndirect = c.Bool(flagForceIndirectName)
a.log("Flags %+v\n", a.flags)
}

View File

@ -56,7 +56,7 @@ func (a *action) Run(c *cli.Context) error {
existVendor = true
}
depsStr, useDepFile, err := a.runReadDepsFile(c)
depsStr, useDepFile, err := a.runReadDepsFile()
if err != nil {
return err
}
@ -119,7 +119,7 @@ func (a *action) runGetImportedModules(c *cli.Context) (map[string]Module, error
}
// Ignore indirect module
if importedModule.Indirect {
if importedModule.Indirect && !a.flags.forceIndirect {
continue
}
@ -136,7 +136,7 @@ func (a *action) runGetImportedModules(c *cli.Context) (map[string]Module, error
return mapImportedModules, nil
}
func (a *action) runReadDepsFile(c *cli.Context) (depsStr string, useDepFile bool, err error) {
func (a *action) runReadDepsFile() (depsStr string, useDepFile bool, err error) {
// Try to read from url first
if a.flags.depsURL != "" {
depsURL, err := url.Parse(a.flags.depsURL)

View File

@ -30,6 +30,9 @@ const (
flagDryRun = "dry-run"
flagDryRunName = "demo what would be done"
flagForceIndirectName = "force-indirect"
flagForceIndirectUsage = "force update indirect module"
)
var aliasFlagVerbose = []string{"v"}
@ -70,6 +73,10 @@ func NewApp(
Name: flagDryRun,
Usage: flagDryRunName,
},
&cli.BoolFlag{
Name: flagForceIndirectName,
Usage: flagForceIndirectUsage,
},
},
Action: a.Run,
},