Skip to content

Commit 7dfded4

Browse files
committed
Fix #8: runx help or --help should show usage.
1 parent d892e8f commit 7dfded4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

runx.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def show_help
5454
end
5555
end
5656

57+
def task_defined?(name)
58+
!@tasks[name.to_s.downcase].nil?
59+
end
60+
5761
def run_task(name, *args)
5862
task = @tasks[name.to_s.downcase]
5963
if task.nil?
@@ -124,7 +128,11 @@ def find_runfile
124128
$stderr.puts "[runx] In #{dir}."
125129

126130
task_name = ARGV[0]
127-
if !task_name
131+
132+
is_help = ['--help', 'help'].include?(task_name)
133+
show_help = !task_name || (is_help && !manager.task_defined?(task_name))
134+
135+
if show_help
128136
$stderr.puts
129137
manager.show_help
130138
else

0 commit comments

Comments
 (0)