]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/gui/cli/JubCLICommand.h
Add a zxcv-like CLI frontend
[jubjub.git] / src / gui / cli / JubCLICommand.h
1 #import <ObjFW/ObjFW.h>
2
3 @class JubCLIUI;
4
5 @protocol JubCLICommand
6 @property (readonly) OFString *command;
7 @property (readonly) OFString *params;
8 @property (readonly) OFString *help;
9
10 - initWithCLIUI: (JubCLIUI*)ui;
11 - (void)callWithParameters: (OFArray*)parameters;
12 @end
13
14 #define BEGINCLICOMMAND(name, com, paramsString, helpString) \
15     @interface name: OFObject<JubCLICommand> \
16     { \
17         JubCLIUI *_ui; \
18     } \
19     @end \
20     @implementation name \
21     - initWithCLIUI: (JubCLIUI*)ui \
22     { \
23         self = [super init]; \
24         _ui = [ui retain]; \
25         return self; \
26     } \
27     - (void)dealloc \
28     { \
29         [_ui release]; \
30         [super dealloc]; \
31     } \
32     - (OFString*)command { return com; } \
33     - (OFString*)params { return paramsString; } \
34     - (OFString*)help { return helpString; } \
35     - (void)callWithParameters: (OFArray*)parameters
36
37 #define ENDCLICOMMAND @end