Sha256: 8a3152d838fe5872c5d9107d9de3bdfee1bfb7111855fbcfd296135f51f123d4

Contents?: true

Size: 1.99 KB

Versions: 16

Compression:

Stored size: 1.99 KB

Contents

require "vmc/cli"

module VMC
  class Organization < CLI
    def precondition
      super
      fail "This command is v2-only." unless v2?
    end

    def self.by_name(what, obj = what)
      proc { |name, *_|
        client.send(:"#{obj}_by_name", name) ||
          fail("Unknown #{what} '#{name}'")
      }
    end

    desc "Show organization information"
    group :organizations
    input :organization, :aliases => ["--org", "-o"],
      :argument => :optional,
      :from_given => by_name("organization"),
      :default => proc { client.current_organization },
      :desc => "Organization to show"
    input :full, :type => :boolean,
      :desc => "Show full information for spaces, domains, etc."
    def org
      org = input[:organization]

      if quiet?
        puts org.name
        return
      end

      line "#{c(org.name, :name)}:"

      indented do
        line "domains: #{name_list(org.domains)}"

        if input[:full]
          line "spaces:"

          spaced(org.spaces(2)) do |s|
            indented do
              invoke :space, :space => s
            end
          end
        else
          line "spaces: #{name_list(org.spaces)}"
        end
      end
    end


    desc "List available organizations"
    group :organizations
    input :one_line, :alias => "-l", :type => :boolean, :default => false,
      :desc => "Single-line tabular format"
    input :full, :type => :boolean, :default => false,
      :desc => "Show full information for apps, service instances, etc."
    def orgs
      orgs =
        with_progress("Getting organizations") do
          client.organizations(1)
        end

      line unless quiet?

      if input[:one_line]
        table(
          %w{name spaces domains},
          orgs.collect { |o|
            [ c(o.name, :name),
              name_list(o.spaces),
              name_list(o.domains)
            ]
          })
      else
        orgs.each do |o|
          invoke :org, :organization => o, :full => input[:full]
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
vmc-0.4.0.beta.80 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.79 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.78 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.77 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.76 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.75 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.74 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.73 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.72 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.71 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.70 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.69 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.68 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.67 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.66 vmc-ng/lib/vmc/cli/organization.rb
vmc-0.4.0.beta.65 vmc-ng/lib/vmc/cli/organization.rb