PageRenderTime 23ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

C++ Header | 81 lines | 9 code | 9 blank | 63 comment | 0 complexity | a3b8ca9798ec9262c63b17805614f829 MD5 | raw file
 1// Copyright 2008 Google Inc.
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
15#import <Foundation/Foundation.h>
17// ERCommand is an abstract base class for an EngineRunner command.
19// To use:
20//   You won't actually be instantiating an ERCommand directly, but
21//   instead will use a subclass that actually does something.
22//   Presume there exists an ERGreebleCommand that does stuff.
24//   Make a new command object by asking the class for a command:
25//     ERCommand *cmd = [ERGreebleCommand command];
27//   Now that you have a command, you can ask it its name and a brief
28//   description, for help and documentation purposes.
29//     NSLog(@"arrrr, ye command is %@ and it does %@",
30//           [cmd name], [cmd blurb]);
32//  Each command declares what arguments it must have, and what arguments
33//  it can optionally have:
34//     NSDictionary *reqArgs = [cmd requiredArguments];
35//     NSDictionary *optArgs = [cmd optionalArguments];
36//  The keys are the argument names (without a leading dash) and the
37//  values are help blurbs, handy for constructing user-error smackdowns.
39// To actually make the command do something, obtain or construct a dictionary
40// with key-value pairs which have all of the required arguments, and
41// whatever optional arguments, and tell the command to run:
43//  NSDictionary *args = ...;
44//  BOOL success = [cmd runWithArguments:args];
46//  |success| will be YES if the command succeded, NO if the command failed.
48@interface ERCommand : NSObject
50// Returns an autoreleased instance of the ERCommand subclass receiving
51// the message. Returns nil if sent to the abstract ERCommand class itself.
52+ (id)command;
54// The name of the command, which is what the user would type on the
55// command line.
56// Subclasses need to override this.
57- (NSString *)name;
59// A brief description of the command.  Will be used in generating help
60// text.
61// Subclasses should override this.
62- (NSString *)blurb;
64// A dictionary of required arguments.  The dictionary key is the argument
65// name and the value is a bit of help text.
66// Subclasses can override this if they have required arguments.
67- (NSDictionary *)requiredArguments;
69// A dictionary of optional arguments.  The dictionary key is the argument
70// name and the value is a bit of help text.
71// Subclasses can override this if they have optional arguments.
72- (NSDictionary *)optionalArguments;
74// Actually run the command, with a dictionary of arguments built from
75// the command line and user defaults.  Callers should make sure all of
76// the required arguments are present.
77// Subclasses should override this so they can, actually, like, do some work.
78// Returns YES if the command ran successfully, NO if it didn't.
79- (BOOL)runWithArguments:(NSDictionary *)args;
81@end  // ERCommand