-
Notifications
You must be signed in to change notification settings - Fork 51
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
Update CLI to get the same output of linguist #41
Conversation
cli/enry/main.go
Outdated
fmt.Printf("%s:\n", name) | ||
for _, file := range language { | ||
fmt.Printf("%s\n", file) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an empty line
cli/enry/main.go
Outdated
fileCount[name] = len(language) | ||
total += len(language) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an empty line
cli/enry/main.go
Outdated
for name, language := range out { | ||
fileCount[name] = len(language) | ||
total += len(language) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this empty line
cli/enry/main.go
Outdated
@@ -77,8 +80,17 @@ func main() { | |||
log.Fatal(err) | |||
} | |||
|
|||
data, _ := json.MarshalIndent(out, "", " ") | |||
fmt.Printf("%s\n", data) | |||
if *jsonFlag && !*breakdownFlag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a switch
is better here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am doing these extrange ifs because linguist flags work weird, if you have JSON and breakdown flags active, only breakdown output is printed. If you have only breakdown flag active, percent output and breakout output are printed.
cli/enry/main.go
Outdated
printBreakDown(out) | ||
} else if *breakdownFlag { | ||
printPercents(out) | ||
fmt.Println() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe is better to use bytes.Buffer
to generate the complete string, and then print it to stdout instead of use fmt.Println()
here and into printPercents
and printBreakDown
functions.
cli/enry/main.go
Outdated
printJson(out) | ||
case *jsonFlag && *breakdownFlag: | ||
printBreakDown(out, &buff) | ||
fmt.Print(buff.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated line
👍 awesome, I guess it just need to be rebased on master now |
The CI is failing due to #47 but this can be merged |
Squash everything into a single commit. It's a small change, so it does not need that much detail in the logs. |
Please, rebase. |
There are still some differences, our json is pretty printed and the percents are not the same because they use all the files in the repo and we only use the ones which are classified.
Tell me if I should change these things too.