Class: Meroku::CLI::Session

Inherits:
Object
  • Object
show all
Includes:
Meroku::CLI, Help
Defined in:
lib/meroku/cli/session.rb

Overview

A session is what is created when user executes the meroku command

Instance Method Summary collapse

Methods included from Help

#help

Methods included from Meroku::CLI

#add_git_remote, #apiusername, #create, #despawn, #keys_add, #login, #logout, #save_setting, #signup, #spawn

Methods included from Aws::Ec2

associate_address, #ec2_client, ec2_client, #make_instance, #tag

Constructor Details

#initialize(args) ⇒ Session

Returns a new instance of Session



8
9
10
11
12
13
14
# File 'lib/meroku/cli/session.rb', line 8

def initialize(args)
  processed = (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

Instance Method Details

#process_admin_command(arguments) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/meroku/cli/session.rb', line 37

def process_admin_command(arguments)
  processed = case arguments
              when 'infrastructure spawn'
                spawn && true
              when 'infrastructure despawn'
                despawn && true
              end
  processed
end

#process_user_login_command(arguments) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/meroku/cli/session.rb', line 16

def (arguments)
  case arguments
  when /\Asignup/
    
  when 'logout'
    logout && true
  when 'login'
     && true
  end
end

#process_user_other_command(arguments) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/meroku/cli/session.rb', line 27

def process_user_other_command(arguments)
  processed = case arguments
              when 'create'
                create && true
              when 'keys_add'
                keys_add && true
              end
  processed
end