Navigation Menu

Skip to content

Commit

Permalink
Validate command name (workaround)
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 15, 2015
1 parent 2ad1d98 commit 0406502
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/droonga-groonga
Expand Up @@ -22,6 +22,12 @@ require "droonga/command/base"
module Droonga
module Command
class Groonga < Base
class InvalidCommandName < StandardError
end

class MissingCommandName < StandardError
end

def run
parse_options do |option|
option.banner("Usage: droonga-groonga [groonga-command-name] [options]\n" +
Expand All @@ -34,6 +40,8 @@ module Droonga
end

groonga_command_name = ARGV.shift
assert_valid_command(groonga_command_name)

groonga_message = {
"dataset" => @options[:dataset],
"type" => groonga_command_name,
Expand All @@ -53,6 +61,11 @@ module Droonga
end

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

def build_params(argv)
params = {}
option_name = nil
Expand Down

0 comments on commit 0406502

Please sign in to comment.