Sha256: 2916d62e3531a66c19e01fd87ea304497cca2eebea43f941671f3c410b1f2588

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

module Aptible
  module CLI
    module Subcommands
      module Apps
        def self.included(thor)
          thor.class_eval do
            include Helpers::Account
            include Helpers::Token

            desc 'apps', 'List all applications'
            option :account
            def apps
              if options[:account]
                accounts = [account_from_handle(options[:account])]
              else
                accounts = Aptible::Api::Account.all(token: fetch_token)
              end

              accounts.each do |account|
                say "=== #{account.handle}"
                account.apps.each do |app|
                  say app.handle
                end
                say ''
              end
            end

            desc 'apps:create HANDLE', 'Create a new application'
            option :account
            define_method 'apps:create' do |handle|
              account = ensure_account(options)
              app = account.create_app(handle: handle)

              if app.errors.any?
                fail Thor::Error, app.errors.full_messages.first
              else
                say "App #{handle} created!"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
aptible-cli-0.5.7 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.6 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.5 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.4 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.2 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.1 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.5.0 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.4.4 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.4.3 lib/aptible/cli/subcommands/apps.rb
aptible-cli-0.4.2 lib/aptible/cli/subcommands/apps.rb