Sha256: 92b01993ad0c6b8c856b86fabeb89312fc6c68d5dd5016c406610366211c34d5

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

module Meroku
  module CLI
    # A session is what is created when user executes the meroku command
    class Session
      include Meroku::CLI
      include Meroku::CLI::Help

      def initialize(args)
        processed = process_user_login_command(args.join(' ')) ||
                    process_user_other_command(args.join(' ')) ||
                    process_admin_command(args.join(' '))
        puts "Unknown command #{args.join(' ')}\n\n#{help}" unless processed
        exit 1 unless processed
      end

      def process_user_login_command(arguments)
        case arguments
        when /\Asignup/
          signup
        when 'logout'
          logout
        when 'login'
          login
        end
      end

      def process_user_other_command(arguments)
        case arguments
        when 'create'
          create
        when 'keys:add'
          keys_add
        end
      end

      def process_admin_command(arguments)
        case arguments
        when 'infrastructure spawn'
          spawn
        when 'infrastructure despawn'
          despawn
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meroku-2.0.22 lib/meroku/cli/session.rb
meroku-2.0.21 lib/meroku/cli/session.rb
meroku-2.0.20 lib/meroku/cli/session.rb
meroku-2.0.19 lib/meroku/cli/session.rb
meroku-2.0.18 lib/meroku/cli/session.rb
meroku-2.0.17 lib/meroku/cli/session.rb
meroku-2.0.16 lib/meroku/cli/session.rb
meroku-2.0.14 lib/meroku/cli/session.rb
meroku-2.0.13 lib/meroku/cli/session.rb
meroku-2.0.11 lib/meroku/cli/session.rb
meroku-2.0.10 lib/meroku/cli/session.rb
meroku-2.0.9 lib/meroku/cli/session.rb