Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge branch 'test-branch' of https://github.com/dnaeon/pkgng into dnaeon-test-branch
Eitan committed 15 years ago
commit e7d1114c45b2e2dae33ddc4ccbf49489daae756d
parent cdaecf0
9 files changed +48 -32
modified pkg/add.c
@@ -43,8 +43,12 @@ is_url(const char *pattern)
void
usage_add(void)
{
-
	fprintf(stderr, "add ... <pkg-name>\n"
-
			"add\n");
+
	fprintf(stderr, "usage: pkg add <pkg-name>\n");
+
	fprintf(stderr, "       pkg add <url>://<pkg-name>\n\n"
+
			"Installs a package from either a local source or remote one.\n\n"
+
			"When installing from remote source you need to specify\n"
+
			"the protocol to use when fetching the package.\n\n"
+
			"Currently supported protocols are FTP, HTTP and HTTPS\n");
}

int
@@ -101,3 +105,4 @@ exec_add(int argc, char **argv)

	return (retcode);
}
+

modified pkg/create.c
@@ -12,9 +12,9 @@
void
usage_create(void)
{
-
	fprintf(stderr, "create [-gx] [-r rootdir] [-m manifest] [-f format] [-o outdir] "
-
			"<pkg-name>\n"
-
			"create -a [-r rootdir] [-m manifest] [-f format] [-o outdir]\n");
+
	fprintf(stderr, "usage: pkg create [-gx] [-r rootdir] [-m manifest] [-f format] [-o outdir] "
+
			"<pkg-name>\n");
+
	fprintf(stderr, "       pkg create -a [-r rootdir] [-m manifest] [-f format] [-o outdir]\n");
}

/*
@@ -147,3 +147,4 @@ exec_create(int argc, char **argv)

	return (retcode);
}
+

modified pkg/delete.c
@@ -12,8 +12,8 @@
void
usage_delete(void)
{
-
	fprintf(stderr, "delete [-f] <pkg-name>\n"
-
			"delete -a\n");
+
	fprintf(stderr, "usage: pkg delete [-f] <pkg-name>\n");
+
	fprintf(stderr, "       pkg delete -a\n");
}

int
modified pkg/info.c
@@ -83,8 +83,8 @@ print_info(struct pkg *pkg, unsigned int opt)
void
usage_info(void)
{
-
	fprintf(stderr, "info [-egxXdrlsqO] <pkg-name>\n"
-
			"info\n");
+
	fprintf(stderr, "usage: pkg info\n");
+
	fprintf(stderr, "       pkg info [-egxXdrlsqO] <pkg-name>\n");
}

/*
modified pkg/main.c
@@ -36,23 +36,30 @@ static struct commands {
	{ "which", exec_which, usage_which},
};

-
const int cmd_len = (sizeof(cmd)/sizeof(cmd[0]));
+
const unsigned int cmd_len = (sizeof(cmd)/sizeof(cmd[0]));

static void
usage(void)
{
-
	fprintf(stderr, "usage: pkg <command> [<args>]\n\n"
-
			"Where <command> can be:\n");
-
	for (int i = 0; i < cmd_len; i++) {
-
		fprintf(stderr, "  %s\n", cmd[i].name);
-
	}
+
	fprintf(stderr, "usage: pkg <command> [<args>]\n\n");
+
	fprintf(stderr, "For more information on the different commands"
+
			" see 'pkg help <command>'\n\n");
+
	fprintf(stderr, "Where <command> can be:\n");
+

+
	for (unsigned int i = 0; i < cmd_len; i++) 
+
		fprintf(stderr, "\t%s\n", cmd[i].name);
+

	exit(EX_USAGE);
}

static void
usage_help(void)
{
-
	fprintf(stderr, "help <command>\n");
+
	fprintf(stderr, "usage: pkg help <command>\n\n");
+
	fprintf(stderr, "Where <command> can be:\n");
+

+
	for (unsigned int i = 0; i < cmd_len; i++)
+
		fprintf(stderr, "\t%s\n", cmd[i].name);
}

static int
@@ -63,7 +70,7 @@ exec_help(int argc, char **argv)
		return(EX_USAGE);
	}

-
	for (int i = 0; i < cmd_len; i++) {
+
	for (unsigned int i = 0; i < cmd_len; i++) {
		if (strcmp(cmd[i].name, argv[1]) == 0) {
			assert(cmd[i].usage != NULL);
			cmd[i].usage();
@@ -71,15 +78,16 @@ exec_help(int argc, char **argv)
		}
	}

-
	// Command name not found
-
	warnx("%s is not a valid command", argv[1]);
+
	/* Command name not found */
+
	warnx("'%s' is not a valid command", argv[1]);
+

	return (1);
}

int
main(int argc, char **argv)
{
-
	int i;
+
	unsigned int i;
	struct commands *command = NULL;
	int ambiguous = -1;
	size_t len;
@@ -121,7 +129,9 @@ main(int argc, char **argv)
	}

	if (ambiguous == 1) {
-
		warnx("Ambiguous command: %s, could be:", argv[1]);
+
		warnx("Ambiguous command: '%s'. See 'pkg help' for more information.", argv[1]);
+
		warnx("'%s' could be one of the following:", argv[1]);
+

		for (i = 0; i < cmd_len; i++)
			if (strncmp(argv[1], cmd[i].name, len) == 0)
				warnx("\t%s",cmd[i].name);
@@ -129,3 +139,4 @@ main(int argc, char **argv)

	return (EX_USAGE);
}
+

modified pkg/register.c
@@ -32,11 +32,10 @@ static struct {
void
usage_register(void)
{
-
	fprintf(stderr, "register -c comment -d desc -f plist_file -p prefix "
-
			"-m mtree_file -n pkgname -o origin -r maintainer "
-
			"[-P depends] [-C conflicts] [-M message_file] [-s scripts] "
-
			"[-a arch] [-w www] [-O options] [-H]"
-
			"\n");
+
	fprintf(stderr, "usage: pkg register -c comment -d desc -f plist_file -p prefix\n");
+
	fprintf(stderr, "                    -m mtree_file -n pkgname -o origin -r maintainer\n");
+
	fprintf(stderr, "                    [-P depends] [-C conflicts] [-M message_file] [-s scripts]\n");
+
	fprintf(stderr, "                    [-a arch] [-w www] [-O options] [-H]\n");
}

int
modified pkg/repo.c
@@ -9,7 +9,7 @@
void
usage_repo(void)
{
-
	fprintf(stderr, "repo <repo-path>\n");
+
	fprintf(stderr, "usage: pkg repo <repo-path>\n");
}

static void
modified pkg/version.c
@@ -8,10 +8,10 @@
void
usage_version(void)
{
-
	fprintf(stderr, "version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string]"
-
			"[-O origin] [index]\n"
-
			"version -t version1 version2\n"
-
			"version -T pkgname pattern\n");
+
	fprintf(stderr, "usage: pkg version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string]\n");
+
	fprintf(stderr, "                   [-O origin] [index]\n");
+
	fprintf(stderr, "       pkg version -t <version1> <version2>\n");
+
	fprintf(stderr, "       pkg version -T <pkgname> <pattern>\n");
}

int exec_version(int argc, char **argv)
modified pkg/which.c
@@ -14,7 +14,7 @@
void
usage_which(void)
{
-
	fprintf(stderr, "which <file>\n");
+
	fprintf(stderr, "usage: pkg which <file>\n");
}

int