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
Added list command #5
Conversation
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.
Thank you for the PR. Can you please have a look on requested changes?
aah cli is same as Go command. Typically sub commands with own set of flags in it. I believe it is unit testable. As of now I have not written one. I will check the go command unit test cases and write one for aah cli.
I recommend moving to something much more fine grained
Can you please shed some light? what you have in your mind? I would like to know.
aah/list.go
Outdated
|
||
func listRun(args []string) { | ||
|
||
gopath, err := ess.GoPath() |
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.
gopath
is already validated at aah.go, Can you please remove L#31 to L#36?
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.
Whoops.. I didn't see that
aah/list.go
Outdated
|
||
var count int | ||
|
||
filepath.Walk(gopath, func(path string, info os.FileInfo, err error) error { |
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.
Can you please update this to ess.Walk
? It is improved version of standard filepath.Walk
.
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.
Would do that... I didn't review the essentials package enough
} | ||
|
||
if info.IsDir() { | ||
return nil |
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.
Please use this one return filepath.SkipDir
.
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.
If SkipDir
is returned, the entire content of that directory would be skipped (https://golang.org/pkg/path/filepath/#WalkFunc).. And since the file path is being inspected for aah.project
, the command wouldn't work..
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.
Okay my bad. please keep return nil
.
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.
Done.. It was actually left there in the latest commit
aah/list.go
Outdated
|
||
if isAahProject(path) { | ||
count++ | ||
fmt.Println(filepath.Dir(path)) |
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.
Can you please add the path info into string slice and print it after L#60?
aah/list.go
Outdated
if isAahProject(path) { | ||
count++ | ||
fmt.Println(filepath.Dir(path)) | ||
return nil |
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 believe, this is return statement is not needed.
aah/list.go
Outdated
|
||
} | ||
|
||
func isAahProject(dir string) bool { |
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 think we are passing file
as param, not a directory. Shall we rename variable to 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.
Done
@adelowo Found the references to writing unit test for go cli program.
Thanks. |
Sorry for the late response, I had a bad weekend ... |
Don't worry, take your time. I hope you're doing well now. Thanks again for the PR. Once your changes is done, push it. I have a look and merge it. |
pkg rather than filepath from the standard lib
Thanks @jeevatkm . I am better now. As for this comment I recommend moving to something much more fine grained. I meant something like a dedicated cli library that (hopefully) would make writing tests easy enough. But I would go through those links and see if it is workable |
It seems you have incorporated all the requested changes. Please give me sometime. I will run it locally and get back to you if any improvements needed. Let's make it good together. |
No problem @jeevatkm |
@adelowo I have verified locally. It is working fine. Presentation needs to be improved, Windows OS compatibility and it's related code changes. I will do it after merging your PR. Thank you. Following is the goal to achieve:
|
This is a fix for go-aah/aah#42 ....