parse_args argv

in lib/functions_framework/cli.rb [83:143]


    def parse_args argv 
      @option_parser = ::OptionParser.new do |op| 
        op.on "-t", "--target TARGET",
              "Set the name of the function to execute (defaults to #{DEFAULT_TARGET})" do |val|
          @target = val
        end
        op.on "-s", "--source SOURCE",
              "Set the source file to load (defaults to #{DEFAULT_SOURCE})" do |val|
          @source = val
        end
        op.on "--signature-type TYPE",
              "Asserts that the function has the given signature type. " \
              "Supported values are 'http' and 'cloudevent'." do |val|
          @signature_type = val
        end
        op.on "-P", "--pidfile PIDFILE", "Set the pidfile for the server (defaults to puma.pid)" do |val|
          @pidfile = val
        end
        op.on "-p", "--port PORT", "Set the port to listen to (defaults to 8080)" do |val|
          @port = val.to_i
        end
        op.on "-b", "--bind BIND", "Set the address to bind to (defaults to 0.0.0.0)" do |val|
          @bind = val
        end
        op.on "-e", "--environment ENV", "Set the Rack environment" do |val|
          @env = val
        end
        op.on "--min-threads NUM", "Set the minimum thread pool size" do |val|
          @min_threads = val
        end
        op.on "--max-threads NUM", "Set the maximum thread pool size" do |val|
          @max_threads = val
        end
        op.on "--[no-]detailed-errors", "Set whether to show error details" do |val|
          @detailed_errors = val
        end
        op.on "--verify", "Verify the app only, but do not run the server." do
          @what_to_do ||= :verify
        end
        op.on "-v", "--verbose", "Increase log verbosity" do
          @logging_level -= 1
        end
        op.on "-q", "--quiet", "Decrease log verbosity" do
          @logging_level += 1
        end
        op.on "--version", "Display the framework version" do
          @what_to_do ||= :version
        end
        op.on "--help", "Display help" do
          @what_to_do ||= :help
        end
      end
      begin
        @option_parser.parse! argv
        error! "Unrecognized arguments: #{argv}\n#{@option_parser}", 2 unless argv.empty?
      rescue ::OptionParser::ParseError => e
        error! "#{e.message}\n#{@option_parser}", 2
      end
      self
    end