View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2001-2005 Open World Ltd
4   //
5   // This file is part of MillScript.
6   //
7   // MillScript is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.millscript.apps.website;
22  
23  import com.townleyenterprises.command.CommandOption;
24  import com.townleyenterprises.command.CommandParser;
25  import com.townleyenterprises.command.DefaultCommandListener;
26  
27  /**
28   * 
29   *
30   */
31  public class Website {
32  
33      private CommandOption _average_load = new AverageLoadCommandOption();
34  
35      private CommandOption _find = new FindCommandOption();
36  
37      private CommandOption _new = new NewCommandOption();
38  
39      private CommandParser _parser = new CommandParser( "website" );
40  
41      private CommandOption _purge = new PurgeCommandOption();
42  
43      private CommandOption _quiet = new QuietCommandOption();
44  
45      private CommandOption _status = new StatusCommandOption();
46  
47      private CommandOption _unattended = new UnattendedCommandOption();
48  
49      private CommandOption _who = new WhoCommandOption();
50  
51      private CommandOption[] _options = {
52          _quiet, _unattended
53      };
54  
55      private CommandOption[] _commands = {
56          _average_load, _find, _new, _purge, _status, _who
57      };
58  
59      public Website( String[] args ) {
60          _parser.setExitOnMissingArg( true, -100 );
61          _parser.setExtraHelpText(
62              "The admin tool for a MillScript website",
63              "See the MillScript website for further details: http://www.millscript.org/"
64          );
65          _parser.addCommandListener(
66              new DefaultCommandListener(
67                  "website options",
68                  _options
69              )
70          );
71          _parser.addCommandListener(
72              new DefaultCommandListener(
73                  "website commands",
74                  _commands
75              )
76          );
77          _parser.parse( args );
78          try {
79              _parser.executeCommands();
80          } catch ( Exception ex ) {
81              ex.printStackTrace();
82              System.exit( -111 );
83          }
84      }
85  
86      public static void main( String[] args ) {
87          Website website = new Website( args );
88      }
89  }