(stdout, stderr io.Writer, args []string)
| 101 | } |
| 102 | |
| 103 | func mainImplementation(stdout, stderr io.Writer, args []string) error { |
| 104 | var nameStyle sizes.NameStyle = sizes.NameStyleFull |
| 105 | var cpuprofile string |
| 106 | var jsonOutput bool |
| 107 | var jsonVersion int |
| 108 | var threshold sizes.Threshold = 1 |
| 109 | var progress bool |
| 110 | var version bool |
| 111 | var showRefs bool |
| 112 | |
| 113 | // Try to open the repository, but it's not an error yet if this |
| 114 | // fails, because the user might only be asking for `--help`. |
| 115 | repo, repoErr := git.NewRepository(".") |
| 116 | |
| 117 | flags := pflag.NewFlagSet("git-sizer", pflag.ContinueOnError) |
| 118 | flags.Usage = func() { |
| 119 | fmt.Fprint(stdout, usage) |
| 120 | } |
| 121 | |
| 122 | flags.VarP( |
| 123 | sizes.NewThresholdFlagValue(&threshold, 0), |
| 124 | "verbose", "v", "report all statistics, whether concerning or not", |
| 125 | ) |
| 126 | flags.Lookup("verbose").NoOptDefVal = "true" |
| 127 | |
| 128 | flags.Var( |
| 129 | sizes.NewThresholdFlagValue(&threshold, 1), |
| 130 | "no-verbose", "report statistics that are at all concerning", |
| 131 | ) |
| 132 | flags.Lookup("no-verbose").NoOptDefVal = "true" |
| 133 | |
| 134 | flags.Var( |
| 135 | &threshold, "threshold", |
| 136 | "minimum level of concern (i.e., number of stars) that should be\n"+ |
| 137 | " reported", |
| 138 | ) |
| 139 | |
| 140 | flags.Var( |
| 141 | sizes.NewThresholdFlagValue(&threshold, 30), |
| 142 | "critical", "only report critical statistics", |
| 143 | ) |
| 144 | flags.Lookup("critical").NoOptDefVal = "true" |
| 145 | |
| 146 | flags.Var( |
| 147 | &nameStyle, "names", |
| 148 | "display names of large objects in the specified `style`:\n"+ |
| 149 | " --names=none omit footnotes entirely\n"+ |
| 150 | " --names=hash show only the SHA-1s of objects\n"+ |
| 151 | " --names=full show full names", |
| 152 | ) |
| 153 | |
| 154 | flags.BoolVarP(&jsonOutput, "json", "j", false, "output results in JSON format") |
| 155 | flags.IntVar(&jsonVersion, "json-version", 1, "JSON format version to output (1 or 2)") |
| 156 | |
| 157 | defaultProgress := false |
| 158 | if f, ok := stderr.(*os.File); ok { |
| 159 | atty, err := isatty.Isatty(f.Fd()) |
| 160 | if err == nil && atty { |
no test coverage detected