Reimplementation of Pijul in C, for education, fun and absolutely no profit
#include <unistd.h> /* getopt(3p) */
#include <stdio.h>
#include <stdlib.h>

#include "common.h"
#include "repository.h"

static void
cmd_init_usage()
{
	printf("ani init [-h] [-c <channel>] [<dir>]\n");
}

/**
 * Init initializes a new repository as
 *
 * mkdir .pijul/{pristine, changes}
 *
 * plus maybe a few other things?
 */
int
init(const char *dir, const char *channel)
{
	/* create the directory with mkdir(2) */
	printf("init! dir = '%s' channel = '%s'\n", dir, channel);
	return 0;
}

/**
 * ani init [-c <channel>] [<dir>]
 */
int
cmd_init(int argc, const char **argv, struct repository *repo)
{
	int c;
	const char *dir;
	char *channel = "main";
	char **arguments = (char **)argv;

	(void)repo;

	/* Parse cmdline args */
	while ((c = getopt(argc, arguments, "hc:")) != -1) {
		switch (c) {
		case 'h':
			cmd_init_usage();
			return 0;
		case 'c':
			channel = optarg;
			break;
		case '?':
			fprintf(stderr, "unrecognized option '-%c'\n", optopt);
			exit(1);
		}
	}
	dir = optind < argc ? argv[optind] : ".";

	/* Return result of init() */
	return init(dir, channel);
}