-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 unix-like commands to FileUtils #3420
Conversation
@ghivert Awesome!! ❤️ I'll review it soon. |
# FileUtils.cd("to/directory") { puts "Do something useful here!" } | ||
# ``` | ||
def cd(path : String, &block) | ||
Dir.cd(path, &block) |
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 implement this as:
Dir.cd(path) { yield }
This avoids closures, as described here (might be improved in the future)
@asterite Hopefully not too off-topic, but why exactly do we have |
@ghivert Looks really good! :-) The only thing I would change (in addition to the block comment above) is to mark methods that you have right now returning |
@RX14 The idea is that include FileUtils
# Now you can write things almost as in a unix shell
cd "foo"
mv "bar", "baz"
mkdir_p "qux" In this particular case these aliases don't bother because it's not like there will be multiple possible implementations of this and these aliases will need to be defined over and over. |
describe "pwd" do | ||
it "returns the current working directory" do | ||
cwd = Dir.current | ||
(cwd == FileUtils.pwd).should be_true |
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.
FileUtils.pwd.should eq(Dir.current)
?
@asterite Actually, functions returned 0 to mimic shell behavior. But it seems better for me now. :) |
@ghivert Sure, that would be great! I forgot about this PR, it looks good now. Thank you so much for this! ❤️ |
Hi.
I tried to add some unix-like commands in FileUtils, as asked in request #1058.
Hope it will be good.