Sha256: 61f348a92be731e111a9be2c134d83103adaf3646a8061fe272c865e97b1c85d

Contents?: true

Size: 1.98 KB

Versions: 10

Compression:

Stored size: 1.98 KB

Contents

# groups.rb: a group of commands
# copyright (c) 2009 by Vincent Fourmond
  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details (in the COPYING file).

require 'ctioga2/utils'
require 'ctioga2/metabuilder/types'

module CTioga2

  module Commands

    # A group of commands, organized along a same theme.
    class CommandGroup

      # The commands belonging to the group
      attr_accessor :commands

      # The name of the group
      attr_accessor :name

      # A short, unique, codelike name for the group.
      attr_accessor :id

      # A (longer) description of the group
      attr_accessor :description

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

      # Whether the group is blacklisted or not, ie whether the group's
      # help text will be displayed at all. 
      attr_accessor :blacklisted

      # The context of definition [file, line]
      attr_accessor :context
      
      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
      
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ctioga2-0.14.1 lib/ctioga2/commands/groups.rb
ctioga2-0.14 lib/ctioga2/commands/groups.rb
ctioga2-0.13.1 lib/ctioga2/commands/groups.rb
ctioga2-0.13 lib/ctioga2/commands/groups.rb
ctioga2-0.12 lib/ctioga2/commands/groups.rb
ctioga2-0.11 lib/ctioga2/commands/groups.rb
ctioga2-0.10.1 lib/ctioga2/commands/groups.rb
ctioga2-0.10 lib/ctioga2/commands/groups.rb
ctioga2-0.9 lib/ctioga2/commands/groups.rb
ctioga2-0.8 lib/ctioga2/commands/groups.rb