int main(int argc, char **argv)
{
+ if (argc <= 1 || argc > 1 && !strcmp(argv[1], "--help"))
+ {
+ help();
+ return 0;
+ }
+
if (argc != 4)
{
fprintf(stderr, "Usage: paperjam <commands> <input> <output>\n");
debug_cmds(cmds);
instantiate(cmds);
}
+
+void help()
+{
+ for (int i=0; cmd_table[i].name; i++)
+ {
+ const cmd_def *def = &cmd_table[i];
+ printf("%s\n", def->name);
+
+ const arg_def *arg = def->arg_defs;
+ static const char * const type_names[] = {
+ "string", "int", "double", "dimen"
+ };
+ while (arg->name)
+ {
+ printf("\t%s (%s)%s%s\n",
+ arg->name,
+ type_names[arg->type & AT_TYPE_MASK],
+ (arg->type & AT_MANDATORY) ? " [mandatory]" : "",
+ (arg->type & AT_POSITIONAL) ? " [positional]" : "");
+ arg++;
+ }
+
+ if (def->has_pipeline)
+ printf("\t{ pipeline }\n");
+ }
+}