Sha256: cd04a0c64d91b267e53633a333978d49c3ca5a9a4956433e74956a20f2fe0345

Contents?: true

Size: 528 Bytes

Versions: 109

Compression:

Stored size: 528 Bytes

Contents

require "pathname"

module Standard
  class ParsesCliOption
    def call(argv, option_name)
      return unless (config_file = argv_value_for(argv, option_name))

      resolved_config = Pathname.new(config_file)
      if resolved_config.exist?
        resolved_config.expand_path
      else
        raise "Configuration file \"#{resolved_config.expand_path}\" not found."
      end
    end

    def argv_value_for(argv, option_name)
      return unless (index = argv.index(option_name))
      argv[index + 1]
    end
  end
end

Version data entries

109 entries across 109 versions & 3 rubygems

Version Path
standard-1.17.0 lib/standard/parses_cli_option.rb
standard-1.16.1 lib/standard/parses_cli_option.rb
standard-1.16.0 lib/standard/parses_cli_option.rb
standard-1.15.0 lib/standard/parses_cli_option.rb
standard-1.14.0 lib/standard/parses_cli_option.rb
standard-1.13.0 lib/standard/parses_cli_option.rb
standard-1.12.1 lib/standard/parses_cli_option.rb
standard-1.12.0 lib/standard/parses_cli_option.rb
standard-1.11.0 lib/standard/parses_cli_option.rb
standard-1.10.0 lib/standard/parses_cli_option.rb
standard-1.9.1 lib/standard/parses_cli_option.rb
standard-1.9.0 lib/standard/parses_cli_option.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/standard-1.8.0/lib/standard/parses_cli_option.rb
standard-1.8.0 lib/standard/parses_cli_option.rb
standard-1.7.3 lib/standard/parses_cli_option.rb
standard-1.7.2 lib/standard/parses_cli_option.rb
standard-1.7.1 lib/standard/parses_cli_option.rb
standard-1.7.0 lib/standard/parses_cli_option.rb
standard-1.6.0 lib/standard/parses_cli_option.rb
standard-1.5.0 lib/standard/parses_cli_option.rb