arg-parse-gen.rb
##
# Name is a symbol or a string and underscores are converted to dashes when
# we generate the bash function for parsing the arguments. We make sure that
# there are no spaces in the name to simplify the generated bash function.
# The set of options can include :validation, which needs to be a single line
# bash command with a placeholder symbol. The placeholder symbol is $arg.
Name is a symbol or a string and underscores are converted to dashes when
we generate the bash function for parsing the arguments. We make sure that
there are no spaces in the name to simplify the generated bash function.
The set of options can include :validation, which needs to be a single line
bash command with a placeholder symbol. The placeholder symbol is $arg.
Name is a symbol or a string and underscores are converted to dashes when we generate the bash function for parsing the arguments . We make sure that there are no spaces in the name to simplify the generated bash function . The set of options can include : validation which needs to be a single line bash command with a placeholder symbol . The placeholder symbol is $arg .
def argument(name, opts = {})
    string_name = name.to_s
    if string_name[/  /]
      raise StandadError, "Argument name can not contain spaces."
    end
    if string_name[/__/]
      raise StandardError, "Argument name can not contain two underscores in a row."
    end
    if string_name.downcase != string_name
      raise StandardError, "Argument name must be all lowercase."
    end
    canonical_name = string_name.gsub('_', '-')
    if @arguments[canonical_name]
      raise StandardError, "Can not define the same argument twice: #{canonical_name}."
    end
    @arguments[canonical_name] = ArgumentOptions.new(canonical_name, opts).validate
  end
def argument ( name , opts = { } ) string_name = name . to_s if string_name [ / / ] raise StandadError , "Argument name can not contain spaces." end if string_name [ / __ / ] raise StandardError , "Argument name can not contain two underscores in a row." end if string_name . downcase != string_name raise StandardError , "Argument name must be all lowercase." end canonical_name = string_name . gsub ( '_' , '-' ) if @arguments [ canonical_name ] raise StandardError , "Can not define the same argument twice: #{canonical_name}." end @arguments [ canonical_name ] = ArgumentOptions . new ( canonical_name , opts ) . validate end
Name is a symbol or a string and underscores are converted to dashes when
we generate the bash function for parsing the arguments.
Name is a symbol or a string and underscores are converted to dashes when we generate the bash function for parsing the arguments .
name
opts