From d9654b752f512a9f5b0c885ad61b27a4f9cef979 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:24:17 -0500 Subject: [PATCH] Support `-h/--help` for all programs (#1620) --- contrib/bash_compl/_rgbasm.bash | 1 + contrib/bash_compl/_rgbfix.bash | 1 + contrib/bash_compl/_rgbgfx.bash | 1 + contrib/bash_compl/_rgblink.bash | 1 + contrib/zsh_compl/_rgbasm | 5 +++-- contrib/zsh_compl/_rgbfix | 5 +++-- contrib/zsh_compl/_rgbgfx | 5 +++-- contrib/zsh_compl/_rgblink | 5 +++-- man/rgbasm.1 | 4 +++- man/rgbfix.1 | 4 +++- man/rgbgfx.1 | 4 +++- man/rgblink.1 | 4 +++- src/asm/main.cpp | 9 +++++++-- src/fix/main.cpp | 9 +++++++-- src/gfx/main.cpp | 8 ++++++-- src/link/main.cpp | 8 ++++++-- 16 files changed, 54 insertions(+), 20 deletions(-) diff --git a/contrib/bash_compl/_rgbasm.bash b/contrib/bash_compl/_rgbasm.bash index 505a8181..3b26bb3e 100755 --- a/contrib/bash_compl/_rgbasm.bash +++ b/contrib/bash_compl/_rgbasm.bash @@ -25,6 +25,7 @@ _rgbasm_completions() { # See the `state` variable below for info about `state_after` declare -A opts=( [V]="version:normal" + [h]="help:normal" [E]="export-all:normal" [v]="verbose:normal" [w]=":normal" diff --git a/contrib/bash_compl/_rgbfix.bash b/contrib/bash_compl/_rgbfix.bash index fa94a11c..a8f03bf2 100755 --- a/contrib/bash_compl/_rgbfix.bash +++ b/contrib/bash_compl/_rgbfix.bash @@ -8,6 +8,7 @@ _rgbfix_completions() { # See the `state` variable below for info about `state_after` declare -A opts=( [V]="version:normal" + [h]="help:normal" [j]="non-japanese:normal" [s]="sgb-compatible:normal" [v]="validate:normal" diff --git a/contrib/bash_compl/_rgbgfx.bash b/contrib/bash_compl/_rgbgfx.bash index 9ac6a272..eb7bff44 100755 --- a/contrib/bash_compl/_rgbgfx.bash +++ b/contrib/bash_compl/_rgbgfx.bash @@ -8,6 +8,7 @@ _rgbgfx_completions() { # See the `state` variable below for info about `state_after` declare -A opts=( [V]="version:normal" + [h]="help:normal" [C]="color-curve:normal" [m]="mirror-tiles:normal" [O]="group-outputs:normal" diff --git a/contrib/bash_compl/_rgblink.bash b/contrib/bash_compl/_rgblink.bash index 41af5d9c..f54adc79 100755 --- a/contrib/bash_compl/_rgblink.bash +++ b/contrib/bash_compl/_rgblink.bash @@ -8,6 +8,7 @@ _rgblink_completions() { # See the `state` variable below for info about `state_after` declare -A opts=( [V]="version:normal" + [h]="help:normal" [d]="dmg:normal" [t]="tiny:normal" [v]="verbose:normal" diff --git a/contrib/zsh_compl/_rgbasm b/contrib/zsh_compl/_rgbasm index 1b2a6bb3..2998be21 100644 --- a/contrib/zsh_compl/_rgbasm +++ b/contrib/zsh_compl/_rgbasm @@ -36,8 +36,9 @@ _rgbasm_warnings() { } local args=( - # Arguments are listed here in the same order as in the manual, except for the version - '(- : * options)'{-V,--version}'[Print version number]' + # Arguments are listed here in the same order as in the manual, except for the version and help + '(- : * 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]' '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]' diff --git a/contrib/zsh_compl/_rgbfix b/contrib/zsh_compl/_rgbfix index 56b54ba4..c559a3b1 100644 --- a/contrib/zsh_compl/_rgbfix +++ b/contrib/zsh_compl/_rgbfix @@ -35,8 +35,9 @@ _mbc_names() { } local args=( - # Arguments are listed here in the same order as in the manual, except for the version - '(- : * options)'{-V,--version}'[Print version number]' + # Arguments are listed here in the same order as in the manual, except for the version and help + '(- : * 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-compatible}'[Mark ROM as GBC-compatible]' diff --git a/contrib/zsh_compl/_rgbgfx b/contrib/zsh_compl/_rgbgfx index b64aa7af..49d9596a 100644 --- a/contrib/zsh_compl/_rgbgfx +++ b/contrib/zsh_compl/_rgbgfx @@ -10,8 +10,9 @@ _depths() { } local args=( - # Arguments are listed here in the same order as in the manual, except for the version - '(- : * options)'{-V,--version}'[Print version number]' + # Arguments are listed here in the same order as in the manual, except for the version and help + '(- : * 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 .attrmap]' '(-C --color-curve)'{-C,--color-curve}'[Generate palettes using GBC color curve]' diff --git a/contrib/zsh_compl/_rgblink b/contrib/zsh_compl/_rgblink index 3e9ca6be..98cccb07 100644 --- a/contrib/zsh_compl/_rgblink +++ b/contrib/zsh_compl/_rgblink @@ -1,8 +1,9 @@ #compdef rgblink local args=( - # Arguments are listed here in the same order as in the manual, except for the version - '(- : * options)'{-V,--version}'[Print version number]' + # Arguments are listed here in the same order as in the manual, except for the version and help + '(- : * 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)]' '(-t --tiny)'{-t,--tiny}'[Enable tiny mode, disabling ROM banking]' diff --git a/man/rgbasm.1 b/man/rgbasm.1 index ae270dee..cc9253a2 100644 --- a/man/rgbasm.1 +++ b/man/rgbasm.1 @@ -8,7 +8,7 @@ .Nd Game Boy assembler .Sh SYNOPSIS .Nm -.Op Fl EVvw +.Op Fl EhVvw .Op Fl b Ar chars .Op Fl D Ar name Ns Op = Ns Ar value .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 Change the four characters used for gfx constants. 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 Add a new .Dq include path ; diff --git a/man/rgbfix.1 b/man/rgbfix.1 index 705b9068..66fa0914 100644 --- a/man/rgbfix.1 +++ b/man/rgbfix.1 @@ -8,7 +8,7 @@ .Nd Game Boy header utility and checksum fixer .Sh SYNOPSIS .Nm -.Op Fl jOsVv +.Op Fl hjOsVv .Op Fl C | c .Op Fl f Ar fix_spec .Op Fl i Ar game_id @@ -91,6 +91,8 @@ Fix the global checksum .It Cm G Trash the global checksum. .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 Set the game ID string .Pq Ad 0x13F Ns \(en Ns Ad 0x142 diff --git a/man/rgbgfx.1 b/man/rgbgfx.1 index 3f9e8e4c..9cabfe7c 100644 --- a/man/rgbgfx.1 +++ b/man/rgbgfx.1 @@ -10,7 +10,7 @@ .Nd Game Boy graphics converter .Sh SYNOPSIS .Nm -.Op Fl CmOuVXYZ +.Op Fl CmhOuVXYZ .Op Fl v Op Fl v No ... .Op Fl a Ar attrmap | Fl A .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 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). +.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 Use the specified input tiles in addition to having .Nm diff --git a/man/rgblink.1 b/man/rgblink.1 index 5f836996..7a5b01eb 100644 --- a/man/rgblink.1 +++ b/man/rgblink.1 @@ -8,7 +8,7 @@ .Nd Game Boy linker .Sh SYNOPSIS .Nm -.Op Fl dMtVvwx +.Op Fl dhMtVvwx .Op Fl l Ar linker_script .Op Fl m Ar map_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. This option automatically enables .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 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. diff --git a/src/asm/main.cpp b/src/asm/main.cpp index 390766fd..4346a0ac 100644 --- a/src/asm/main.cpp +++ b/src/asm/main.cpp @@ -48,7 +48,7 @@ static std::string make_escape(std::string &str) { } // 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 static int depType; // Variants of `-M` @@ -69,6 +69,7 @@ static option const longopts[] = { {"include", required_argument, nullptr, 'I'}, {"dependfile", required_argument, nullptr, 'M'}, {"MG", no_argument, &depType, 'G'}, + {"help", no_argument, nullptr, 'h'}, {"MP", no_argument, &depType, 'P'}, {"MT", required_argument, &depType, 'T'}, {"warning", required_argument, nullptr, 'W'}, @@ -88,7 +89,7 @@ static option const longopts[] = { static void printUsage() { 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" " [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\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'"); break; + case 'h': + printUsage(); + exit(0); + case 'I': fstk_AddIncludePath(musl_optarg); break; diff --git a/src/fix/main.cpp b/src/fix/main.cpp index 3ceaf8a4..7849672a 100644 --- a/src/fix/main.cpp +++ b/src/fix/main.cpp @@ -23,7 +23,7 @@ static_assert(UNSPECIFIED > 0xFF, "UNSPECIFIED should not be in byte range!"); static constexpr off_t BANK_SIZE = 0x4000; // 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 @@ -39,6 +39,7 @@ static option const longopts[] = { {"color-only", no_argument, nullptr, 'C'}, {"color-compatible", no_argument, nullptr, 'c'}, {"fix-spec", required_argument, nullptr, 'f'}, + {"help", no_argument, nullptr, 'h'}, {"game-id", required_argument, nullptr, 'i'}, {"non-japanese", no_argument, nullptr, 'j'}, {"new-licensee", required_argument, nullptr, 'k'}, @@ -58,7 +59,7 @@ static option const longopts[] = { static void printUsage() { fputs( - "Usage: rgbfix [-jOsVv] [-C | -c] [-f ] [-i ] [-k ]\n" + "Usage: rgbfix [-hjOsVv] [-C | -c] [-f ] [-i ] [-k ]\n" " [-L ] [-l ] [-m ]\n" " [-n ] [-p ] [-r ] [-t ]\n" " ...\n" @@ -1281,6 +1282,10 @@ int main(int argc, char *argv[]) { } break; + case 'h': + printUsage(); + exit(0); + case 'i': gameID = musl_optarg; len = strlen(gameID); diff --git a/src/gfx/main.cpp b/src/gfx/main.cpp index 438ad8ef..c8fd4fe1 100644 --- a/src/gfx/main.cpp +++ b/src/gfx/main.cpp @@ -108,7 +108,7 @@ void Options::verbosePrint(uint8_t level, char const *fmt, ...) const { } // 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 @@ -127,6 +127,7 @@ static option const longopts[] = { {"color-curve", no_argument, nullptr, 'C'}, {"colors", required_argument, nullptr, 'c'}, {"depth", required_argument, nullptr, 'd'}, + {"help", no_argument, nullptr, 'h'}, {"input-tileset", required_argument, nullptr, 'i'}, {"slice", required_argument, nullptr, 'L'}, {"mirror-tiles", no_argument, nullptr, 'm'}, @@ -155,7 +156,7 @@ static option const longopts[] = { static void printUsage() { fputs( - "Usage: rgbgfx [-r stride] [-CmOuVXYZ] [-v [-v ...]] [-a | -A]\n" + "Usage: rgbgfx [-r stride] [-ChmOuVXYZ] [-v [-v ...]] [-a | -A]\n" " [-b ] [-c ] [-d ] [-i ]\n" " [-L ] [-N ] [-n ] [-o ]\n" " [-p | -P] [-q | -Q] [-s ]\n" @@ -430,6 +431,9 @@ static char *parseArgv(int argc, char *argv[]) { options.bitDepth = 2; } break; + case 'h': + printUsage(); + exit(0); case 'i': if (!options.inputTileset.empty()) warning("Overriding input tileset file %s", options.inputTileset.c_str()); diff --git a/src/link/main.cpp b/src/link/main.cpp index 8e0069a6..7e4c1d0d 100644 --- a/src/link/main.cpp +++ b/src/link/main.cpp @@ -130,7 +130,7 @@ void argErr(char flag, char const *fmt, ...) { } // 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 @@ -144,6 +144,7 @@ static char const *optstring = "dl:m:Mn:O:o:p:S:tVvWwx"; */ static option const longopts[] = { {"dmg", no_argument, nullptr, 'd'}, + {"help", no_argument, nullptr, 'h'}, {"linkerscript", required_argument, nullptr, 'l'}, {"map", required_argument, nullptr, 'm'}, {"no-sym-in-map", no_argument, nullptr, 'M'}, @@ -162,7 +163,7 @@ static option const longopts[] = { static void printUsage() { 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" " [-S spec] ...\n" "Useful options:\n" @@ -327,6 +328,9 @@ int main(int argc, char *argv[]) { isDmgMode = true; isWRAM0Mode = true; break; + case 'h': + printUsage(); + exit(0); case 'l': if (linkerScriptName) warnx("Overriding linker script %s", linkerScriptName);