make default usage fit on one line; de-duplicates man page info
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
diff --git a/got/got.c b/got/got.c
index 3efedf2..8787eff 100644
--- a/got/got.c
+++ b/got/got.c
@@ -70,7 +70,6 @@ struct cmd {
const char *cmd_name;
const struct got_error *(*cmd_main)(int, char *[]);
void (*cmd_usage)(void);
- const char *cmd_descr;
};
__dead static void usage(void);
@@ -107,36 +106,21 @@ static const struct got_error* cmd_cherrypick(int, char *[]);
static const struct got_error* cmd_backout(int, char *[]);
static struct cmd got_commands[] = {
- { "init", cmd_init, usage_init,
- "create a new empty repository" },
- { "checkout", cmd_checkout, usage_checkout,
- "check out a new work tree from a repository" },
- { "update", cmd_update, usage_update,
- "update a work tree to a different commit" },
- { "log", cmd_log, usage_log,
- "show repository history" },
- { "diff", cmd_diff, usage_diff,
- "compare files and directories" },
- { "blame", cmd_blame, usage_blame,
- "show when lines in a file were changed" },
- { "tree", cmd_tree, usage_tree,
- "list files and directories in repository" },
- { "status", cmd_status, usage_status,
- "show modification status of files" },
- { "ref", cmd_ref, usage_ref,
- "manage references in repository" },
- { "add", cmd_add, usage_add,
- "add new files to version control" },
- { "rm", cmd_rm, usage_rm,
- "remove a versioned file" },
- { "revert", cmd_revert, usage_revert,
- "revert uncommitted changes" },
- { "commit", cmd_commit, usage_commit,
- "write changes from work tree to repository" },
- { "cherrypick", cmd_cherrypick, usage_cherrypick,
- "merge a single commit from another branch into a work tree" },
- { "backout", cmd_backout, usage_backout,
- "reverse-merge changes from a commit into a work tree" },
+ { "init", cmd_init, usage_init },
+ { "checkout", cmd_checkout, usage_checkout },
+ { "update", cmd_update, usage_update },
+ { "log", cmd_log, usage_log },
+ { "diff", cmd_diff, usage_diff },
+ { "blame", cmd_blame, usage_blame },
+ { "tree", cmd_tree, usage_tree },
+ { "status", cmd_status, usage_status },
+ { "ref", cmd_ref, usage_ref },
+ { "add", cmd_add, usage_add },
+ { "rm", cmd_rm, usage_rm },
+ { "revert", cmd_revert, usage_revert },
+ { "commit", cmd_commit, usage_commit },
+ { "cherrypick", cmd_cherrypick, usage_cherrypick },
+ { "backout", cmd_backout, usage_backout },
};
int
@@ -197,14 +181,7 @@ main(int argc, char *argv[])
__dead static void
usage(void)
{
- int i;
-
- fprintf(stderr, "usage: %s [-h] command [arg ...]\n\n"
- "Available commands:\n", getprogname());
- for (i = 0; i < nitems(got_commands); i++) {
- struct cmd *cmd = &got_commands[i];
- fprintf(stderr, " %s: %s\n", cmd->cmd_name, cmd->cmd_descr);
- }
+ fprintf(stderr, "usage: %s [-h] command [arg ...]\n", getprogname());
exit(1);
}
diff --git a/tog/tog.c b/tog/tog.c
index 49ba8f0..5aed76e 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -69,7 +69,6 @@ struct tog_cmd {
const char *name;
const struct got_error *(*cmd_main)(int, char *[]);
void (*cmd_usage)(void);
- const char *descr;
};
__dead static void usage(void);
@@ -84,14 +83,10 @@ static const struct got_error* cmd_blame(int, char *[]);
static const struct got_error* cmd_tree(int, char *[]);
static struct tog_cmd tog_commands[] = {
- { "log", cmd_log, usage_log,
- "show repository history" },
- { "diff", cmd_diff, usage_diff,
- "compare files and directories" },
- { "blame", cmd_blame, usage_blame,
- "show line-by-line file history" },
- { "tree", cmd_tree, usage_tree,
- "browse trees in repository" },
+ { "log", cmd_log, usage_log },
+ { "diff", cmd_diff, usage_diff },
+ { "blame", cmd_blame, usage_blame },
+ { "tree", cmd_tree, usage_tree },
};
enum tog_view_type {
@@ -4332,14 +4327,7 @@ done:
__dead static void
usage(void)
{
- int i;
-
- fprintf(stderr, "usage: %s [-h] [command] [arg ...]\n\n"
- "Available commands:\n", getprogname());
- for (i = 0; i < nitems(tog_commands); i++) {
- struct tog_cmd *cmd = &tog_commands[i];
- fprintf(stderr, " %s: %s\n", cmd->name, cmd->descr);
- }
+ fprintf(stderr, "usage: %s [-h] [command] [arg ...]\n", getprogname());
exit(1);
}