Skip to content

Commit

Permalink
Add hidden arg
Browse files Browse the repository at this point in the history
  • Loading branch information
knightpp committed Jan 29, 2024
1 parent 6f946f4 commit 4dcafe7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
var (
fSelectAll bool
fSelectAllNoConfirm bool
fHidden bool
fDryRun bool
fVersion bool
fSort bool
Expand All @@ -28,6 +29,7 @@ func init() {
flag.BoolVar(&fDryRun, "d", false, "dry run, just print what will be executed")
flag.BoolVar(&fVersion, "v", false, "show version information")
flag.BoolVar(&fSort, "s", false, "sort require lines")
flag.BoolVar(&fHidden, "h", false, "show indirect")
}

func main() {
Expand Down Expand Up @@ -80,7 +82,7 @@ func updateGoMod(gomodPath string) error {
return fmt.Errorf("parse direct deps: %w", err)
}

modules := extractDirectDeps(gomod)
modules := extractDeps(gomod)

if len(modules) == 0 {
return errors.New("no direct dependencies found")
Expand Down Expand Up @@ -120,10 +122,10 @@ func parseGoMod(path string) (*modfile.File, error) {
return ast, nil
}

func extractDirectDeps(gomod *modfile.File) []module.Version {
func extractDeps(gomod *modfile.File) []module.Version {
var modules []module.Version
for _, req := range gomod.Require {
if req.Indirect {
if !fHidden && req.Indirect {
continue
}

Expand Down

0 comments on commit 4dcafe7

Please sign in to comment.