Class: BeamUp::CLI
- Inherits:
-
Object
- Object
- BeamUp::CLI
- Defined in:
- lib/beam_up/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #deploy ⇒ Object
- #deploy_or_help ⇒ Object
- #init ⇒ Object
-
#initialize(arguments) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
- #scotty ⇒ Object
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
#deploy ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/beam_up/cli.rb', line 82 def deploy input = beamed = BeamUp.deploy! input, provider: @provider, config_file: @config_file puts beamed. puts "Deploy ID: #{beamed.deploy_id}" if beamed.deploy_id exit(1) unless beamed.success? end |
#deploy_or_help ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/beam_up/cli.rb', line 71 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 |
#init ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 provider_config_class = PROVIDERS[provider_name]::Config config_keys = provider_config_class.config_keys config_file = ["config/beam_up.yml", ".beam_up.yml"].find { File.exist?(it) } if config_file existing_config = YAML.safe_load_file(config_file) || {} if existing_config.key?(provider_name) puts "Provider '#{provider_name}' already configured in #{config_file}" exit(1) end provider_section = YAML.dump({provider_name => config_keys.to_h { [it, ""] }}, indent: 2, line_width: 80).sub(/^---\n/, "") File.write(config_file, File.read(config_file) + "\n" + provider_section) puts "Updated #{config_file} with #{provider_name} provider" else configuration = YAML.dump({ "provider" => provider_name, "path" => nil, provider_name => config_keys.to_h { |key| [key, ""] } }, indent: 2, line_width: 80).gsub(/^path:$/, "# path: ./output # uncomment to set a default folder") File.write(".beam_up.yml", configuration) puts "Created .beam_up.yml with #{provider_name} provider" end end |
#run ⇒ Object
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 |
#scotty ⇒ Object
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/beam_up/cli.rb', line 93 def scotty puts <<~STARFLEET @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*+=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%***++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%***+++=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%**+++++++%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*+++++++++-%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***+*++++++++:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%****++++++++++=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@***+*++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@%***+++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@*****+++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@%****+++++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@%+****+++++++++++++++++++=%@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@%%=##%***+++++++++++++++++++++==++*-%%@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@%%%#*+-=#*%%*++++++++++++++++++++++++==*+*#.++**@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@%-*+.#%%#####**++++++++++++++++++++++++++=+++++++*%+*%@@@@@@@@@@@@@@ @@@@@@@@%%%*+=#%%%%#%%%%-*+++++++++++++++++++++++++++===++++=+==*:=**@@@@@@@@@@@ @@@@@@%%*+-#%%%%%%%%###%*++++++++++++++++++++++++++++==-=++++++====+.+:%@@@@@@@@ @@@@@%*+-#%%%%%%%%#%#%#=+++++++++++++++++++++++++++++===:=++++++======*==%@@@@@@ @@@@%*:###%%%%%######%%++++++++++++++++++++++++++++======:++++++========*=:%@@@@ @@%%+-###############%-++++++++++++++++++++++++++++=======.+++++++========:*%@@@ @@#+=#################++++++++++++++++++++++++++++++=======-++++++=+=======:*%@@ @%+-**##############%=+++++++++++++++++++++++++++++=========+++++++++=======:*@@ %*:*******##########%=++++++++++++++++++++++++++============.+++++++=========.=% **:**+********#####*#+++++++++++++++++++++++++=============== +++++++=========*% =*=++++++**********#.++++++++++++++++++++++++================-=+++++++=======**: +*.+====++++*******#++++++++++++++++++++======================.+++++++=======++: *#:==-====++++++++-.+++++++++++++==+===========================:++++=========+*= %-*+----=====+++++- ++++++=====================================:=++==========%+% @*:*#----=======+=*==========================-++++#.============-===========#*=% @%=:**=---=====+=-#======================-:+++++++++:-=====================*#-@@ @@%==*.+---======..=====================:+++++++++++++..=========.========%*-@@@ @@@@%--*-=--=====. ===================:++++++++++++++++.:========-======+%+%@@@@ @@@@@%=--*-======-.=================:+++++++++++++++++++*.+=======.===+**=%@@@@@ @@@@@@@%#- #:*==:%-=================++++++++++++++++++++++ -======-=*%+=%%@@@@@@ @@@@@@@@@@%-=:#:% ==============-:+++++++++++++++++++++++++.:====== -%@@@@@@@@@@ @@@@@@@@@@@@@%---.=============:++++++++++++++++++++++++++++ +======%@@@@@@@@@@@ @@@@@@@@@@@@@@@%-.=============+++++++++++++++++++++++++#**#*--===== @@@@@@@@@@@ @@@@@@@@@@@@@@@%=:==========.%%+.:-%*****+*+**#*---%#*+--::*%::-====-%@@@@@@@@@@ @@@@@@@@@@@@@@%* :=========*#:::::-=+-::-===+=-:::::+%@@@@@@@%.:-====.@@@@@@@@@@ @@@@@@@@@@@@@@@= -=======:%%@@@@@%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@::.===-%@@@@@@@@@ @@@@@@@@@@@@@@@= ======:%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=:--==+@@@@@@@@@ @@@@@@@@@@@@@@@=.=====-%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=-.==-@@@@@@@@@ @@@@@@@@@@@@@@%=:====:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@--+==%@@@@@@@@ @@@@@@@@@@@@@@%=:==:%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%-===%@@@@@@@@ @@@@@@@@@@@@@@@=:=:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-:-@@@@@@@@@ @@@@@@@@@@@@@@%-:+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ STARFLEET exit end |