~mcf/samurai

6cfcc7dbf5ecd5d1387de5e26483df7562acea36 — Michael Forney 10 months ago a883d98
tool: Fail on first unknown target in commands and graph tools

This matches ninja behavior and is a bit simpler.
1 files changed, 6 insertions(+), 14 deletions(-)

M tool.c
M tool.c => tool.c +6 -14
@@ 148,17 148,13 @@ targetcommands(struct node *n)
static int
commands(int argc, char *argv[])
{
	int ret = 0;
	struct node *n;

	if (argc > 1) {
		while (*++argv) {
			n = nodeget(*argv, 0);
			if (!n) {
				warn("unknown target '%s'", *argv);
				ret = 1;
				continue;
			}
			if (!n)
				fatal("unknown target '%s'", *argv);
			targetcommands(n);
		}
	} else {


@@ 168,7 164,7 @@ commands(int argc, char *argv[])
	if (fflush(stdout) || ferror(stdout))
		fatal("write failed");

	return ret;
	return 0;
}

static void


@@ 297,7 293,6 @@ graphnode(struct node *n)
static int
graph(int argc, char *argv[])
{
	int ret = 0;
	struct node *n;

	puts("digraph ninja {");


@@ 308,11 303,8 @@ graph(int argc, char *argv[])
	if (argc > 1) {
		while (*++argv) {
			n = nodeget(*argv, 0);
			if (!n) {
				warn("unknown target '%s'", *argv);
				ret = 1;
				continue;
			}
			if (!n)
				fatal("unknown target '%s'", *argv);
			graphnode(n);
		}
	} else {


@@ 324,7 316,7 @@ graph(int argc, char *argv[])
	if (fflush(stdout) || ferror(stdout))
		fatal("write failed");

	return ret;
	return 0;
}

static int