Sha256: 5d6a17656522869b2d22c27a2813ba396cdd32f6fa8dd1966d2cf092516233e7

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require 'lino'
require_relative 'base'
require_relative 'mixins/environment'
require_relative 'mixins/required_params'

module RubyFly
  module Commands
    class Login < Base
      include Mixins::Environment
      include Mixins::RequiredParams

      def configure_command(builder, opts)
        builder = super(builder, opts)
        builder
          .with_subcommand('login') do |sub|
            sub = with_target(sub, opts[:target])
            sub = with_concourse_url(sub, opts[:concourse_url])
            sub = with_username(sub, opts[:username])
            sub = with_password(sub, opts[:password])
            sub = with_team(sub, opts[:team])
            sub
          end
      end

      private

      def required_params
        %i[target]
      end

      def with_target(builder, target)
        builder.with_option('-t', target)
      end

      def with_concourse_url(builder, concourse_url)
        return builder unless concourse_url

        builder.with_option('-c', concourse_url)
      end

      def with_username(builder, username)
        return builder unless username

        builder.with_option('-u', username)
      end

      def with_password(builder, password)
        return builder unless password

        builder.with_option('-p', password)
      end

      def with_team(builder, team)
        return builder unless team

        builder.with_option('-n', team)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_fly-0.40.0.pre.4 lib/ruby_fly/commands/login.rb
ruby_fly-0.40.0.pre.3 lib/ruby_fly/commands/login.rb
ruby_fly-0.40.0.pre.2 lib/ruby_fly/commands/login.rb
ruby_fly-0.40.0.pre.1 lib/ruby_fly/commands/login.rb
ruby_fly-0.39.0 lib/ruby_fly/commands/login.rb
ruby_fly-0.38.0.pre.5 lib/ruby_fly/commands/login.rb
ruby_fly-0.38.0.pre.4 lib/ruby_fly/commands/login.rb
ruby_fly-0.38.0.pre.3 lib/ruby_fly/commands/login.rb