Skip to content

Commit

Permalink
Arrange short help options in same sequence they are mentioned in man…
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
hzeller committed Aug 8, 2023
1 parent 74a8eb3 commit 564e9e2
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 66 deletions.
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ grid uses `--grid=2` and is pixelated `-p iterm2`).

```
usage: timg [options] <image/video> [<image/video>...]
Options:
-g<w>x<h> : Output geometry in character cells. Partial geometry
leaving out one value -g<w>x or -gx<h> is possible,
the other value it then derived from the terminal size.
Default derived from terminal size is 160x50
Options (most common first):
-p<pixelation> : Pixelation: 'h' = half blocks 'q' = quarter blocks
'k' = kitty graphics 'i' = iTerm2 graphics
's' = sixel graphics
Default: Auto-detect graphics, otherwise 'quarter'.
--compress[=level]: Only for -pk or -pi: Compress image data. More
CPU use, but less bandwidth. (default: 1)
-C, --center : Center image horizontally.
-W, --fit-width: Scale to fit width of available space, even if it
exceeds height.
--grid=<cols>[x<rows>] : Arrange images in a grid (contact sheet).
-w<seconds> : Wait time between images (default: 0.0).
-wr<seconds> : like above, but wait time between rows in grid.
-a : Switch off anti aliasing (default: on).
--grid=<cols>[x<rows>] : Arrange images in a grid ("contact sheet").
-C, --center : Center image horizontally in available cell.
--title[=<fmt_str>]: Print title above each image. Accepts the following
format parameters: %f = full filename; %b = basename
%w = image width; %h = height
%D = internal decoder used
If no parameter is given, defaults to "%f"
Env-var override with TIMG_DEFAULT_TITLE
-f<filelist> : Read newline-separated list of image files to show.
Relative filenames are relative to current directory.
(-f and -F can be provided multiple times.)
-F<filelist> : like -f, but relative filenames considered relative
to the directory containing the filelist.
-b<str> : Background color to use behind alpha channel. Format
'yellow', '#rrggbb', 'auto' or 'none' (default 'auto').
-B<str> : Checkerboard pattern color to use on alpha.
Expand All @@ -100,31 +100,32 @@ Options:
remove beforehand to get rid of an uneven border.
--rotate=<exif|off> : Rotate according to included exif orientation.
or 'off'. Default: exif.
--clear : Clear screen first. Optional argument 'every' will
clear before every image (useful with -w)
-W, --fit-width: Scale to fit width of available space, even if it
exceeds height.
-U, --upscale[=i]: Allow Upscaling. If an image is smaller than the
available frame (e.g. an icon), enlarge it to fit.
Optional parameter 'i' only enlarges in integer steps.
--clear : Clear screen first. Optional argument 'every' will
clear before every image (useful with -w)
-V : Directly use Video subsystem. Don't probe image
decoding first (useful, if you stream video from stdin)
-I : Only use Image subsystem. Don't attempt video decoding
--title[=<fmt_str>]: Print title above each image. Accepts the following
format parameters: %f = full filename; %b = basename
%w = image width; %h = height
%D = internal decoder used
If no parameter is given, defaults to "%f"
Env-var override with TIMG_DEFAULT_TITLE
-f<filelist> : Read newline-separated list of image files to show.
Relative filenames are relative to current directory.
(Can be provided multiple times.)
-F<filelist> : like -f, but relative filenames considered relative
to the directory containting the filelist.
-w<seconds> : Wait time between images (default: 0.0).
-wr<seconds> : like above, but wait time between rows in grid.
-a : Switch off anti-aliasing (default: on).
-g<w>x<h> : Output geometry in character cells. Partial geometry
leaving out one value -g<w>x or -gx<h> is possible,
the other value it then derived from the terminal size.
Default derived from terminal size is 160x50
-o<outfile> : Write to <outfile> instead of stdout.
-E : Don't hide the cursor while showing images.
--compress[=level]: Only for -pk or -pi: Compress image data. More
CPU use, but less used bandwidth. (default: 1)
--threads=<n> : Run image decoding in parallel with n threads
(Default 3, 3/4 #cores on this machine)
--color8 : Choose 8 bit color mode for -ph or -pq
--version : Print version and exit.
--version : Print detailed version including used libraries.
(v1.5.1+)
--verbose : Print some stats after images shown.
-h : Print this help and exit.
--help : Page through detailed manpage-like help and exit.
Expand Down
77 changes: 39 additions & 38 deletions src/timg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,7 @@ static int usage(const char *progname, ExitCode exit_code, int width,
kFileType);
fprintf(
stderr,
"\e[1mOptions\e[0m:\n"
"\t-g<w>x<h> : Output geometry in character cells. Partial "
"geometry\n"
"\t leaving out one value -g<w>x or -gx<h> is "
"possible,\n"
"\t the other value it then derived from the terminal "
"size.\n"
"\t Default derived from terminal size is %dx%d\n"
"\e[1mOptions\e[0m (most common first):\n"
"\t-p<pixelation> : Pixelation: 'h' = half blocks 'q' = quarter "
"blocks\n"
"\t 'k' = kitty graphics 'i' = iTerm2 "
Expand All @@ -184,15 +177,25 @@ static int usage(const char *progname, ExitCode exit_code, int width,
#endif
"\t Default: Auto-detect graphics, otherwise "
"'quarter'.\n"
"\t--compress[=level]: Only for -pk or -pi: Compress image data. More\n"
"\t CPU use, but less used bandwidth. (default: 1)\n"
"\t-C, --center : Center image horizontally.\n"
"\t-W, --fit-width: Scale to fit width of available space, even if it\n"
"\t exceeds height.\n"
"\t--grid=<cols>[x<rows>] : Arrange images in a grid (contact sheet).\n"
"\t-w<seconds> : Wait time between images (default: 0.0).\n"
"\t-wr<seconds> : like above, but wait time between rows in grid.\n"
"\t-a : Switch off anti-aliasing (default: on).\n"
"\t--grid=<cols>[x<rows>] : Arrange images in a grid (\"contact sheet\").\n"
"\t-C, --center : Center image horizontally in available cell.\n"
"\t--title[=<fmt_str>]: Print title above each image. Accepts the "
"following\n"
"\t format parameters: %%f = full filename; %%b = "
"basename\n"
"\t %%w = image width; %%h = "
"height\n"
"\t %%D = internal decoder used\n"
"\t If no parameter is given, defaults to \"%%f\"\n"
"\t Env-var override with TIMG_DEFAULT_TITLE%s%s%s\n"
"\t-f<filelist> : Read newline-separated list of image files to "
"show.\n"
"\t Relative filenames are relative to current "
"directory.\n"
"\t (-f and -F can be provided multiple times.)\n"
"\t-F<filelist> : like -f, but relative filenames considered "
"relative\n"
"\t to the directory containing the filelist.\n"
"\t-b<str> : Background color to use behind alpha channel. "
"Format\n"
"\t 'yellow', '#rrggbb', 'auto' or 'none' (default "
Expand All @@ -207,41 +210,38 @@ static int usage(const char *progname, ExitCode exit_code, int width,
"\t--rotate=<exif|off> : Rotate according to included exif "
"orientation.\n"
"\t or 'off'. Default: exif.\n"
"\t--clear : Clear screen first. Optional argument 'every' "
"will\n"
"\t clear before every image (useful with -w)\n"
"\t-W, --fit-width: Scale to fit width of available space, even if it\n"
"\t exceeds height.\n"
"\t-U, --upscale[=i]: Allow Upscaling. If an image is smaller than "
"the\n"
"\t available frame (e.g. an icon), enlarge it to "
"fit.\n"
"\t Optional parameter 'i' only enlarges in integer "
"steps.\n"
"\t--clear : Clear screen first. Optional argument 'every' "
"will\n"
"\t clear before every image (useful with -w)\n"
#ifdef WITH_TIMG_VIDEO
"\t-V : Directly use Video subsystem. Don't probe image\n"
"\t decoding first (useful, if you stream video from "
"stdin)\n"
"\t-I : Only use Image subsystem. Don't attempt video "
"decoding\n"
#endif
"\t--title[=<fmt_str>]: Print title above each image. Accepts the "
"following\n"
"\t format parameters: %%f = full filename; %%b = "
"basename\n"
"\t %%w = image width; %%h = "
"height\n"
"\t %%D = internal decoder used\n"
"\t If no parameter is given, defaults to \"%%f\"\n"
"\t Env-var override with TIMG_DEFAULT_TITLE%s%s%s\n"
"\t-f<filelist> : Read newline-separated list of image files to "
"show.\n"
"\t Relative filenames are relative to current "
"directory.\n"
"\t (-f and -F can be provided multiple times.)\n"
"\t-F<filelist> : like -f, but relative filenames considered "
"relative\n"
"\t to the directory containing the filelist.\n"
"\t-w<seconds> : Wait time between images (default: 0.0).\n"
"\t-wr<seconds> : like above, but wait time between rows in grid.\n"
"\t-a : Switch off anti-aliasing (default: on).\n"
"\t-g<w>x<h> : Output geometry in character cells. Partial "
"geometry\n"
"\t leaving out one value -g<w>x or -gx<h> is "
"possible,\n"
"\t the other value it then derived from the terminal "
"size.\n"
"\t Default derived from terminal size is %dx%d\n"
"\t-o<outfile> : Write to <outfile> instead of stdout.\n"
"\t-E : Don't hide the cursor while showing images.\n"
"\t--compress[=level]: Only for -pk or -pi: Compress image data. More\n"
"\t CPU use, but less used bandwidth. (default: 1)\n"
"\t--threads=<n> : Run image decoding in parallel with n threads\n"
"\t (Default %d, 3/4 #cores on this machine)\n"
"\t--color8 : Choose 8 bit color mode for -ph or -pq\n"
Expand Down Expand Up @@ -269,8 +269,9 @@ static int usage(const char *progname, ExitCode exit_code, int width,
"\t--frame-offset=<num>: Start animation/video at this frame\n"
"\t-t<seconds> : Stop after this time, independent of --loops or "
"--frames\n",
width, height, default_title ? "='" : "",
default_title ? "='" : "",
default_title ? default_title : "", default_title ? "'" : "",
width, height,
kDefaultThreadCount, TIMG_VERSION);
return (int)exit_code;
}
Expand Down

0 comments on commit 564e9e2

Please sign in to comment.