Permalink
Browse files

add basic commander setup

  • Loading branch information...
1 parent 2711f60 commit 4cd7970c9dd254ce0928cfcae2377bcdfab1d6f8 @tj committed Jan 26, 2013
Showing with 35 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −1 Makefile
  3. +33 −0 src/main.c
View
1 .gitignore
@@ -0,0 +1 @@
+histo
View
2 Makefile
@@ -4,7 +4,7 @@ SRC += $(wildcard deps/*.c)
OBJ = $(SRC:.c=.o)
histo: $(SRC)
- $(CC) $^ -std=c99 -o $@
+ $(CC) $^ -std=c99 -I deps -o $@
clean:
rm -f histo $(OBJ)
View
33 src/main.c
@@ -0,0 +1,33 @@
+
+//
+// main.c
+//
+// Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
+//
+
+#include <stdio.h>
+#include <commander.h>
+
+static void
+verbose(command_t *self) {
+ printf("verbose: enabled\n");
+}
+
+static void
+required(command_t *self) {
+ printf("required: %s\n", self->arg);
+}
+
+static void
+optional(command_t *self) {
+ printf("optional: %s\n", self->arg);
+}
+
+int
+main(int argc, char **argv){
+ command_t cmd;
+ command_init(&cmd, argv[0], "0.0.1");
+ command_parse(&cmd, argc, argv);
+ command_free(&cmd);
+ return 0;
+}

0 comments on commit 4cd7970

Please sign in to comment.