summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-08-15 13:17:05 -0700
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-08-16 17:14:14 +0300
commitd2432457a5469804c33f3f71c5d1a5f722a9295f (patch)
tree57c550add03647c6587df1f4f683a3ce1a881b99
parente7b50d4366c6b72241aa0c0c2472103305ee0ed5 (diff)
mtdinfo: consolidate help as display_help()
The help message for mtdinfo is unnecessarily disjointed. It is split into three strings which reuse the PROGRAM_NAME string inefficiently and don't have a consistent style. This fixup should provide a cleaner look with aligned columns and easier-to-read source code. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
-rw-r--r--ubi-utils/mtdinfo.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index 1c3a46f..d919673 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -50,28 +50,32 @@ static struct args args = {
.node = NULL,
};
-static const char doc[] = PROGRAM_NAME " version " VERSION
- " - a tool to print MTD information.";
-
-static const char optionsstr[] =
-"-u, --ubi-info print what would UBI layout be if it was put\n"
-" on this MTD device\n"
-"-M, --map print eraseblock map\n"
-"-a, --all print information about all MTD devices\n"
-" Note: `--all' may give less info per device\n"
-" than, e.g., `mtdinfo /dev/mtdX'\n"
-"-h, --help print help message\n"
-"-V, --version print program version";
-
-static const char usage[] =
-"Usage: " PROGRAM_NAME " <MTD node file path> [--map | -M] [--ubi-info | -u]\n"
-" " PROGRAM_NAME " --all [--ubi-info | -u]\n"
-" " PROGRAM_NAME " [--help | --version]\n"
-"\n"
-"Example 1: " PROGRAM_NAME " /dev/mtd0 print information MTD device /dev/mtd0\n"
-"Example 2: " PROGRAM_NAME " /dev/mtd0 -u print information MTD device /dev/mtd0\n"
-"\t\t\t\t and include UBI layout information\n"
-"Example 3: " PROGRAM_NAME " -a print information about all MTD devices\n";
+static void display_help(void)
+{
+ printf(
+ "%1$s version %2$s - a tool to print MTD information.\n"
+ "\n"
+ "Usage: %1$s <MTD node file path> [--map | -M] [--ubi-info | -u]\n"
+ " %1$s --all [--ubi-info | -u]\n"
+ " %1$s [--help | --version]\n"
+ "\n"
+ "Options:\n"
+ "-u, --ubi-info print what would UBI layout be if it was put\n"
+ " on this MTD device\n"
+ "-M, --map print eraseblock map\n"
+ "-a, --all print information about all MTD devices\n"
+ " Note: `--all' may give less info per device\n"
+ " than, e.g., `mtdinfo /dev/mtdX'\n"
+ "-h, --help print help message\n"
+ "-V, --version print program version\n"
+ "\n"
+ "Examples:\n"
+ " %1$s /dev/mtd0 print information MTD device /dev/mtd0\n"
+ " %1$s /dev/mtd0 -u print information MTD device /dev/mtd0\n"
+ " %4$*3$s and include UBI layout information\n"
+ " %1$s -a print information about all MTD devices\n",
+ PROGRAM_NAME, VERSION, (int)strlen(PROGRAM_NAME) + 3, "");
+}
static const struct option long_options[] = {
{ .name = "ubi-info", .has_arg = 0, .flag = NULL, .val = 'u' },
@@ -105,9 +109,7 @@ static int parse_opt(int argc, char * const argv[])
break;
case 'h':
- printf("%s\n\n", doc);
- printf("%s\n\n", usage);
- printf("%s\n", optionsstr);
+ display_help();
exit(EXIT_SUCCESS);
case 'V':