~ubuntu-branches/ubuntu/oneiric/ctioga2/oneiric

« back to all changes in this revision

Viewing changes to lib/ctioga2/commands/arguments.rb

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2011-01-24 21:36:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110124213606-9ettx0ugl83z0bzp
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# arguments.rb: arguments to commands
 
2
# copyright (c) 2009 by Vincent Fourmond
 
3
  
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
  
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details (in the COPYING file).
 
13
 
 
14
require 'ctioga2/utils'
 
15
require 'ctioga2/commands/type'
 
16
 
 
17
module CTioga2
 
18
 
 
19
  Version::register_svn_info('$Revision: 18 $', '$Date: 2009-04-28 23:43:54 +0200 (Tue, 28 Apr 2009) $')
 
20
 
 
21
  module Commands
 
22
 
 
23
    # An argument to a Command
 
24
    class CommandArgument
 
25
 
 
26
      # The type of the argument, a CTioga2::MetaBuilder::Type object.
 
27
      attr_accessor :type
 
28
 
 
29
      # The name of the argument. Uniquely for display in the help
 
30
      # documentation.
 
31
      attr_accessor :name
 
32
 
 
33
      # A small description of the argument
 
34
      attr_accessor :description
 
35
 
 
36
      # _type_ is a named CommandType
 
37
      def initialize(type, name = nil, desc = nil)
 
38
        @type = CommandType.get_type(type)
 
39
        @name = name
 
40
        @description = desc
 
41
      end
 
42
      
 
43
      # Returns a name suitable for display in a documentation, such
 
44
      # as the command-line help.
 
45
      def displayed_name
 
46
        if @name
 
47
          return @name
 
48
        else
 
49
          return @type.name
 
50
        end
 
51
      end
 
52
 
 
53
    end
 
54
 
 
55
  end
 
56
 
 
57
end
 
58