Class: Stax::Cli

Inherits:
Base
  • Object
show all
Defined in:
lib/stax/cli.rb,
lib/stax/cli/ls.rb,
lib/stax/cli/new.rb,
lib/stax/cli/crud.rb,
lib/stax/cli/version.rb,
lib/stax/cli/generate.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



39
40
41
42
43
44
45
# File 'lib/stax/cli/crud.rb', line 39

def change
  stack_objects.each do |s|
    if s.exists?
      s.change
    end
  end
end

#createObject



17
18
19
20
21
22
23
24
25
# File 'lib/stax/cli/crud.rb', line 17

def create
  stack_objects.each do |s|
    if s.exists?
      say("Skipping: #{s.stack_name} exists", :yellow)
    elsif y_or_n?("Create #{s.stack_name}?", :yellow)
      s.create
    end
  end
end

#deleteObject



48
49
50
51
52
53
54
55
56
# File 'lib/stax/cli/crud.rb', line 48

def delete
  stack_objects.reverse.each do |s|
    if s.exists?
      s.delete
    else
      say("#{s.stack_name} does not exist", :green)
    end
  end
end

#generate(name = nil, *args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stax/cli/generate.rb', line 7

def generate(name = nil, *args)
  Stax::Generators.load_builtin_generators
  Stax::Generators.load_local_generators

  if name.nil?
    Stax::Generators::Base.subclasses.each do |g|
      say_status(g.command_name, g.desc, :bold)
    end
  else
    klass = Stax::Generators.find(name)
    fail_task("Unknown generator #{name}") unless klass
    klass.start(args)
  end
end

#ls(prefix = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/stax/cli/ls.rb', line 35

def ls(prefix = nil)
  if options[:account]
    
  elsif options[:all]
    ls_stacks_with_prefix(prefix)
  else
    ls_staxfile_stacks
  end
end

#new(dir) ⇒ Object



5
6
7
8
# File 'lib/stax/cli/new.rb', line 5

def new(dir)
  Stax::Generators.load_builtin_generators
  Stax::Generators::NewGenerator.start(Array(dir))
end

#updateObject



28
29
30
31
32
33
34
35
36
# File 'lib/stax/cli/crud.rb', line 28

def update
  stack_objects.each do |s|
    if s.exists?
      y_or_n?("Update #{s.stack_name}?", :yellow) && s.update
    else
      say("#{s.stack_name} does not exist")
    end
  end
end

#versionObject



7
8
9
# File 'lib/stax/cli/version.rb', line 7

def version
  puts Stax::VERSION
end