Navigation Menu

Skip to content

Commit

Permalink
Show help document if no command name is given
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 15, 2015
1 parent 0406502 commit af9dd3a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/droonga-groonga
Expand Up @@ -39,12 +39,12 @@ module Droonga
:default => false)
end

groonga_command_name = ARGV.shift
assert_valid_command(groonga_command_name)
@command = ARGV.shift
assert_valid_command

groonga_message = {
"dataset" => @options[:dataset],
"type" => groonga_command_name,
"type" => @command,
"body" => build_params(ARGV),
}

Expand All @@ -57,13 +57,16 @@ module Droonga
puts(JSON.generate(body))
end

exit(true)
rescue InvalidCommandName, MissingCommandName
puts(@options)
exit(true)
end

private
def assert_valid_command(command)
raise InvalidCommandName.new(command) if /\A--.+\z/ =~ command
raise MissingCommandName.new if command.nil?
def assert_valid_command
raise InvalidCommandName.new(@command) if /\A--.+\z/ =~ @command
raise MissingCommandName.new if @command.nil?
end

def build_params(argv)
Expand Down

0 comments on commit af9dd3a

Please sign in to comment.