Sha256: f1c3efce3cf71ba21993cb56080968ad7ee745943006acf1aba0ff6074548abb

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require "shelly/cli/command"

module Shelly
  module CLI
    class Organization < Command
      namespace :organization
      include Helpers

      before_hook :logged_in?, :only => [:list, :add, :create, :new]

      desc "list", "Lists organizations"
      def list
        user = Shelly::User.new
        organizations = user.organizations
        say "You have access to the following organizations and clouds:", :green
        say_new_line
        organizations.each do |organization|
          say organization.name, :green
          if organization.apps.present?
            print_table(apps_table(organization.apps), :ident => 2, :colwidth => 35)
          else
            print_wrapped "No clouds", :ident => 2
          end
        end
      end

      method_option "redeem-code", :type => :string, :aliases => "-r",
        :desc => "Redeem code for free credits"
      method_option "referral-code", :type => :string,
        :desc => "Referral code for additional credit"
      desc "add", "Add a new organization"
      map "create" => :add
      map "new" => :add
      def add
        create_new_organization(options)
      rescue Client::ValidationException => e
        e.each_error { |error| say_error error, :with_exit => false }
        exit 1
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shelly-0.5.7 lib/shelly/cli/organization.rb
shelly-0.5.6 lib/shelly/cli/organization.rb
shelly-0.5.5 lib/shelly/cli/organization.rb
shelly-0.5.4 lib/shelly/cli/organization.rb
shelly-0.5.3 lib/shelly/cli/organization.rb