Class: CTioga2::Commands::CommandGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/commands/groups.rb

Overview

A group of commands, organized along a same theme.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, desc = nil, priority = 0, blacklist = false, register = true) ⇒ CommandGroup

Returns a new instance of CommandGroup.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ctioga2/commands/groups.rb', line 48

def initialize(id, name, desc = nil, priority = 0, blacklist = false,
               register = true)
  @commands = []
  @name = name
  @id = id
  @description = desc || name
  @priority = priority
  @blacklisted = blacklist

  if register 
    Interpreter.register_group(self)
  end

  # The context in which the group was defined
  caller[1].gsub(/.*\/ctioga2\//, 'lib/ctioga2/') =~ /(.*):(\d+)/
  @context = [$1, $2.to_i]
end

Instance Attribute Details

#blacklistedObject

Whether the group is blacklisted or not, ie whether the group’s help text will be displayed at all.



43
44
45
# File 'lib/ctioga2/commands/groups.rb', line 43

def blacklisted
  @blacklisted
end

#commandsObject

The commands belonging to the group



25
26
27
# File 'lib/ctioga2/commands/groups.rb', line 25

def commands
  @commands
end

#contextObject

The context of definition [file, line]



46
47
48
# File 'lib/ctioga2/commands/groups.rb', line 46

def context
  @context
end

#descriptionObject

A (longer) description of the group



34
35
36
# File 'lib/ctioga2/commands/groups.rb', line 34

def description
  @description
end

#idObject

A short, unique, codelike name for the group.



31
32
33
# File 'lib/ctioga2/commands/groups.rb', line 31

def id
  @id
end

#nameObject

The name of the group



28
29
30
# File 'lib/ctioga2/commands/groups.rb', line 28

def name
  @name
end

#priorityObject

The priority of the group. It influences the positioning of its command-line options in the –help display. Lower priorities come first.



39
40
41
# File 'lib/ctioga2/commands/groups.rb', line 39

def priority
  @priority
end