Class: BeamUp::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/beam_up/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
14
# File 'lib/beam_up/cli.rb', line 10

def initialize(arguments)
  @arguments = arguments
  @provider = nil
  @config_file = nil
end

Class Method Details

.start(arguments) ⇒ Object



6
7
8
# File 'lib/beam_up/cli.rb', line 6

def self.start(arguments)
  new(arguments).run
end

Instance Method Details

#deployObject



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/beam_up/cli.rb', line 62

def deploy
  input = parse_options

  BeamUp.with_progress do
    beamed = BeamUp.deploy! input, provider: @provider, config_file: @config_file

    puts beamed.message
    puts "Deploy ID: #{beamed.deploy_id}" if beamed.deploy_id

    exit(1) unless beamed.success?
  end
end

#deploy_or_helpObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/beam_up/cli.rb', line 51

def deploy_or_help
  if File.exist?(".beam_up.yml") || File.exist?("config/beam_up.yml")
    deploy
  else
    puts "No .beam_up.yml found. Run `beam_up init PROVIDER` to get started"
    puts

    help
  end
end

#initObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/beam_up/cli.rb', line 31

def init
  provider_name = @arguments.shift&.downcase

  if provider_name.nil? || !PROVIDERS.key?(provider_name)
    puts "Available providers:"

    PROVIDERS.keys.reject { it == "transporter" }.sort.each { puts "  - #{it}" }

    exit(1)
  end

  path = BeamUp.init!(provider_name)

  puts "Configured #{provider_name} in #{path}"
rescue ConfigurationError => error
  puts error.message

  exit(1)
end

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/beam_up/cli.rb', line 16

def run
  command = @arguments.shift

  case command
  when "init" then init
  when "scotty" then scotty
  when "--help", "-h" then help
  when nil then deploy_or_help
  else
    @arguments.unshift(command)

    deploy
  end
end

#scottyObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/beam_up/cli.rb', line 75

def scotty
  puts <<~STARFLEET
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*+=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%***++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%***+++=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%**+++++++%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*+++++++++-%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***+*++++++++:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%****++++++++++=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@***+*++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@%***+++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@*****+++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@%****+++++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@%+****+++++++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@%%=##%***+++++++++++++++++++++==++*-%%@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@%%%#*+-=#*%%*++++++++++++++++++++++++==*+*#.++**@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@%-*+.#%%#####**++++++++++++++++++++++++++=+++++++*%+*%@@@@@@@@@@@@@@
    @@@@@@@@%%%*+=#%%%%#%%%%-*+++++++++++++++++++++++++++===++++=+==*:=**@@@@@@@@@@@
    @@@@@@%%*+-#%%%%%%%%###%*++++++++++++++++++++++++++++==-=++++++====+.+:%@@@@@@@@
    @@@@@%*+-#%%%%%%%%#%#%#=+++++++++++++++++++++++++++++===:=++++++======*==%@@@@@@
    @@@@%*:###%%%%%######%%++++++++++++++++++++++++++++======:++++++========*=:%@@@@
    @@%%+-###############%-++++++++++++++++++++++++++++=======.+++++++========:*%@@@
    @@#+=#################++++++++++++++++++++++++++++++=======-++++++=+=======:*%@@
    @%+-**##############%=+++++++++++++++++++++++++++++=========+++++++++=======:*@@
    %*:*******##########%=++++++++++++++++++++++++++============.+++++++=========.=%
    **:**+********#####*#+++++++++++++++++++++++++=============== +++++++=========*%
    =*=++++++**********#.++++++++++++++++++++++++================-=+++++++=======**:
    +*.+====++++*******#++++++++++++++++++++======================.+++++++=======++:
    *#:==-====++++++++-.+++++++++++++==+===========================:++++=========+*=
    %-*+----=====+++++- ++++++=====================================:=++==========%+%
    @*:*#----=======+=*==========================-++++#.============-===========#*=%
    @%=:**=---=====+=-#======================-:+++++++++:-=====================*#-@@
    @@%==*.+---======..=====================:+++++++++++++..=========.========%*-@@@
    @@@@%--*-=--=====. ===================:++++++++++++++++.:========-======+%+%@@@@
    @@@@@%=--*-======-.=================:+++++++++++++++++++*.+=======.===+**=%@@@@@
    @@@@@@@%#- #:*==:%-=================++++++++++++++++++++++ -======-=*%+=%%@@@@@@
    @@@@@@@@@@%-=:#:% ==============-:+++++++++++++++++++++++++.:====== -%@@@@@@@@@@
    @@@@@@@@@@@@@%---.=============:++++++++++++++++++++++++++++ +======%@@@@@@@@@@@
    @@@@@@@@@@@@@@@%-.=============+++++++++++++++++++++++++#**#*--===== @@@@@@@@@@@
    @@@@@@@@@@@@@@@%=:==========.%%+.:-%*****+*+**#*---%#*+--::*%::-====-%@@@@@@@@@@
    @@@@@@@@@@@@@@%* :=========*#:::::-=+-::-===+=-:::::+%@@@@@@@%.:-====.@@@@@@@@@@
    @@@@@@@@@@@@@@@= -=======:%%@@@@@%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@::.===-%@@@@@@@@@
    @@@@@@@@@@@@@@@= ======:%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=:--==+@@@@@@@@@
    @@@@@@@@@@@@@@@=.=====-%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=-.==-@@@@@@@@@
    @@@@@@@@@@@@@@%=:====:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@--+==%@@@@@@@@
    @@@@@@@@@@@@@@%=:==:%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%-===%@@@@@@@@
    @@@@@@@@@@@@@@@=:=:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-:-@@@@@@@@@
    @@@@@@@@@@@@@@%-:+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  STARFLEET
  exit
end