Class: EPC::Command::BaseCommand

Inherits:
Object
  • Object
show all
Includes:
Error, PersistentAttributes
Defined in:
lib/epc/command/base_command.rb

Direct Known Subclasses

ArchiveCommand, AttachLibraryCommand, AttachLibrarysetCommand, AttachRuntimeCommand, BindServiceCommand, BuildCommand, CopyDeploymentCommand, CreateCommand, CreateConfigCommand, CreateDependencyCommand, CreateDeploymentCommand, CreateGroupCommand, CreateLibraryCommand, CreateLibrarylanguageCommand, CreateLibrarysetCommand, CreateObjectroleCommand, CreateProjectCommand, CreateRoleCommand, CreateServicedefinitionCommand, CreateServiceversionCommand, CreateSolutionCommand, CreateUserCommand, DeleteCommand, DeleteLibraryCommand, DeleteLibrarysetCommand, DeleteProjectCommand, DeployCommand, DetachLibraryCommand, DetachLibrarysetCommand, InfoCommand, ListCommand, ListConfigsCommand, ListDeploymentsCommand, ListDeploymentstagesCommand, ListGroupsCommand, ListLibrariesCommand, ListLibrarylanguagesCommand, ListLibrarysetsCommand, ListMetricsCommand, ListObjectrolesCommand, ListObjecttypesCommand, ListPermissiongroupsCommand, ListPermissionsCommand, ListPluginsCommand, ListProjectsCommand, ListProjecttypesCommand, ListRolesCommand, ListRuntimesCommand, ListServicedefinitionsCommand, ListServicetypesCommand, ListServiceversionsCommand, ListSolutionsCommand, ListUsersCommand, ListVersionsCommand, LoginCommand, LogoutCommand, PullCommand, PushCommand, RefreshSolutionCommand, RenewCommand, RequestPasswordchangeCommand, ShowCommand, ShowGroupCommand, ShowInstancesCommand, ShowLibrarysetCommand, ShowMetricsCommand, ShowProjecttypeCommand, SubmitDeploymentCommand, TargetCommand, UnarchiveCommand, UnbindServiceCommand, UndefineServiceCommand, UndeployCommand, UpdateCommand, UpdateDeploymentCommand, UpdateGroupCommand, UpdateLibrarylanguageCommand, UpdateLibrarysetCommand, UpdateProjectCommand, UpdateSolutionCommand, UpdateUserCommand, VoteDeploymentCommand

Constant Summary collapse

SLEEP_TIME =
1
TICKER_TICKS =

Numerators are in secs

25/SLEEP_TIME
GIVEUP_TICKS =
120/SLEEP_TIME
@@retrieval_rules =
{
  :Role => {
    :required_type => :numeric, 
  },
  :User => {
    :required_type => :numeric,
  },
  :UserGroup => {
    :required_type => :numeric,
  },
  :LibrarySet => {
    :required_type => :numeric,
  }
}
@@required_options =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

#initialize(client, options = {}) ⇒ BaseCommand



50
51
52
53
54
55
56
# File 'lib/epc/command/base_command.rb', line 50

def initialize(client, options = {})
  @client = client
  @options = options.dup
  if @options[:skip_prompts].present?
    create_method(:ask) {|text, arr| return "Y"}
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/epc/command/base_command.rb', line 11

def client
  @client
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/epc/command/base_command.rb', line 12

def options
  @options
end

Class Method Details

.inherited(subklass) ⇒ Object



37
38
39
40
# File 'lib/epc/command/base_command.rb', line 37

def self.inherited(subklass)
  # Here login is required for all commands that inherit
  subklass.
end

.required_options(*opts, opt_hash) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/epc/command/base_command.rb', line 42

def self.required_options(*opts, opt_hash)
  options_hash = {
    :mode => :any?,
    :message => "You need to specify all required options"
  }.merge(opt_hash)
  @@required_options << {:name => opts, :mode => options_hash[:mode], :message => options_hash[:message]}
end

Instance Method Details

#go(*args) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/epc/command/base_command.rb', line 58

def go(*args)
  if () && (!logged_in?)
    say("You must be logged in to run this command")
    return 1
  else
    return translate_status_to_exit_code(execute(*args))
  end
end