diff options
author | B. Watson <urchlay@slackware.uk> | 2024-04-24 15:18:53 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-04-24 15:18:53 -0400 |
commit | 3286d83fb8ddbcbbcde3adca2b41dbb3339daa02 (patch) | |
tree | 5013babab1682800127fa029a3222097beae2d21 /blob2xex.c | |
parent | 8ca7c68e9e3baa4c0d17ffeaaee84ff351c104eb (diff) | |
download | bw-atari8-tools-3286d83fb8ddbcbbcde3adca2b41dbb3339daa02.tar.gz |
blob2xex: add -v -h/--help -V/--version options.
Diffstat (limited to 'blob2xex.c')
-rw-r--r-- | blob2xex.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -121,7 +121,21 @@ int main(int argc, char **argv) { char *outfile = 0, *infile = 0; int i, loadaddr = -1, runaddr = -1, initaddr = -1, offset = 0, size = DEFAULT_SIZE, *param = 0; - xex_verbose = 1; + outfile = argv[1]; + if(!outfile || strcmp(outfile, "--help") == 0 || strcmp(outfile, "-h") == 0) { + usage(); + exit(0); + } + + if(strcmp(outfile, "--version") == 0 || strcmp(outfile, "-V") == 0) { + printf(SELF " " VERSION "\n"); + exit(0); + } + + if(outfile[0] == '-' && outfile[1] != '\0') { + fprintf(stderr, SELF ": output file must come before any options.\n"); + exit(1); + } if(argc < 5) { fprintf(stderr, SELF ": not enough arguments.\n"); @@ -129,8 +143,6 @@ int main(int argc, char **argv) { exit(1); } - outfile = argv[1]; - for(i = 2; i < argc; i++) { char *arg = argv[i]; @@ -153,6 +165,7 @@ int main(int argc, char **argv) { case 'i': param = &initaddr; break; case 'o': param = &offset; break; case 's': param = &size; break; + case 'v': xex_verbose = 1; break; default: fprintf(stderr, SELF ": unknown option '-%c'\n", arg[1]); usage(); |