Commit 569f1896 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

Have programs display version information in their usage help



This way we don't have to introduce new options for retrieving
version info. For those programs that do not output their usage
by default (e.g. because they would process stdin), you may pass
a "-?" option to get help - and thus version information.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 57928140
...@@ -336,6 +336,13 @@ void print_boot1_file_head(boot1_file_head_t *hdr, loader_type type) ...@@ -336,6 +336,13 @@ void print_boot1_file_head(boot1_file_head_t *hdr, loader_type type)
printf("Unknown boot0 header version\n"); printf("Unknown boot0 header version\n");
} }
static void usage(const char *cmd)
{
puts("sunxi-bootinfo " VERSION "\n");
printf("Usage: %s [<filename>]\n", cmd);
printf(" With no <filename> given, will read from stdin instead\n");
}
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
FILE *in = stdin; FILE *in = stdin;
...@@ -352,8 +359,11 @@ int main(int argc, char * argv[]) ...@@ -352,8 +359,11 @@ int main(int argc, char * argv[])
} }
if (argc > 1) { if (argc > 1) {
in = fopen(argv[1], "rb"); in = fopen(argv[1], "rb");
if (!in) if (!in) {
fail("open input: "); if (*argv[1] == '-')
usage(argv[0]);
fail("open input");
}
} }
int len; int len;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "common.h"
#include "portable_endian.h" #include "portable_endian.h"
#include "progress.h" #include "progress.h"
...@@ -1565,6 +1566,7 @@ int main(int argc, char **argv) ...@@ -1565,6 +1566,7 @@ int main(int argc, char **argv)
#endif #endif
if (argc <= 1) { if (argc <= 1) {
puts("sunxi-fel " VERSION "\n");
printf("Usage: %s [options] command arguments... [command...]\n" printf("Usage: %s [options] command arguments... [command...]\n"
" -v, --verbose Verbose logging\n" " -v, --verbose Verbose logging\n"
" -p, --progress \"write\" transfers show a progress bar\n" " -p, --progress \"write\" transfers show a progress bar\n"
......
...@@ -215,6 +215,7 @@ done: ...@@ -215,6 +215,7 @@ done:
*/ */
static inline void app_usage(const char *arg0, int mode) static inline void app_usage(const char *arg0, int mode)
{ {
fputs("sunxi-fexc " VERSION "\n\n", stderr);
errf("Usage: %s [-vq]%s[<input> [<output>]]\n", arg0, errf("Usage: %s [-vq]%s[<input> [<output>]]\n", arg0,
mode ? " " : " [-I <infmt>] [-O <outfmt>] "); mode ? " " : " [-I <infmt>] [-O <outfmt>] ");
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#include "common.h"
#include "portable_endian.h" #include "portable_endian.h"
#if defined(CONFIG_BCH_CONST_PARAMS) #if defined(CONFIG_BCH_CONST_PARAMS)
...@@ -62,7 +63,6 @@ ...@@ -62,7 +63,6 @@
#define cpu_to_be32 htobe32 #define cpu_to_be32 htobe32
#define kfree free #define kfree free
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define BCH_PRIMITIVE_POLY 0x5803 #define BCH_PRIMITIVE_POLY 0x5803
...@@ -916,7 +916,9 @@ static int create_image(const struct image_info *info) ...@@ -916,7 +916,9 @@ static int create_image(const struct image_info *info)
static void display_help(int status) static void display_help(int status)
{ {
fprintf(status == EXIT_SUCCESS ? stdout : stderr, fprintf(status == EXIT_SUCCESS ? stdout : stderr,
"Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image\n" "sunxi-nand-image-builder %s\n"
"\n"
"Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image\n"
"\n" "\n"
"Creates a raw NAND image that can be read by the sunxi NAND controller.\n" "Creates a raw NAND image that can be read by the sunxi NAND controller.\n"
"\n" "\n"
...@@ -960,8 +962,8 @@ static void display_help(int status) ...@@ -960,8 +962,8 @@ static void display_help(int status)
" A normal image can be generated with\n" " A normal image can be generated with\n"
" sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -c 40/1024\n" " sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -c 40/1024\n"
" A boot0 image can be generated with\n" " A boot0 image can be generated with\n"
" sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -b -u 4096 -c 64/1024\n" " sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -b -u 4096 -c 64/1024\n",
); VERSION);
exit(status); exit(status);
} }
......
...@@ -24,9 +24,11 @@ ...@@ -24,9 +24,11 @@
#include <strings.h> #include <strings.h>
#include <fcntl.h> #include <fcntl.h>
#include "nand-common.h" #include "nand-common.h"
#include "common.h"
void usage(const char *cmd) void usage(const char *cmd)
{ {
puts("sunxi-nand-part " VERSION "\n");
printf("usage: %s [-f a10|a20] nand-device\n", cmd); printf("usage: %s [-f a10|a20] nand-device\n", cmd);
printf(" %s nand-device 'name2 len2 [usertype2]' ['name3 len3 [usertype3]'] ...\n", cmd); printf(" %s nand-device 'name2 len2 [usertype2]' ['name3 len3 [usertype3]'] ...\n", cmd);
printf(" %s [-f a10|a20] nand-device start1 'name1 len1 [usertype1]' ['name2 len2 [usertype2]'] ...\n", cmd); printf(" %s [-f a10|a20] nand-device start1 'name1 len1 [usertype1]' ['name2 len2 [usertype2]'] ...\n", cmd);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "common.h"
#include "portable_endian.h" #include "portable_endian.h"
struct phoenix_ptable { struct phoenix_ptable {
...@@ -76,6 +77,7 @@ err: ...@@ -76,6 +77,7 @@ err:
static void usage(char **argv) static void usage(char **argv)
{ {
puts("phoenix-info " VERSION "\n");
printf("Usage: %s [options] [phoenix_image]\n" printf("Usage: %s [options] [phoenix_image]\n"
" -v verbose\n" " -v verbose\n"
" -q quiet\n" " -q quiet\n"
......
...@@ -165,7 +165,7 @@ static const char *argv0; ...@@ -165,7 +165,7 @@ static const char *argv0;
static void usage(int rc ) static void usage(int rc )
{ {
fputs("sunxi-pio " VERSION "\n\n", stderr);
fprintf(stderr, "usage: %s -m|-i input [-o output] pin..\n", argv0); fprintf(stderr, "usage: %s -m|-i input [-o output] pin..\n", argv0);
fprintf(stderr," -m mmap - read pin state from system\n"); fprintf(stderr," -m mmap - read pin state from system\n");
fprintf(stderr," -i read pin state from file\n"); fprintf(stderr," -i read pin state from file\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment