Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 #5

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/drsz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ func cli() Config {

csvArg := flag.String("o", "none", "save output to the provided CSV filepath")
concArg := flag.Int("c", 0, "number of concurrent directory size searches")
verArg := flag.Bool("v", false, "program version")
flag.Parse()

if *verArg {
fmt.Printf("drsz %s\n", drsz.Version)
os.Exit(0)
}

rootArg := flag.Arg(0)

// validate root arg
Expand Down
3 changes: 3 additions & 0 deletions constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package drsz

const Version = "v2.0"
15 changes: 10 additions & 5 deletions drsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ func (r *RootDir) CalcStats(concLimit uint8) error {

wg.Wait() // wait for goroutines to finish

if len(errors) != 0 {
// errors encountered, just return first one for simplicity for now
return fmt.Errorf("encountered %d errors, the first being: %v", len(errors), errors[0])
}

// print results using tabwriter
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', 0)
// add blank row
Expand All @@ -205,6 +200,16 @@ func (r *RootDir) CalcStats(concLimit uint8) error {
for _, d := range r.TopDirs {
fmt.Fprintf(tw, "%s\t%s\t%s\n", d.Name(), d.SizeString(), d.LastModified.Local().String())
}

// print errors and their associated directories
if len(errors) != 0 {
fmt.Fprintln(tw, "")
fmt.Fprintln(tw, "***WARN*** Processing failed on the following directories ***WARN***")
for i, err := range errors {
fmt.Fprintf(tw, "%d: %v\n", i+1, err)
}
}

tw.Flush()

return nil
Expand Down