Class: EyProCli
- Inherits:
-
Thor
- Object
- Thor
- EyProCli
- Defined in:
- lib/ey_pro_cli.rb
Class Attribute Summary collapse
-
.core_file ⇒ Object
Returns the value of attribute core_file.
Instance Method Summary collapse
Class Attribute Details
.core_file ⇒ Object
Returns the value of attribute core_file.
16 17 18 |
# File 'lib/ey_pro_cli.rb', line 16 def core_file @core_file end |
Instance Method Details
#accounts ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ey_pro_cli.rb', line 25 def accounts accounts = core_client.users.current.accounts width = longest_account_name_length(accounts) table_data = TablePrint::Printer.new(accounts, [{id: {width: 36}}, :name]) puts table_data.table_print end |
#deploy ⇒ Object
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 |
# File 'lib/ey_pro_cli.rb', line 79 def deploy check_for_updates unless ["no-update-check"] environment = core_environment_for() app = core_application_for() = {} .merge!(ref: [:ref]) if [:ref] .merge!(migrate_command: [:migrate]) if [:migrate] .merge!(migrate_command: '') if ["no-migrate"] request = environment.deploy(app, ) puts "Deploy started to environment: #{environment.name} with application: #{app.name}" if [:stream] request.subscribe { |m| print m["message"] if m.is_a?(Hash) } puts "" # fix console output from stream else request.ready! end if request.successful puts "Deploy successful!" else abort "Deploy failed!" end end |
#login ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ey_pro_cli.rb', line 35 def login email = ENV["EMAIL"] || ask("Email:") password = ENV["PASSWORD"] || ask("Password:", echo: false) token = unauthenticated_core_client.get_api_token(email, password).body["api_token"] existing_token = core_yaml[core_url] write_token = if existing_token && existing_token != token puts "New token does not match existing token. Overwriting".yellow true elsif existing_token == token puts "Token already exists".green false else puts "Writing token".green true end write_core_yaml(token) if write_token rescue Ey::Core::Response::Unauthorized abort "Invalid email or password".yellow end |
#logout ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/ey_pro_cli.rb', line 59 def logout if core_yaml[core_url] core_yaml.delete(core_url) write_core_yaml puts "Successfully removed API token from credentials file".green else puts "No API token found".yellow end end |