Support -h/--help for all programs (#1620)

This commit is contained in:
Rangi
2025-01-21 21:24:17 -05:00
committed by GitHub
parent 157826bf82
commit d9654b752f
16 changed files with 54 additions and 20 deletions

View File

@@ -25,6 +25,7 @@ _rgbasm_completions() {
# See the `state` variable below for info about `state_after` # See the `state` variable below for info about `state_after`
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[h]="help:normal"
[E]="export-all:normal" [E]="export-all:normal"
[v]="verbose:normal" [v]="verbose:normal"
[w]=":normal" [w]=":normal"

View File

@@ -8,6 +8,7 @@ _rgbfix_completions() {
# See the `state` variable below for info about `state_after` # See the `state` variable below for info about `state_after`
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[h]="help:normal"
[j]="non-japanese:normal" [j]="non-japanese:normal"
[s]="sgb-compatible:normal" [s]="sgb-compatible:normal"
[v]="validate:normal" [v]="validate:normal"

View File

@@ -8,6 +8,7 @@ _rgbgfx_completions() {
# See the `state` variable below for info about `state_after` # See the `state` variable below for info about `state_after`
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[h]="help:normal"
[C]="color-curve:normal" [C]="color-curve:normal"
[m]="mirror-tiles:normal" [m]="mirror-tiles:normal"
[O]="group-outputs:normal" [O]="group-outputs:normal"

View File

@@ -8,6 +8,7 @@ _rgblink_completions() {
# See the `state` variable below for info about `state_after` # See the `state` variable below for info about `state_after`
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[h]="help:normal"
[d]="dmg:normal" [d]="dmg:normal"
[t]="tiny:normal" [t]="tiny:normal"
[v]="verbose:normal" [v]="verbose:normal"

View File

@@ -36,8 +36,9 @@ _rgbasm_warnings() {
} }
local args=( local args=(
# Arguments are listed here in the same order as in the manual, except for the version # Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-E --export-all)'{-E,--export-all}'[Export all symbols]' '(-E --export-all)'{-E,--export-all}'[Export all symbols]'
'(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]' '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]'

View File

@@ -35,8 +35,9 @@ _mbc_names() {
} }
local args=( local args=(
# Arguments are listed here in the same order as in the manual, except for the version # Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-C --color-only -c --color-compatible)'{-C,--color-only}'[Mark ROM as GBC-only]' '(-C --color-only -c --color-compatible)'{-C,--color-only}'[Mark ROM as GBC-only]'
'(-C --color-only -c --color-compatible)'{-c,--color-compatible}'[Mark ROM as GBC-compatible]' '(-C --color-only -c --color-compatible)'{-c,--color-compatible}'[Mark ROM as GBC-compatible]'

View File

@@ -10,8 +10,9 @@ _depths() {
} }
local args=( local args=(
# Arguments are listed here in the same order as in the manual, except for the version # Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-a --attr-map -A --auto-attr-map)'{-A,--auto-attr-map}'[Shortcut for -a <file>.attrmap]' '(-a --attr-map -A --auto-attr-map)'{-A,--auto-attr-map}'[Shortcut for -a <file>.attrmap]'
'(-C --color-curve)'{-C,--color-curve}'[Generate palettes using GBC color curve]' '(-C --color-curve)'{-C,--color-curve}'[Generate palettes using GBC color curve]'

View File

@@ -1,8 +1,9 @@
#compdef rgblink #compdef rgblink
local args=( local args=(
# Arguments are listed here in the same order as in the manual, except for the version # Arguments are listed here in the same order as in the manual, except for the version and help
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number and exit]'
'(- : * options)'{-h,--help}'[Print help text and exit]'
'(-d --dmg)'{-d,--dmg}'[Enable DMG mode (-w + no VRAM banking)]' '(-d --dmg)'{-d,--dmg}'[Enable DMG mode (-w + no VRAM banking)]'
'(-t --tiny)'{-t,--tiny}'[Enable tiny mode, disabling ROM banking]' '(-t --tiny)'{-t,--tiny}'[Enable tiny mode, disabling ROM banking]'

View File

@@ -8,7 +8,7 @@
.Nd Game Boy assembler .Nd Game Boy assembler
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl EVvw .Op Fl EhVvw
.Op Fl b Ar chars .Op Fl b Ar chars
.Op Fl D Ar name Ns Op = Ns Ar value .Op Fl D Ar name Ns Op = Ns Ar value
.Op Fl g Ar chars .Op Fl g Ar chars
@@ -67,6 +67,8 @@ Export all labels, including unreferenced and local labels.
.It Fl g Ar chars , Fl \-gfx-chars Ar chars .It Fl g Ar chars , Fl \-gfx-chars Ar chars
Change the four characters used for gfx constants. Change the four characters used for gfx constants.
The defaults are 0123. The defaults are 0123.
.It Fl h , Fl \-help
Print help text for the program and exit.
.It Fl I Ar path , Fl \-include Ar path .It Fl I Ar path , Fl \-include Ar path
Add a new Add a new
.Dq include path ; .Dq include path ;

View File

@@ -8,7 +8,7 @@
.Nd Game Boy header utility and checksum fixer .Nd Game Boy header utility and checksum fixer
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl jOsVv .Op Fl hjOsVv
.Op Fl C | c .Op Fl C | c
.Op Fl f Ar fix_spec .Op Fl f Ar fix_spec
.Op Fl i Ar game_id .Op Fl i Ar game_id
@@ -91,6 +91,8 @@ Fix the global checksum
.It Cm G .It Cm G
Trash the global checksum. Trash the global checksum.
.El .El
.It Fl h , Fl \-help
Print help text for the program and exit.
.It Fl i Ar game_id , Fl \-game-id Ar game_id .It Fl i Ar game_id , Fl \-game-id Ar game_id
Set the game ID string Set the game ID string
.Pq Ad 0x13F Ns \(en Ns Ad 0x142 .Pq Ad 0x13F Ns \(en Ns Ad 0x142

View File

@@ -10,7 +10,7 @@
.Nd Game Boy graphics converter .Nd Game Boy graphics converter
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl CmOuVXYZ .Op Fl CmhOuVXYZ
.Op Fl v Op Fl v No ... .Op Fl v Op Fl v No ...
.Op Fl a Ar attrmap | Fl A .Op Fl a Ar attrmap | Fl A
.Op Fl b Ar base_ids .Op Fl b Ar base_ids
@@ -165,6 +165,8 @@ for a list of formats and their descriptions.
.It Fl d Ar depth , Fl \-depth Ar depth .It Fl d Ar depth , Fl \-depth Ar depth
Set the bit depth of the output tile data, in bits per pixel (bpp), either 1 or 2 (the default). Set the bit depth of the output tile data, in bits per pixel (bpp), either 1 or 2 (the default).
This changes how tile data is output, and the maximum number of colors per palette (2 and 4 respectively). This changes how tile data is output, and the maximum number of colors per palette (2 and 4 respectively).
.It Fl h , Fl \-help
Print help text for the program and exit.
.It Fl i Ar input_tiles , Fl \-input-tileset Ar input_tiles .It Fl i Ar input_tiles , Fl \-input-tileset Ar input_tiles
Use the specified input tiles in addition to having Use the specified input tiles in addition to having
.Nm .Nm

View File

@@ -8,7 +8,7 @@
.Nd Game Boy linker .Nd Game Boy linker
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl dMtVvwx .Op Fl dhMtVvwx
.Op Fl l Ar linker_script .Op Fl l Ar linker_script
.Op Fl m Ar map_file .Op Fl m Ar map_file
.Op Fl n Ar sym_file .Op Fl n Ar sym_file
@@ -67,6 +67,8 @@ Enable DMG mode.
Prohibit the use of sections that doesn't exist on a DMG, such as VRAM bank 1. Prohibit the use of sections that doesn't exist on a DMG, such as VRAM bank 1.
This option automatically enables This option automatically enables
.Fl w . .Fl w .
.It Fl h , Fl \-help
Print help text for the program and exit.
.It Fl l Ar linker_script , Fl \-linkerscript Ar linker_script .It Fl l Ar linker_script , Fl \-linkerscript Ar linker_script
Specify a linker script file that tells the linker how sections must be placed in the ROM. Specify a linker script file that tells the linker how sections must be placed in the ROM.
The attributes assigned in the linker script must be consistent with any assigned in the code. The attributes assigned in the linker script must be consistent with any assigned in the code.

View File

@@ -48,7 +48,7 @@ static std::string make_escape(std::string &str) {
} }
// Short options // Short options
static char const *optstring = "b:D:Eg:I:M:o:P:p:Q:r:s:VvW:wX:"; static char const *optstring = "b:D:Eg:hI:M:o:P:p:Q:r:s:VvW:wX:";
// Variables for the long-only options // Variables for the long-only options
static int depType; // Variants of `-M` static int depType; // Variants of `-M`
@@ -69,6 +69,7 @@ static option const longopts[] = {
{"include", required_argument, nullptr, 'I'}, {"include", required_argument, nullptr, 'I'},
{"dependfile", required_argument, nullptr, 'M'}, {"dependfile", required_argument, nullptr, 'M'},
{"MG", no_argument, &depType, 'G'}, {"MG", no_argument, &depType, 'G'},
{"help", no_argument, nullptr, 'h'},
{"MP", no_argument, &depType, 'P'}, {"MP", no_argument, &depType, 'P'},
{"MT", required_argument, &depType, 'T'}, {"MT", required_argument, &depType, 'T'},
{"warning", required_argument, nullptr, 'W'}, {"warning", required_argument, nullptr, 'W'},
@@ -88,7 +89,7 @@ static option const longopts[] = {
static void printUsage() { static void printUsage() {
fputs( fputs(
"Usage: rgbasm [-EVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n" "Usage: rgbasm [-EhVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n"
" [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n" " [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n"
" [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n" " [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n"
" [-r depth] [-s features:state_file] [-W warning] [-X max_errors]\n" " [-r depth] [-s features:state_file] [-W warning] [-X max_errors]\n"
@@ -169,6 +170,10 @@ int main(int argc, char *argv[]) {
errx("Must specify exactly 4 characters for option 'g'"); errx("Must specify exactly 4 characters for option 'g'");
break; break;
case 'h':
printUsage();
exit(0);
case 'I': case 'I':
fstk_AddIncludePath(musl_optarg); fstk_AddIncludePath(musl_optarg);
break; break;

View File

@@ -23,7 +23,7 @@ static_assert(UNSPECIFIED > 0xFF, "UNSPECIFIED should not be in byte range!");
static constexpr off_t BANK_SIZE = 0x4000; static constexpr off_t BANK_SIZE = 0x4000;
// Short options // Short options
static char const *optstring = "Ccf:i:jk:L:l:m:n:Op:r:st:Vv"; static char const *optstring = "Ccf:hi:jk:L:l:m:n:Op:r:st:Vv";
/* /*
* Equivalent long options * Equivalent long options
@@ -39,6 +39,7 @@ static option const longopts[] = {
{"color-only", no_argument, nullptr, 'C'}, {"color-only", no_argument, nullptr, 'C'},
{"color-compatible", no_argument, nullptr, 'c'}, {"color-compatible", no_argument, nullptr, 'c'},
{"fix-spec", required_argument, nullptr, 'f'}, {"fix-spec", required_argument, nullptr, 'f'},
{"help", no_argument, nullptr, 'h'},
{"game-id", required_argument, nullptr, 'i'}, {"game-id", required_argument, nullptr, 'i'},
{"non-japanese", no_argument, nullptr, 'j'}, {"non-japanese", no_argument, nullptr, 'j'},
{"new-licensee", required_argument, nullptr, 'k'}, {"new-licensee", required_argument, nullptr, 'k'},
@@ -58,7 +59,7 @@ static option const longopts[] = {
static void printUsage() { static void printUsage() {
fputs( fputs(
"Usage: rgbfix [-jOsVv] [-C | -c] [-f <fix_spec>] [-i <game_id>] [-k <licensee>]\n" "Usage: rgbfix [-hjOsVv] [-C | -c] [-f <fix_spec>] [-i <game_id>] [-k <licensee>]\n"
" [-L <logo_file>] [-l <licensee_byte>] [-m <mbc_type>]\n" " [-L <logo_file>] [-l <licensee_byte>] [-m <mbc_type>]\n"
" [-n <rom_version>] [-p <pad_value>] [-r <ram_size>] [-t <title_str>]\n" " [-n <rom_version>] [-p <pad_value>] [-r <ram_size>] [-t <title_str>]\n"
" <file> ...\n" " <file> ...\n"
@@ -1281,6 +1282,10 @@ int main(int argc, char *argv[]) {
} }
break; break;
case 'h':
printUsage();
exit(0);
case 'i': case 'i':
gameID = musl_optarg; gameID = musl_optarg;
len = strlen(gameID); len = strlen(gameID);

View File

@@ -108,7 +108,7 @@ void Options::verbosePrint(uint8_t level, char const *fmt, ...) const {
} }
// Short options // Short options
static char const *optstring = "-Aa:b:Cc:d:i:L:mN:n:Oo:Pp:Qq:r:s:Tt:U:uVvXx:YZ"; static char const *optstring = "-Aa:b:Cc:d:hi:L:mN:n:Oo:Pp:Qq:r:s:Tt:U:uVvXx:YZ";
/* /*
* Equivalent long options * Equivalent long options
@@ -127,6 +127,7 @@ static option const longopts[] = {
{"color-curve", no_argument, nullptr, 'C'}, {"color-curve", no_argument, nullptr, 'C'},
{"colors", required_argument, nullptr, 'c'}, {"colors", required_argument, nullptr, 'c'},
{"depth", required_argument, nullptr, 'd'}, {"depth", required_argument, nullptr, 'd'},
{"help", no_argument, nullptr, 'h'},
{"input-tileset", required_argument, nullptr, 'i'}, {"input-tileset", required_argument, nullptr, 'i'},
{"slice", required_argument, nullptr, 'L'}, {"slice", required_argument, nullptr, 'L'},
{"mirror-tiles", no_argument, nullptr, 'm'}, {"mirror-tiles", no_argument, nullptr, 'm'},
@@ -155,7 +156,7 @@ static option const longopts[] = {
static void printUsage() { static void printUsage() {
fputs( fputs(
"Usage: rgbgfx [-r stride] [-CmOuVXYZ] [-v [-v ...]] [-a <attr_map> | -A]\n" "Usage: rgbgfx [-r stride] [-ChmOuVXYZ] [-v [-v ...]] [-a <attr_map> | -A]\n"
" [-b <base_ids>] [-c <colors>] [-d <depth>] [-i <tileset_file>]\n" " [-b <base_ids>] [-c <colors>] [-d <depth>] [-i <tileset_file>]\n"
" [-L <slice>] [-N <nb_tiles>] [-n <nb_pals>] [-o <out_file>]\n" " [-L <slice>] [-N <nb_tiles>] [-n <nb_pals>] [-o <out_file>]\n"
" [-p <pal_file> | -P] [-q <pal_map> | -Q] [-s <nb_colors>]\n" " [-p <pal_file> | -P] [-q <pal_map> | -Q] [-s <nb_colors>]\n"
@@ -430,6 +431,9 @@ static char *parseArgv(int argc, char *argv[]) {
options.bitDepth = 2; options.bitDepth = 2;
} }
break; break;
case 'h':
printUsage();
exit(0);
case 'i': case 'i':
if (!options.inputTileset.empty()) if (!options.inputTileset.empty())
warning("Overriding input tileset file %s", options.inputTileset.c_str()); warning("Overriding input tileset file %s", options.inputTileset.c_str());

View File

@@ -130,7 +130,7 @@ void argErr(char flag, char const *fmt, ...) {
} }
// Short options // Short options
static char const *optstring = "dl:m:Mn:O:o:p:S:tVvWwx"; static char const *optstring = "dhl:m:Mn:O:o:p:S:tVvWwx";
/* /*
* Equivalent long options * Equivalent long options
@@ -144,6 +144,7 @@ static char const *optstring = "dl:m:Mn:O:o:p:S:tVvWwx";
*/ */
static option const longopts[] = { static option const longopts[] = {
{"dmg", no_argument, nullptr, 'd'}, {"dmg", no_argument, nullptr, 'd'},
{"help", no_argument, nullptr, 'h'},
{"linkerscript", required_argument, nullptr, 'l'}, {"linkerscript", required_argument, nullptr, 'l'},
{"map", required_argument, nullptr, 'm'}, {"map", required_argument, nullptr, 'm'},
{"no-sym-in-map", no_argument, nullptr, 'M'}, {"no-sym-in-map", no_argument, nullptr, 'M'},
@@ -162,7 +163,7 @@ static option const longopts[] = {
static void printUsage() { static void printUsage() {
fputs( fputs(
"Usage: rgblink [-dMtVvwx] [-l script] [-m map_file] [-n sym_file]\n" "Usage: rgblink [-dhMtVvwx] [-l script] [-m map_file] [-n sym_file]\n"
" [-O overlay_file] [-o out_file] [-p pad_value]\n" " [-O overlay_file] [-o out_file] [-p pad_value]\n"
" [-S spec] <file> ...\n" " [-S spec] <file> ...\n"
"Useful options:\n" "Useful options:\n"
@@ -327,6 +328,9 @@ int main(int argc, char *argv[]) {
isDmgMode = true; isDmgMode = true;
isWRAM0Mode = true; isWRAM0Mode = true;
break; break;
case 'h':
printUsage();
exit(0);
case 'l': case 'l':
if (linkerScriptName) if (linkerScriptName)
warnx("Overriding linker script %s", linkerScriptName); warnx("Overriding linker script %s", linkerScriptName);