sdboyer / gps

your dependencies have arrived
MIT License
270 stars 24 forks source link

Removing nested trace output from trace.go #168

Closed krisnova closed 7 years ago

krisnova commented 7 years ago

My first attempt at a PR..

Closes https://github.com/sdboyer/gps/issues/129

@sdboyer when you get a chance let me know what you think!

krisnova commented 7 years ago

Sample output with Kubernetes kops and example.go

glide install && go build -o gps example.go && chmod +x gps && mv gps ~/Workspace/kops && cd ~/Workspace/kops/ && ./gps && rm -rf .repocache; cd -

Output here

codecov[bot] commented 7 years ago

Codecov Report

Merging #168 into master will increase coverage by -0.06%.

@@            Coverage Diff             @@
##           master     #168      +/-   ##
==========================================
- Coverage   79.34%   79.28%   -0.06%     
==========================================
  Files          24       24              
  Lines        3698     3707       +9     
==========================================
+ Hits         2934     2939       +5     
- Misses        567      570       +3     
- Partials      197      198       +1
Impacted Files Coverage Δ
trace.go 71.69% <75%> (-1.5%) :x:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2fe10c6...3cd8278. Read the comment docs.

codecov[bot] commented 7 years ago

Codecov Report

Merging #168 into master will increase coverage by -0.29%.

@@            Coverage Diff             @@
##           master     #168      +/-   ##
==========================================
- Coverage   79.34%   79.05%   -0.29%     
==========================================
  Files          24       24              
  Lines        3698     3709      +11     
==========================================
- Hits         2934     2932       -2     
- Misses        567      577      +10     
- Partials      197      200       +3
Impacted Files Coverage Δ
trace.go 72.22% <81.48%> (-0.98%) :x:
source_errors.go 0% <ø> (-50%) :x:
source.go 42.69% <ø> (-2.93%) :x:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2fe10c6...5182d7d. Read the comment docs.

sdboyer commented 7 years ago

Huh. Well. Simplest really is best - I think I might like that more than any of the other options I discussed in #129 :)

One thing, though - I think it might still be valuable to indent the "inner" rows - things not starting with "select", "attempt", "revisit" or "backtrack". Yes, you can infer it from the counter on the left, but that's not the most useful for visual scanning and grouping. I'd at least like to see if doing it that way provides an improved experience.

Also, that leading pipe feels unnecessary now - maybe we can drop that, too.

krisnova commented 7 years ago

@sdboyer Pushed up changes per your review.. Totally agree about the pipe

I think I got all of the "inner" messages - but if you could check that would be helpful

Also I indented the "inner" messages over 2 spaces.. I tried a few options, and that looked the best.

Sample output:

Root project is "/Users/kris/Workspace/kops"
 69 transitively valid internal packages
 132 external packages imported from 17 projects
(0)   ✓ select (root)
(1)   ? attempt github.com/ghodss/yaml with 1 pkgs; 1 versions to try
(1)       try github.com/ghodss/yaml@master
(1)   ✓ select github.com/ghodss/yaml@master w/1 pkgs
(2)   ? attempt github.com/sergi/go-diff with 1 pkgs; 1 versions to try
(2)       try github.com/sergi/go-diff@master
(2)   ✓ select github.com/sergi/go-diff@master w/1 pkgs
(3)   ? attempt github.com/golang/glog with 1 pkgs; 1 versions to try
(3)       try github.com/golang/glog@master
(3)   ✓ select github.com/golang/glog@master w/1 pkgs
(4)   ? attempt github.com/spf13/viper with 1 pkgs; 1 versions to try
(4)       try github.com/spf13/viper@master
(4)   ✓ select github.com/spf13/viper@master w/1 pkgs
(5)   ? attempt github.com/mitchellh/mapstructure with 1 pkgs; 1 versions to try
(5)       try github.com/mitchellh/mapstructure@master
(5)   ✓ select github.com/mitchellh/mapstructure@master w/1 pkgs
(6)   ? attempt github.com/spf13/afero with 1 pkgs; 1 versions to try
(6)       try github.com/spf13/afero@master
(6)   ✓ select github.com/spf13/afero@master w/1 pkgs
(7)   ? attempt github.com/spf13/cobra with 2 pkgs; 1 versions to try
(7)       try github.com/spf13/cobra@master
(7)   ✓ select github.com/spf13/cobra@master w/2 pkgs
(8)   ? attempt github.com/inconshreveable/mousetrap with 1 pkgs; 1 versions to try
(8)       try github.com/inconshreveable/mousetrap@master
(8)   ✓ select github.com/inconshreveable/mousetrap@master w/1 pkgs
(9)   ? attempt golang.org/x/text with 2 pkgs; 1 versions to try
(9)       try golang.org/x/text@master
sdboyer commented 7 years ago

Yep, we have a winner! 🎉