You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the file_collision method without block, displaying help will show commands (diff,merge) that should not be supported.
The reason for this behavior is that the branching is done by block_given? in the file_collision method, but not in file_collision_help.
diff,merge works only when block is passed.
d - diff, show the differences between the old and the new
h - help, show this help
m - merge, run merge tool
HELP
end
Shouldn't the behavior be branched in the file_collision_help method as well, so that unsupported commands (diff,merge) are not displayed?
I checked with thor v1.2.1 and current main branch.
A working example is below:
# thor.rbrequire"thor"classMyCLI < Thordesc"hello","say hello"defhellofile_path="./foo.txt"if !File.exist?(file_path)File.write(file_path,"first write",mode: "w")returnendcontent="file_collision with no block"puts"=== #{content}"iffile_collision(file_path)File.write(file_path,content,mode: "w")endcontent="file_collision with block"puts"=== #{content}"iffile_collision(file_path){content}File.write(file_path,content,mode: "w")endendendMyCLI.start(ARGV)
$ ruby ./thor.rb hello
=== file_collision with no block
Overwrite ./foo.txt? (enter "h"for help) [Ynaqh] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
m - merge, run merge tool
Overwrite ./foo.txt? (enter "h"for help) [Ynaqh] y
=== file_collision with block
Overwrite ./foo.txt? (enter "h"for help) [Ynaqdhm] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
m - merge, run merge tool
Overwrite ./foo.txt? (enter "h"for help) [Ynaqdhm] d
- file_collision with no block
+ file_collision with block
Retrying...
Overwrite ./foo.txt? (enter "h"for help) [Ynaqdhm] y
Thank you.
The text was updated successfully, but these errors were encountered:
Hello.
When using the
file_collision
method without block, displaying help will show commands (diff,merge) that should not be supported.The reason for this behavior is that the branching is done by
block_given?
in thefile_collision
method, but not infile_collision_help
.diff,merge works only when
block
is passed.thor/lib/thor/shell/basic.rb
Line 287 in 376e141
thor/lib/thor/shell/basic.rb
Lines 308 to 315 in 376e141
thor/lib/thor/shell/basic.rb
Lines 387 to 397 in 376e141
Shouldn't the behavior be branched in the
file_collision_help
method as well, so that unsupported commands (diff,merge) are not displayed?I checked with thor v1.2.1 and current main branch.
A working example is below:
Thank you.
The text was updated successfully, but these errors were encountered: