<commit_before>// Copyright 2013 <NAME> (<EMAIL>). All rights reserved.
// Use of this source code is governed by a MIT-license
// that can be found in the LICENSE file.

// Summarize size of directories and files in directories.
package main

import (
    . "github.com/shenwei356/util/bytesize"
    . "github.com/shenwei356/util/sortitem"
	"errors"
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"sort"
	"strings"
)

var (
	sortByAlphabet bool
	sortBySize     bool
	sortReverse    bool
)

// Parse arguments and show usage.
func init() {
	flag.BoolVar(&sortByAlphabet, "a", false, "sort by Alphabet.")
	flag.BoolVar(&sortBySize, "s", true, "sort by Size.")
	flag.BoolVar(&sortReverse, "r", false, "reverse order while sorting.")
	flag.Usage = func() {
		fmt.Printf("\nUsage: %s [OPTION]... [DIR]...\n\n", os.Args[0])
		fmt.Println("Summarize size of directories and files in directories.")
		fmt.Println("by <NAME> (<EMAIL>)\n")
		fmt.Println("OPTION:")
		flag.PrintDefaults()
	}
	flag.Parse()
	if len(flag.Args()) == 0 {
		flag.Usage()
	}
}

func main() {
	for _, arg := range flag.Args() {
		if strings.HasPrefix(arg, "-") {
			continue
		}
		if _, err := os.Stat(arg); err == nil {
			size, info, err := FolderSize(arg)
			if err != nil {
				fmt.Println(err)
			}
            // reverse order while sorting
			if sortReverse {
				if sortBySize { // sort by Alphabet
					sort.Sort(ByValue{info})
				} else {        // sort by Size
					sort.Sort(Reverse{ByKey{info}})
				}
			} else {
				if sortBySize {
					sort.Sort(Reverse{ByValue{info}})
				} else {
					sort.Sort(ByKey{info})
				}
			}

			fmt.Printf("\n%s: %v\n", arg, ByteSize(size))
			for _, item := range info {<commit_msg>update again<commit_after>// Copyright 2013 <NAME> (<EMAIL>). All rights reserved.
// Use of this source code is governed by a MIT-license
// that can be found in the LICENSE file.

// Summarize size of directories and files in directories.
package main

import (
	"errors"
	"flag"
	"fmt"
	. "github.com/shenwei356/util/bytesize"
	. "github.com/shenwei356/util/sortitem"
	"io/ioutil"
	"os"
	"path/filepath"
	"sort"
	"strings"
)

var (
	sortByAlphabet bool
	sortBySize     bool
	sortReverse    bool
)

// Parse arguments and show usage.
func init() {
	flag.BoolVar(&sortByAlphabet, "a", false, "sort by Alphabet.")
	flag.BoolVar(&sortBySize, "s", true, "sort by Size.")
	flag.BoolVar(&sortReverse, "r", false, "reverse order while sorting.")
	flag.Usage = func() {
		fmt.Printf("\nUsage: %s [OPTION]... [DIR]...\n\n", os.Args[0])
		fmt.Println("Summarize size of directories and files in directories.")
		fmt.Println("by <NAME> (<EMAIL>)\n")
		fmt.Println("OPTION:")
		flag.PrintDefaults()
	}
	flag.Parse()
	if len(flag.Args()) == 0 {
		flag.Usage()
	}
}

func main() {
	for _, arg := range flag.Args() {
		if strings.HasPrefix(arg, "-") {
			continue
		}
		if _, err := os.Stat(arg); err == nil {
			size, info, err := FolderSize(arg)
			if err != nil {
				fmt.Println(err)
			}
			// reverse order while sorting
			if sortReverse {
				if sortBySize { // sort by Alphabet
					sort.Sort(ByValue{info})
				} else { // sort by Size
					sort.Sort(Reverse{ByKey{info}})
				}
			} else {
				if sortBySize {
					sort.Sort(Reverse{ByValue{info}})
				} else {
					sort.Sort(ByKey{info})
				}
			}

			fmt.Printf("\n%s: %v\n", arg, ByteSize(size))
			for _, item := range info {
{'fraction_non_alphanumeric': 0.1626737651582372, 'fraction_numerical': 0.00709849157054126, 'mean_word_length': 2.9882075471698113, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3443965', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1230, 'n_words': 317}