]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/gui/cli/JubCLICommand.h
Add a zxcv-like CLI frontend
[jubjub.git] / src / gui / cli / JubCLICommand.h
diff --git a/src/gui/cli/JubCLICommand.h b/src/gui/cli/JubCLICommand.h
new file mode 100644 (file)
index 0000000..6f32796
--- /dev/null
@@ -0,0 +1,37 @@
+#import <ObjFW/ObjFW.h>
+
+@class JubCLIUI;
+
+@protocol JubCLICommand
+@property (readonly) OFString *command;
+@property (readonly) OFString *params;
+@property (readonly) OFString *help;
+
+- initWithCLIUI: (JubCLIUI*)ui;
+- (void)callWithParameters: (OFArray*)parameters;
+@end
+
+#define BEGINCLICOMMAND(name, com, paramsString, helpString) \
+    @interface name: OFObject<JubCLICommand> \
+    { \
+       JubCLIUI *_ui; \
+    } \
+    @end \
+    @implementation name \
+    - initWithCLIUI: (JubCLIUI*)ui \
+    { \
+       self = [super init]; \
+       _ui = [ui retain]; \
+       return self; \
+    } \
+    - (void)dealloc \
+    { \
+       [_ui release]; \
+       [super dealloc]; \
+    } \
+    - (OFString*)command { return com; } \
+    - (OFString*)params { return paramsString; } \
+    - (OFString*)help { return helpString; } \
+    - (void)callWithParameters: (OFArray*)parameters
+
+#define ENDCLICOMMAND @end