+static const tchar *usage_strings[] = {
+[CMD_APPEND] =
+T(
+" %"TS" (DIRECTORY | NTFS_VOLUME) WIMFILE\n"
+" [IMAGE_NAME [IMAGE_DESCRIPTION]] [--boot]\n"
+" [--check] [--nocheck] [--flags EDITION_ID] [--verbose]\n"
+" [--dereference] [--config=FILE] [--threads=NUM_THREADS]\n"
+" [--source-list] [--no-acls] [--strict-acls] [--rpfix]\n"
+" [--norpfix] [--unix-data] [--pipable]\n"
+" [--update-of=[WIMFILE:]IMAGE]\n"
+),
+[CMD_APPLY] =
+T(
+" %"TS" WIMFILE [(IMAGE_NUM | IMAGE_NAME | all)]\n"
+" (DIRECTORY | NTFS_VOLUME) [--check] [--hardlink]\n"
+" [--symlink] [--verbose] [--ref=\"GLOB\"] [--unix-data]\n"
+" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n"
+" [--include-invalid-names]\n"
+),
+[CMD_CAPTURE] =
+T(
+" %"TS" (DIRECTORY | NTFS_VOLUME) WIMFILE\n"
+" [IMAGE_NAME [IMAGE_DESCRIPTION]] [--boot]\n"
+" [--check] [--nocheck] [--compress=TYPE]\n"
+" [--flags EDITION_ID] [--verbose] [--dereference]\n"
+" [--config=FILE] [--threads=NUM_THREADS] [--source-list]\n"
+" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n"
+" [--unix-data] [--pipable] [--update-of=[WIMFILE:]IMAGE]\n"
+" [--delta-from=WIMFILE]\n"
+),
+[CMD_DELETE] =
+T(
+" %"TS" WIMFILE (IMAGE_NUM | IMAGE_NAME | all) [--check]\n"
+" [--soft]\n"
+),
+[CMD_DIR] =
+T(
+" %"TS" WIMFILE (IMAGE_NUM | IMAGE_NAME | all) [--path=PATH]\n"
+),
+[CMD_EXPORT] =
+T(
+" %"TS" SRC_WIMFILE (SRC_IMAGE_NUM | SRC_IMAGE_NAME | all ) \n"
+" DEST_WIMFILE [DEST_IMAGE_NAME [DEST_IMAGE_DESCRIPTION]]\n"
+" [--boot] [--check] [--nocheck] [--compress=TYPE]\n"
+" [--ref=\"GLOB\"] [--threads=NUM_THREADS] [--rebuild]\n"
+" [--pipable] [--not-pipable]\n"
+),
+[CMD_EXTRACT] =
+T(
+" %"TS" WIMFILE (IMAGE_NUM | IMAGE_NAME) [PATH...]\n"
+" [--check] [--ref=\"GLOB\"] [--verbose] [--unix-data]\n"
+" [--no-acls] [--strict-acls] [--to-stdout]\n"
+" [--dest-dir=CMD_DIR] [--include-invalid-names]\n"
+),
+[CMD_INFO] =
+T(
+" %"TS" WIMFILE [(IMAGE_NUM | IMAGE_NAME) [NEW_NAME\n"
+" [NEW_DESC]]] [--boot] [--check] [--nocheck] [--header]\n"
+" [--lookup-table] [--xml] [--extract-xml FILE]\n"
+" [--metadata]\n"
+),
+[CMD_JOIN] =
+T(
+" %"TS" OUT_WIMFILE SPLIT_WIM_PART... [--check]\n"
+),
+#if WIM_MOUNTING_SUPPORTED
+[CMD_MOUNT] =
+T(
+" %"TS" WIMFILE [(IMAGE_NUM | IMAGE_NAME)] DIRECTORY\n"
+" [--check] [--debug] [--streams-interface=INTERFACE]\n"
+" [--ref=\"GLOB\"] [--unix-data] [--allow-other]\n"
+),
+[CMD_MOUNTRW] =
+T(
+" %"TS" WIMFILE [(IMAGE_NUM | IMAGE_NAME)] DIRECTORY\n"
+" [--check] [--debug] [--streams-interface=INTERFACE]\n"
+" [--staging-dir=CMD_DIR] [--unix-data] [--allow-other]\n"
+),
+#endif
+[CMD_OPTIMIZE] =
+T(
+" %"TS" WIMFILE [--check] [--nocheck] [--recompress]\n"
+" [--recompress-slow] [--compress=TYPE]\n"
+" [--threads=NUM_THREADS] [--pipable] [--not-pipable]\n"
+),
+[CMD_SPLIT] =
+T(
+" %"TS" WIMFILE SPLIT_WIM_PART_1 PART_SIZE_MB [--check]\n"
+),
+#if WIM_MOUNTING_SUPPORTED
+[CMD_UNMOUNT] =
+T(
+" %"TS" DIRECTORY [--commit] [--check] [--rebuild] [--lazy]\n"
+),
+#endif
+[CMD_UPDATE] =
+T(
+" %"TS" WIMFILE [IMAGE_NUM | IMAGE_NAME] [--check] [--rebuild]\n"
+" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
+" [DEFAULT_DELETE_OPTIONS] [--command=STRING] [< CMDFILE]\n"
+),
+};
+
+static const tchar *invocation_name;
+static int invocation_cmd = CMD_NONE;
+
+static const tchar *get_cmd_string(int cmd, bool nospace)
+{
+ static tchar buf[50];
+ if (cmd == CMD_NONE) {
+ tsprintf(buf, T("%"TS), T(IMAGEX_PROGNAME));
+ } else if (invocation_cmd != CMD_NONE) {
+ tsprintf(buf, T("wim%"TS), imagex_commands[cmd].name);
+ } else {
+ const tchar *format;
+
+ if (nospace)
+ format = T("%"TS"-%"TS"");
+ else
+ format = T("%"TS" %"TS"");
+ tsprintf(buf, format, invocation_name, imagex_commands[cmd].name);
+ }
+ return buf;
+}
+