Sha256: b3e54dcfc7cf5f2310f51b7fac865604c73cf39153060f44892cc7437c422791

Contents?: true

Size: 845 Bytes

Versions: 24

Compression:

Stored size: 845 Bytes

Contents

module Localeapp
  module CLI
    class Command
      def initialize(args = {})
        initialize_config(args)
        @output = args[:output] || $stdout
      end

      # requires the Localeapp configuration
      def initialize_config(args = {})
        Localeapp.configure # load defaults
        load_config_file
        set_command_line_arguments(args)
      end

      def set_command_line_arguments(args = {})
        sanitized_args = {}
        if args[:k]
          sanitized_args[:api_key] = args[:k]
        end
        sanitized_args.each do |setting, value|
          Localeapp.configuration.send("#{setting}=", value)
        end
      end

      def load_config_file
        Localeapp.default_config_file_paths.each do |path|
          next unless File.exist? path
          require path
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
localeapp-3.3.0 lib/localeapp/cli/command.rb
localeapp-3.2.0 lib/localeapp/cli/command.rb
localeapp-3.1.3 lib/localeapp/cli/command.rb
localeapp-3.1.2 lib/localeapp/cli/command.rb
localeapp-3.1.1 lib/localeapp/cli/command.rb
localeapp-3.1.0 lib/localeapp/cli/command.rb
localeapp-3.0.1 lib/localeapp/cli/command.rb
localeapp-3.0.0 lib/localeapp/cli/command.rb
localeapp-2.5.0 lib/localeapp/cli/command.rb
localeapp-2.4.0 lib/localeapp/cli/command.rb
localeapp-2.3.0 lib/localeapp/cli/command.rb
localeapp-2.2.0 lib/localeapp/cli/command.rb
localeapp-2.1.1 lib/localeapp/cli/command.rb
localeapp-2.1.0 lib/localeapp/cli/command.rb
localeapp-2.0.0 lib/localeapp/cli/command.rb
localeapp-1.0.2 lib/localeapp/cli/command.rb
localeapp-1.0.1 lib/localeapp/cli/command.rb
localeapp-1.0.0 lib/localeapp/cli/command.rb
localeapp-0.9.3 lib/localeapp/cli/command.rb
localeapp-0.9.2 lib/localeapp/cli/command.rb