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

Better Documentation for hs.fs.dir() #1927

Closed
latenitefilms opened this issue Aug 28, 2018 · 2 comments
Closed

Better Documentation for hs.fs.dir() #1927

latenitefilms opened this issue Aug 28, 2018 · 2 comments

Comments

@latenitefilms
Copy link
Contributor

Based on the API documentation it's not clear that hs.fs.dir() will return a nil value for the iterator function if something doesn't work. For example:

> iterFn, dirObj = hs.fs.dir("/Users/Guest/Documents")
print(string.format("iterFn: %s", iterFn))
print(string.format("dirObj: %s", dirObj))
2018-08-28 12:11:11: iterFn: nil
2018-08-28 12:11:11: dirObj: cannot open /Users/Guest/Documents: Permission denied

This becomes problematic when you're using a for loop, for example:

for file in hs.fs.dir("/Users/Guest/Documents") do 
	print(file)
end

Maybe either the documentation or the function itself needs to be re-thought @cmsj or @asmagill ?

@cmsj
Copy link
Member

cmsj commented Aug 29, 2018

I suspect probably the docs should include an example

latenitefilms added a commit to latenitefilms/hammerspoon that referenced this issue Sep 1, 2018
- Fixed `hs.fs.dir()` documentation
- Closes Hammerspoon#1927
@latenitefilms
Copy link
Contributor Author

Fixed in #1928

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

No branches or pull requests

2 participants