PageRenderTime 21ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/core/externals/update-engine/Samples/EngineRunner/ERCommand.h

http://macfuse.googlecode.com/
C Header | 81 lines | 9 code | 9 blank | 63 comment | 0 complexity | a3b8ca9798ec9262c63b17805614f829 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  1. // Copyright 2008 Google Inc.
  2. //
  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
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  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.
  14. #import <Foundation/Foundation.h>
  15. // ERCommand is an abstract base class for an EngineRunner command.
  16. //
  17. // To use:
  18. // You won't actually be instantiating an ERCommand directly, but
  19. // instead will use a subclass that actually does something.
  20. // Presume there exists an ERGreebleCommand that does stuff.
  21. //
  22. // Make a new command object by asking the class for a command:
  23. // ERCommand *cmd = [ERGreebleCommand command];
  24. //
  25. // Now that you have a command, you can ask it its name and a brief
  26. // description, for help and documentation purposes.
  27. // NSLog(@"arrrr, ye command is %@ and it does %@",
  28. // [cmd name], [cmd blurb]);
  29. //
  30. // Each command declares what arguments it must have, and what arguments
  31. // it can optionally have:
  32. // NSDictionary *reqArgs = [cmd requiredArguments];
  33. // NSDictionary *optArgs = [cmd optionalArguments];
  34. // The keys are the argument names (without a leading dash) and the
  35. // values are help blurbs, handy for constructing user-error smackdowns.
  36. //
  37. // To actually make the command do something, obtain or construct a dictionary
  38. // with key-value pairs which have all of the required arguments, and
  39. // whatever optional arguments, and tell the command to run:
  40. //
  41. // NSDictionary *args = ...;
  42. // BOOL success = [cmd runWithArguments:args];
  43. //
  44. // |success| will be YES if the command succeded, NO if the command failed.
  45. //
  46. @interface ERCommand : NSObject
  47. // Returns an autoreleased instance of the ERCommand subclass receiving
  48. // the message. Returns nil if sent to the abstract ERCommand class itself.
  49. + (id)command;
  50. // The name of the command, which is what the user would type on the
  51. // command line.
  52. // Subclasses need to override this.
  53. - (NSString *)name;
  54. // A brief description of the command. Will be used in generating help
  55. // text.
  56. // Subclasses should override this.
  57. - (NSString *)blurb;
  58. // A dictionary of required arguments. The dictionary key is the argument
  59. // name and the value is a bit of help text.
  60. // Subclasses can override this if they have required arguments.
  61. - (NSDictionary *)requiredArguments;
  62. // A dictionary of optional arguments. The dictionary key is the argument
  63. // name and the value is a bit of help text.
  64. // Subclasses can override this if they have optional arguments.
  65. - (NSDictionary *)optionalArguments;
  66. // Actually run the command, with a dictionary of arguments built from
  67. // the command line and user defaults. Callers should make sure all of
  68. // the required arguments are present.
  69. // Subclasses should override this so they can, actually, like, do some work.
  70. // Returns YES if the command ran successfully, NO if it didn't.
  71. - (BOOL)runWithArguments:(NSDictionary *)args;
  72. @end // ERCommand