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

Update CLI to get the same output of linguist #41

Merged
merged 1 commit into from
Jun 27, 2017
Merged

Conversation

dpaz
Copy link
Contributor

@dpaz dpaz commented Jun 16, 2017

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.

@dpaz dpaz requested review from smola and mcarmonaa June 16, 2017 10:50
cli/enry/main.go Outdated
fmt.Printf("%s:\n", name)
for _, file := range language {
fmt.Printf("%s\n", file)
}
Copy link
Contributor

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)

}
Copy link
Contributor

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)

Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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()
Copy link
Contributor

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.

@dpaz
Copy link
Contributor Author

dpaz commented Jun 19, 2017

This PR should solve #39 and #27

cli/enry/main.go Outdated
printJson(out)
case *jsonFlag && *breakdownFlag:
printBreakDown(out, &buff)
fmt.Print(buff.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated line

@bzz
Copy link
Contributor

bzz commented Jun 20, 2017

👍 awesome, I guess it just need to be rebased on master now

@dpaz
Copy link
Contributor Author

dpaz commented Jun 21, 2017

The CI is failing due to #47 but this can be merged

@smola
Copy link
Contributor

smola commented Jun 23, 2017

Squash everything into a single commit. It's a small change, so it does not need that much detail in the logs.

@smola
Copy link
Contributor

smola commented Jun 26, 2017

Please, rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants