~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai/command-template.py

  • Committer: Robert Collins
  • Date: 2005-09-13 12:39:26 UTC
  • mto: (147.2.6) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20050913123926-b72242bdacc1ae52
create the output directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2004 Aaron Bentley
 
2
# <aaron.bentley@utoronto.ca>
 
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.
 
13
#
 
14
#    You should have received a copy of the GNU General Public License
 
15
#    along with this program; if not, write to the Free Software
 
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
import sys
 
19
import os
 
20
 
 
21
#ensure that the parent directory is in the path (for epydoc)
 
22
sys.path=[os.path.realpath(os.path.dirname(__file__)+"/..")]+sys.path
 
23
 
 
24
import commands
 
25
 
 
26
__docformat__ = "restructuredtext"
 
27
__doc__ = "command template"
 
28
 
 
29
class Template(commands.BaseCommand):
 
30
    """Template for writing new commands"""
 
31
    def __init__(self):
 
32
        self.description = self.__doc__
 
33
 
 
34
#   override get_completer if you want custom completion
 
35
#    def get_completer(self, arg, index):
 
36
#        return cmdutil.iter_dir_completions(arg)
 
37
 
 
38
    def do_command(self, cmdargs):
 
39
        parser=self.get_parser()
 
40
        (options, args) = parser.parse_args(cmdargs)
 
41
 
 
42
        if len(args) != 1:
 
43
            raise errors.GetHelp
 
44
        return 0
 
45
 
 
46
    def get_parser(self):
 
47
        parser = cmdutil.CmdOptionParser("example ARGUMENT1 ARGUMENT2")
 
48
        return parser
 
49
 
 
50
    def help(self, parser=None):
 
51
        """
 
52
        Prints a help message.
 
53
 
 
54
        :param parser: If supplied, the parser to use for generating help.  If \
 
55
        not supplied, it is retrieved.
 
56
        :type parser: cmdutil.CmdOptionParser
 
57
        """
 
58
        if parser==None:
 
59
            parser=self.get_parser()
 
60
        parser.print_help()
 
61
        print """
 
62
Verbose help text goes here.
 
63
"""
 
64
 
 
65
 
 
66
#This function assigns the command class to a user command name
 
67
def add_command(commands):
 
68
    commands["template"] = Template
 
69
 
 
70
 
 
71
# arch-tag: 9feb1e39-86dd-447f-8999-5f8eab1f4ddf