From 2c4b65eda76cda359559d8d225901b58f2cc8008 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 26 Jun 2023 10:29:48 -0700 Subject: [PATCH 01/24] Fix print_usage mistakes Seems like someone confused tldr-c-client with another client because -v prints out version and you can't even search for a string instead you have to provide a [PAGE] --- src/tldr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tldr.c b/src/tldr.c index 4db1807..1fda4d6 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -204,13 +204,12 @@ print_version(char const *arg) void print_usage(char const *arg) { - char const *out = "usage: %s [-v] [OPTION]... SEARCH\n\n"; + char const *out = "usage: %s [OPTION]... [PAGE]\n\n"; /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-20s %-30s\n", "-v", "print verbose output"); - fprintf(stdout, " %-20s %-30s\n", "--version", "print version and exit"); + fprintf(stdout, " %-20s %-30s\n", "-v, --version", "print version and exit"); fprintf(stdout, " %-20s %-30s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-20s %-30s\n", "-u, --update", "update local database"); fprintf(stdout, " %-20s %-30s\n", "-c, --clear-cache", "clear local database"); From 4195d4e0ec61ae3a99306dc1d0a253d35a512435 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 26 Jun 2023 10:36:14 -0700 Subject: [PATCH 02/24] Fix the manual page as well --- man/tldr.1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index d0d0a5b..bf9f9fe 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -6,17 +6,13 @@ tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fB\-v\fR] -[\fIOPTION\fR]... \fISEARCH\fR +[\fIOPTION\fR]... [\fIPAGE\fR] .SH DESCRIPTION tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. .SH OPTIONS .TP -.BR \-v -verbose output -.TP -.BR \-\-version +.BR \-v ", " \-\-version output version information and exit .TP .BR \-h ", " \-\-help From d5fac814c9aad94715912d7fbca0c6cd98f00c9d Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 26 Jun 2023 11:04:12 -0700 Subject: [PATCH 03/24] Remove redundancy and fix man page URLs --- man/tldr.1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index bf9f9fe..3a69784 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -1,6 +1,5 @@ .\" Manpage for tldr. .\" Contact ag@arvid.io to correct errors or typos. -.mso www.tmac .TH TLDR 1 .SH NAME tldr \- A collection of simplified and community-driven man pages. @@ -33,10 +32,10 @@ render a local page for testing purposes 0 on success, any other positive value otherwise .SH SEE ALSO The source is available at: -.URL "https://github.com/tldr-pages/tldr-cpp-client" "" "" +.UR "https://github.com/tldr-pages/tldr-cpp-client" .SH REPORTING BUGS Report bugs through the Github repository: -.URL "https://github.com/tldr-pages/tldr-cpp-client" "" "." +.UR "https://github.com/tldr-pages/tldr-cpp-client" .SH COPYRIGHT The MIT License (MIT) From 5cf3ff91090da0717ecbd412426be5ca7ad8c201 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 26 Jun 2023 11:13:29 -0700 Subject: [PATCH 04/24] Add a period ad the end of the urls --- man/tldr.1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/tldr.1 b/man/tldr.1 index 3a69784..c3b1e73 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -33,9 +33,11 @@ render a local page for testing purposes .SH SEE ALSO The source is available at: .UR "https://github.com/tldr-pages/tldr-cpp-client" +.UE . .SH REPORTING BUGS Report bugs through the Github repository: .UR "https://github.com/tldr-pages/tldr-cpp-client" +.UE . .SH COPYRIGHT The MIT License (MIT) From 053757b38063fdfa114de186ee7f3e2a398c0b84 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Tue, 27 Jun 2023 08:08:50 -0700 Subject: [PATCH 05/24] Fix man page mistakes and update usage --- man/tldr.1 | 18 +++++++++++++++--- src/tldr.c | 23 ++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index c3b1e73..b484f96 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -5,12 +5,15 @@ tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fIOPTION\fR]... [\fIPAGE\fR] +[\fB\-v\fR] [\fB\-u\fR] [\fB\-c\fR] [\fIOPTION\fR]... [\fIPAGE\fR] .SH DESCRIPTION tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. .SH OPTIONS .TP +.BR \-v +verbose output (when used with \fB\-u\fR or \fB\-c\fR) +.TP .BR \-v ", " \-\-version output version information and exit .TP @@ -23,10 +26,19 @@ update local database and exit .BR \-c ", " \-\-clear-cache remove local database and exit .TP -.BR \-p ", " \-\-platform=\fIPLATFORM\fR +\fB\-p\fR, \fB\-\-platform\fR=\fIPLATFORM\fR select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / \fIwindows\fR / \fIcommon\fR .TP -.BR \-r ", " \-\-render=\fIPATH\fR +.BR \-\-linux +show command page for Linux +.TP +.BR \-\-osx +show command page for OSX +.TP +.BR \-\-sunos +show command page for SunOS +.TP +\fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR render a local page for testing purposes .SH EXIT STATUS 0 on success, any other positive value otherwise diff --git a/src/tldr.c b/src/tldr.c index 1fda4d6..ab48402 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -204,22 +204,23 @@ print_version(char const *arg) void print_usage(char const *arg) { - char const *out = "usage: %s [OPTION]... [PAGE]\n\n"; + char const *out = "usage: %s [-v] [-u] [-c] [OPTION]... [PAGE]\n\n"; /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-20s %-30s\n", "-v, --version", "print version and exit"); - fprintf(stdout, " %-20s %-30s\n", "-h, --help", "print this help and exit"); - fprintf(stdout, " %-20s %-30s\n", "-u, --update", "update local database"); - fprintf(stdout, " %-20s %-30s\n", "-c, --clear-cache", "clear local database"); - fprintf(stdout, " %-20s %-30s\n", "-l, --list", "list all entries in the local database"); - fprintf(stdout, " %-20s %-30s\n", "-p, --platform=PLATFORM", + fprintf(stdout, " %-23s %-30s\n", "-v", "verbose output (when used with -u or -c)"); + fprintf(stdout, " %-23s %-30s\n", "-v, --version", "print version and exit"); + fprintf(stdout, " %-23s %-30s\n", "-h, --help", "print this help and exit"); + fprintf(stdout, " %-23s %-30s\n", "-u, --update", "update local database"); + fprintf(stdout, " %-23s %-30s\n", "-c, --clear-cache", "clear local database"); + fprintf(stdout, " %-23s %-30s\n", "-l, --list", "list all entries in the local database"); + fprintf(stdout, " %-23s %-30s\n", "-p, --platform=PLATFORM", "select platform, supported are linux / osx / sunos / windows / common"); - fprintf(stdout, " %-20s %-30s\n", "--linux", "show command page for Linux"); - fprintf(stdout, " %-20s %-30s\n", "--osx", "show command page for OSX"); - fprintf(stdout, " %-20s %-30s\n", "--sunos", "show command page for SunOS"); - fprintf(stdout, " %-20s %-30s\n", "-r, --render=PATH", + fprintf(stdout, " %-23s %-30s\n", "--linux", "show command page for Linux"); + fprintf(stdout, " %-23s %-30s\n", "--osx", "show command page for OSX"); + fprintf(stdout, " %-23s %-30s\n", "--sunos", "show command page for SunOS"); + fprintf(stdout, " %-23s %-30s\n", "-r, --render=PATH", "render a local page for testing purposes"); /* *INDENT-ON* */ } From 1da5cb32afc915606c3c6dfdb5a3e97ac4c750ad Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Tue, 27 Jun 2023 08:23:01 -0700 Subject: [PATCH 06/24] Fix capitalization --- man/tldr.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/tldr.1 b/man/tldr.1 index b484f96..4879482 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -47,7 +47,7 @@ The source is available at: .UR "https://github.com/tldr-pages/tldr-cpp-client" .UE . .SH REPORTING BUGS -Report bugs through the Github repository: +Report bugs through the GitHub repository: .UR "https://github.com/tldr-pages/tldr-cpp-client" .UE . .SH COPYRIGHT From 17fac4a0dafb52a0610267c8537b9c062e1488b7 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Tue, 27 Jun 2023 09:36:25 -0700 Subject: [PATCH 07/24] Reorder options in a more logical manner --- man/tldr.1 | 4 ++-- src/tldr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 4879482..9309306 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -5,14 +5,14 @@ tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fB\-v\fR] [\fB\-u\fR] [\fB\-c\fR] [\fIOPTION\fR]... [\fIPAGE\fR] +[\fB\-v\fR] [\fB\-c\fR] [\fB\-u\fR] [\fIOPTION\fR]... [\fIPAGE\fR] .SH DESCRIPTION tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. .SH OPTIONS .TP .BR \-v -verbose output (when used with \fB\-u\fR or \fB\-c\fR) +verbose output (when used with \fB\-c\fR or \fB\-u\fR) .TP .BR \-v ", " \-\-version output version information and exit diff --git a/src/tldr.c b/src/tldr.c index ab48402..99ee8dc 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -204,12 +204,12 @@ print_version(char const *arg) void print_usage(char const *arg) { - char const *out = "usage: %s [-v] [-u] [-c] [OPTION]... [PAGE]\n\n"; + char const *out = "usage: %s [-v] [-c] [-u] [OPTION]... [PAGE]\n\n"; /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-23s %-30s\n", "-v", "verbose output (when used with -u or -c)"); + fprintf(stdout, " %-23s %-30s\n", "-v", "verbose output (when used with -c or -u)"); fprintf(stdout, " %-23s %-30s\n", "-v, --version", "print version and exit"); fprintf(stdout, " %-23s %-30s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-23s %-30s\n", "-u, --update", "update local database"); From 774d9eab281c2dae59d94c73865b282cea7405ac Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Tue, 27 Jun 2023 17:36:15 -0700 Subject: [PATCH 08/24] Remove unused variable in deps.sh --- deps.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/deps.sh b/deps.sh index f030d8e..9e215c0 100755 --- a/deps.sh +++ b/deps.sh @@ -1,7 +1,6 @@ #!/bin/sh UNAME=$(uname -s) -ARCH=$(uname -m) if [ "$UNAME" = "Darwin" ]; then HAS_BREW=$(command -v brew > /dev/null 2>&1 && echo 1 || echo 0) From 08ffe3e4551b42b8e2fa901208fa850f821ef284 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Sat, 22 Jul 2023 19:45:56 -0700 Subject: [PATCH 09/24] remove non-existing options and add other options to man page --- man/tldr.1 | 16 ++++++++++------ src/tldr.c | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 9309306..e7da59f 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -11,7 +11,7 @@ tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. .SH OPTIONS .TP -.BR \-v +.BR \-v ", " \-\-verbose verbose output (when used with \fB\-c\fR or \fB\-u\fR) .TP .BR \-v ", " \-\-version @@ -29,17 +29,21 @@ remove local database and exit \fB\-p\fR, \fB\-\-platform\fR=\fIPLATFORM\fR select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / \fIwindows\fR / \fIcommon\fR .TP -.BR \-\-linux +\fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR +render a local page for testing purposes +.TP +.B \-\-list +list all entries in the local database +.TP +.B \-\-linux show command page for Linux .TP -.BR \-\-osx +.B \-\-osx show command page for OSX .TP -.BR \-\-sunos +.B \-\-sunos show command page for SunOS .TP -\fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR -render a local page for testing purposes .SH EXIT STATUS 0 on success, any other positive value otherwise .SH SEE ALSO diff --git a/src/tldr.c b/src/tldr.c index 99ee8dc..bdf2ce1 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -209,19 +209,19 @@ print_usage(char const *arg) /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-23s %-30s\n", "-v", "verbose output (when used with -c or -u)"); + fprintf(stdout, " %-23s %-30s\n", "-v, --verbose", "verbose output (when used with -c or -u)"); fprintf(stdout, " %-23s %-30s\n", "-v, --version", "print version and exit"); fprintf(stdout, " %-23s %-30s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-23s %-30s\n", "-u, --update", "update local database"); fprintf(stdout, " %-23s %-30s\n", "-c, --clear-cache", "clear local database"); - fprintf(stdout, " %-23s %-30s\n", "-l, --list", "list all entries in the local database"); fprintf(stdout, " %-23s %-30s\n", "-p, --platform=PLATFORM", "select platform, supported are linux / osx / sunos / windows / common"); + fprintf(stdout, " %-23s %-30s\n", "-r, --render=PATH", + "render a local page for testing purposes"); + fprintf(stdout, " %-23s %-30s\n", "--list", "list all entries in the local database"); fprintf(stdout, " %-23s %-30s\n", "--linux", "show command page for Linux"); fprintf(stdout, " %-23s %-30s\n", "--osx", "show command page for OSX"); fprintf(stdout, " %-23s %-30s\n", "--sunos", "show command page for SunOS"); - fprintf(stdout, " %-23s %-30s\n", "-r, --render=PATH", - "render a local page for testing purposes"); /* *INDENT-ON* */ } From 2754c7b2a9f6b511f1f77b5abe43d313fd584518 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 04:34:46 -0700 Subject: [PATCH 10/24] Remove obsolete padding code It appears that using %-30s for padding is unnecessary in this context, as %s alone seems to work perfectly without any issues. --- src/tldr.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tldr.c b/src/tldr.c index bdf2ce1..90af4a6 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -209,19 +209,19 @@ print_usage(char const *arg) /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-23s %-30s\n", "-v, --verbose", "verbose output (when used with -c or -u)"); - fprintf(stdout, " %-23s %-30s\n", "-v, --version", "print version and exit"); - fprintf(stdout, " %-23s %-30s\n", "-h, --help", "print this help and exit"); - fprintf(stdout, " %-23s %-30s\n", "-u, --update", "update local database"); - fprintf(stdout, " %-23s %-30s\n", "-c, --clear-cache", "clear local database"); - fprintf(stdout, " %-23s %-30s\n", "-p, --platform=PLATFORM", + fprintf(stdout, " %-23s %s\n", "-v, --verbose", "verbose output (when used with -c or -u)"); + fprintf(stdout, " %-23s %s\n", "-v, --version", "print version and exit"); + fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit"); + fprintf(stdout, " %-23s %s\n", "-u, --update", "update local database"); + fprintf(stdout, " %-23s %s\n", "-c, --clear-cache", "clear local database"); + fprintf(stdout, " %-23s %s\n", "-p, --platform=PLATFORM", "select platform, supported are linux / osx / sunos / windows / common"); - fprintf(stdout, " %-23s %-30s\n", "-r, --render=PATH", + fprintf(stdout, " %-23s %s\n", "-r, --render=PATH", "render a local page for testing purposes"); - fprintf(stdout, " %-23s %-30s\n", "--list", "list all entries in the local database"); - fprintf(stdout, " %-23s %-30s\n", "--linux", "show command page for Linux"); - fprintf(stdout, " %-23s %-30s\n", "--osx", "show command page for OSX"); - fprintf(stdout, " %-23s %-30s\n", "--sunos", "show command page for SunOS"); + fprintf(stdout, " %-23s %s\n", "--list", "list all entries in the local database"); + fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux"); + fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); + fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS"); /* *INDENT-ON* */ } From 0900ecba0e9ba741fc8d9b364d1f077c96cfdc5c Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 04:43:22 -0700 Subject: [PATCH 11/24] Replace "[PAGE]" with "PAGE" to comply with usual conventions --- man/tldr.1 | 2 +- src/tldr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index e7da59f..8ee0e0a 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -5,7 +5,7 @@ tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fB\-v\fR] [\fB\-c\fR] [\fB\-u\fR] [\fIOPTION\fR]... [\fIPAGE\fR] +[\fB\-v\fR] [\fB\-c\fR] [\fB\-u\fR] [\fIOPTION\fR]... \fIPAGE\fR .SH DESCRIPTION tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. diff --git a/src/tldr.c b/src/tldr.c index 90af4a6..eba8498 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -204,7 +204,7 @@ print_version(char const *arg) void print_usage(char const *arg) { - char const *out = "usage: %s [-v] [-c] [-u] [OPTION]... [PAGE]\n\n"; + char const *out = "usage: %s [-v] [-c] [-u] [OPTION]... PAGE\n\n"; /* *INDENT-OFF* */ fprintf(stdout, out, arg); From 32c7172f2553b5bc1c26fc27877881150f0f6ebd Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 05:20:24 -0700 Subject: [PATCH 12/24] Prevent -v from printing version if no additional arguments are provided print usage instead. --- man/tldr.1 | 5 ++--- src/tldr.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 8ee0e0a..bb8ffd4 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -14,9 +14,6 @@ used commandline tools. .BR \-v ", " \-\-verbose verbose output (when used with \fB\-c\fR or \fB\-u\fR) .TP -.BR \-v ", " \-\-version -output version information and exit -.TP .BR \-h ", " \-\-help display help and exit .TP @@ -44,6 +41,8 @@ show command page for OSX .B \-\-sunos show command page for SunOS .TP +.B \-\-version +output version information and exit .SH EXIT STATUS 0 on success, any other positive value otherwise .SH SEE ALSO diff --git a/src/tldr.c b/src/tldr.c index eba8498..8acc399 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -138,7 +138,7 @@ main(int argc, char **argv) return EXIT_SUCCESS; } if (verbose_flag && optind >= argc) { - print_version(argv[0]); + print_usage(argv[0]); return EXIT_SUCCESS; } if (list_flag) { @@ -210,7 +210,6 @@ print_usage(char const *arg) fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); fprintf(stdout, " %-23s %s\n", "-v, --verbose", "verbose output (when used with -c or -u)"); - fprintf(stdout, " %-23s %s\n", "-v, --version", "print version and exit"); fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-23s %s\n", "-u, --update", "update local database"); fprintf(stdout, " %-23s %s\n", "-c, --clear-cache", "clear local database"); @@ -222,6 +221,7 @@ print_usage(char const *arg) fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux"); fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS"); + fprintf(stdout, " %-23s %s\n", "--version", "print version and exit"); /* *INDENT-ON* */ } From 9383391d7456a74445accd58ac85c55814452e19 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 05:29:22 -0700 Subject: [PATCH 13/24] Use literal URLs in the man page to increase compatiability between mandoc and man-db --- man/tldr.1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index bb8ffd4..bdb62bf 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -47,12 +47,10 @@ output version information and exit 0 on success, any other positive value otherwise .SH SEE ALSO The source is available at: -.UR "https://github.com/tldr-pages/tldr-cpp-client" -.UE . +. .SH REPORTING BUGS Report bugs through the GitHub repository: -.UR "https://github.com/tldr-pages/tldr-cpp-client" -.UE . +. .SH COPYRIGHT The MIT License (MIT) From 7747857add51485fdd4b9afe5c0648ae92f0189e Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 05:48:53 -0700 Subject: [PATCH 14/24] Comply with padding of 80 colums --- man/tldr.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/tldr.1 b/man/tldr.1 index bdb62bf..500fa7e 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -24,7 +24,8 @@ update local database and exit remove local database and exit .TP \fB\-p\fR, \fB\-\-platform\fR=\fIPLATFORM\fR -select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / \fIwindows\fR / \fIcommon\fR +select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / +\fIwindows\fR / \fIcommon\fR .TP \fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR render a local page for testing purposes From 69858948a9434eff2e2f79f16bd764d9a70cfbcc Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 06:08:32 -0700 Subject: [PATCH 15/24] Client specification compliant does the opposite of commit 32c7172 --- man/tldr.1 | 11 ++++++----- src/tldr.c | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 500fa7e..46c8e89 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -11,8 +11,9 @@ tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. .SH OPTIONS .TP -.BR \-v ", " \-\-verbose -verbose output (when used with \fB\-c\fR or \fB\-u\fR) +.TP +.BR \-v ", " \-\-version +output version information and exit .TP .BR \-h ", " \-\-help display help and exit @@ -30,6 +31,9 @@ select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / \fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR render a local page for testing purposes .TP +.B \-\-verbose +print verbose output +.TP .B \-\-list list all entries in the local database .TP @@ -41,9 +45,6 @@ show command page for OSX .TP .B \-\-sunos show command page for SunOS -.TP -.B \-\-version -output version information and exit .SH EXIT STATUS 0 on success, any other positive value otherwise .SH SEE ALSO diff --git a/src/tldr.c b/src/tldr.c index 8acc399..b67a558 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -75,7 +75,7 @@ main(int argc, char **argv) break; case 'v': - verbose_flag = 1; + version_flag = 1; break; case '?': @@ -139,7 +139,7 @@ main(int argc, char **argv) } if (verbose_flag && optind >= argc) { print_usage(argv[0]); - return EXIT_SUCCESS; + return EXIT_FAILURE; } if (list_flag) { if (!has_localdb()) @@ -209,7 +209,7 @@ print_usage(char const *arg) /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-23s %s\n", "-v, --verbose", "verbose output (when used with -c or -u)"); + fprintf(stdout, " %-23s %s\n", "-v, --version", "print version and exit"); fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-23s %s\n", "-u, --update", "update local database"); fprintf(stdout, " %-23s %s\n", "-c, --clear-cache", "clear local database"); @@ -217,11 +217,11 @@ print_usage(char const *arg) "select platform, supported are linux / osx / sunos / windows / common"); fprintf(stdout, " %-23s %s\n", "-r, --render=PATH", "render a local page for testing purposes"); + fprintf(stdout, " %-23s %s\n", "--verbose", "verbose output"); fprintf(stdout, " %-23s %s\n", "--list", "list all entries in the local database"); fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux"); fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS"); - fprintf(stdout, " %-23s %s\n", "--version", "print version and exit"); /* *INDENT-ON* */ } From 56749bea9b671d27f8549a0e9e760b5332350b9a Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 06:37:49 -0700 Subject: [PATCH 16/24] Fix exit codes and more descriptive usage info for --verbose --- man/tldr.1 | 2 +- src/tldr.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 46c8e89..f8fea33 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -32,7 +32,7 @@ select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / render a local page for testing purposes .TP .B \-\-verbose -print verbose output +print verbose output (when used with \fB\-c\fR or \fB\-u\fR) .TP .B \-\-list list all entries in the local database diff --git a/src/tldr.c b/src/tldr.c index b67a558..b06cde1 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -81,6 +81,7 @@ main(int argc, char **argv) case '?': /* do not set help flag, only show getopt error */ /* help_flag = 1; */ + return EXIT_FAILURE; break; case 'p': { @@ -119,10 +120,14 @@ main(int argc, char **argv) /* show help, if platform was supplied, but no further argument */ missing_arg = (platform_flag && !list_flag && (optind == argc)); - if (help_flag || missing_arg) { + if (help_flag) { print_usage(argv[0]); return EXIT_SUCCESS; } + if (missing_arg) { + print_usage(argv[0]); + return EXIT_FAILURE; + } if (version_flag) { print_version(argv[0]); return EXIT_SUCCESS; @@ -217,7 +222,7 @@ print_usage(char const *arg) "select platform, supported are linux / osx / sunos / windows / common"); fprintf(stdout, " %-23s %s\n", "-r, --render=PATH", "render a local page for testing purposes"); - fprintf(stdout, " %-23s %s\n", "--verbose", "verbose output"); + fprintf(stdout, " %-23s %s\n", "--verbose", "verbose output (when used with -c or -u)"); fprintf(stdout, " %-23s %s\n", "--list", "list all entries in the local database"); fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux"); fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); From 9a5515d2766b7a65a16e50103896020caf219912 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Mon, 24 Jul 2023 06:54:49 -0700 Subject: [PATCH 17/24] More valid --verbose description --- man/tldr.1 | 2 +- src/tldr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index f8fea33..5f3fe44 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -32,7 +32,7 @@ select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / render a local page for testing purposes .TP .B \-\-verbose -print verbose output (when used with \fB\-c\fR or \fB\-u\fR) +print verbose output (when clearing or updating database) .TP .B \-\-list list all entries in the local database diff --git a/src/tldr.c b/src/tldr.c index b06cde1..7ff9257 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -222,7 +222,7 @@ print_usage(char const *arg) "select platform, supported are linux / osx / sunos / windows / common"); fprintf(stdout, " %-23s %s\n", "-r, --render=PATH", "render a local page for testing purposes"); - fprintf(stdout, " %-23s %s\n", "--verbose", "verbose output (when used with -c or -u)"); + fprintf(stdout, " %-23s %s\n", "--verbose", "verbose output (when clearing or updating database)"); fprintf(stdout, " %-23s %s\n", "--list", "list all entries in the local database"); fprintf(stdout, " %-23s %s\n", "--linux", "show command page for Linux"); fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); From 7f2d816e6d0315dfcf65221f90de1c7e08ac50a1 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Thu, 27 Jul 2023 05:35:32 -0700 Subject: [PATCH 18/24] Revert to old usage, but use the long option instead --- src/tldr.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/tldr.c b/src/tldr.c index 7ff9257..4818f8f 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -14,11 +14,6 @@ #include #define VERSION_TAG "v1.6.0" -#ifndef VERSION - #define VERSION_PRETTY "" -#else - #define VERSION_PRETTY VERSION -#endif /* Help and usage */ void print_version (char const *arg); @@ -196,20 +191,13 @@ main(int argc, char **argv) void print_version(char const *arg) { - /* *INDENT-OFF* */ - if (strcmp("", VERSION_PRETTY) == 0) - fprintf(stdout, "%s %s\n", arg, VERSION_TAG); - else - fprintf(stdout, "%s %s (%s)\n", arg, VERSION_TAG, VERSION_PRETTY);; - fprintf(stdout, "Copyright (C) 2016 Arvid Gerstmann\n"); - fprintf(stdout, "Source available at https://github.com/tldr-pages/tldr-c-client\n"); - /* *INDENT-ON* */ + fprintf(stdout, "%s %s\n", arg, VERSION_TAG); } void print_usage(char const *arg) { - char const *out = "usage: %s [-v] [-c] [-u] [OPTION]... PAGE\n\n"; + char const *out = "usage: %s [--verbose] [OPTION]... PAGE\n\n"; /* *INDENT-OFF* */ fprintf(stdout, out, arg); From 5402f04d06c2b7a684fa85e4b30811bfd2110428 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Thu, 27 Jul 2023 05:35:32 -0700 Subject: [PATCH 19/24] Revert to old usage, but use the long option instead man --- man/tldr.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/tldr.1 b/man/tldr.1 index 5f3fe44..401460e 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -5,7 +5,7 @@ tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fB\-v\fR] [\fB\-c\fR] [\fB\-u\fR] [\fIOPTION\fR]... \fIPAGE\fR +[\fI\-\-verbose\fR] [\fIOPTION\fR]... \fIPAGE\fR .SH DESCRIPTION tldr is a collection of simplified and community-driven man pages, for commonly used commandline tools. From d3dab8fbdc515c0c999ec23d2f16f2e917973bb5 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Thu, 27 Jul 2023 05:40:00 -0700 Subject: [PATCH 20/24] Revert accidental changes --- src/tldr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tldr.c b/src/tldr.c index 4818f8f..25e84c8 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -14,6 +14,11 @@ #include #define VERSION_TAG "v1.6.0" +#ifndef VERSION + #define VERSION_PRETTY "" +#else + #define VERSION_PRETTY VERSION +#endif /* Help and usage */ void print_version (char const *arg); @@ -191,7 +196,14 @@ main(int argc, char **argv) void print_version(char const *arg) { - fprintf(stdout, "%s %s\n", arg, VERSION_TAG); + /* *INDENT-OFF* */ + if (strcmp("", VERSION_PRETTY) == 0) + fprintf(stdout, "%s %s\n", arg, VERSION_TAG); + else + fprintf(stdout, "%s %s (%s)\n", arg, VERSION_TAG, VERSION_PRETTY);; + fprintf(stdout, "Copyright (C) 2016 Arvid Gerstmann\n"); + fprintf(stdout, "Source available at https://github.com/tldr-pages/tldr-c-client\n"); + /* *INDENT-ON* */ } void From d36ea25d788cb468043759fbeb5e49f6951fd44c Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Tue, 31 Oct 2023 10:02:41 +0530 Subject: [PATCH 21/24] tldr.1: update manpage --- man/tldr.1 | 55 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/man/tldr.1 b/man/tldr.1 index 401460e..721d884 100644 --- a/man/tldr.1 +++ b/man/tldr.1 @@ -1,60 +1,57 @@ .\" Manpage for tldr. .\" Contact ag@arvid.io to correct errors or typos. +.mso www.tmac .TH TLDR 1 .SH NAME tldr \- A collection of simplified and community-driven man pages. .SH SYNOPSIS .B tldr -[\fI\-\-verbose\fR] [\fIOPTION\fR]... \fIPAGE\fR +[\fB\-C\fR] [\fB\-v\fR] [\fB\-\-clear-cache\fR] [\fB\-\-update\fR] [\fB\-\-list\fR] [\fB\-p\fR \fIPLATFORM\fR]... [\fB\-r\fR \fIPATH\fR] \fIPAGE\fR .SH DESCRIPTION -tldr is a collection of simplified and community-driven man pages, for commonly -used commandline tools. +tldr is a collection of simplified and community-driven man pages for commonly used command-line tools. .SH OPTIONS .TP +.BR \-C ", " \-\-color +Force color display. .TP .BR \-v ", " \-\-version -output version information and exit -.TP -.BR \-h ", " \-\-help -display help and exit +Output version information and exit. .TP .BR \-u ", " \-\-update -update local database and exit +Update the local database and exit. .TP -.BR \-c ", " \-\-clear-cache -remove local database and exit +.BR \-p ", " \-\-platform=\fIPLATFORM\fR +Select platform, supported platforms are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / \fIwindows\fR / \fIcommon\fR. .TP -\fB\-p\fR, \fB\-\-platform\fR=\fIPLATFORM\fR -select platform, supported are \fIlinux\fR / \fIosx\fR / \fIsunos\fR / -\fIwindows\fR / \fIcommon\fR +.BR \-r ", " \-\-render=\fIPATH\fR +Render a local page for testing purposes. .TP -\fB\-r\fR, \fB\-\-render\fR=\fIPATH\fR -render a local page for testing purposes +.BR \-\-clear-cache +Remove the local database and exit. .TP -.B \-\-verbose -print verbose output (when clearing or updating database) +.BR \-\-linux +Show command page for Linux. .TP -.B \-\-list -list all entries in the local database +.BR \-\-list +List all entries in the local database. .TP -.B \-\-linux -show command page for Linux +.BR \-\-osx +Show command page for OSX. .TP -.B \-\-osx -show command page for OSX +.BR \-\-sunos +Show command page for SunOS. .TP -.B \-\-sunos -show command page for SunOS +.BR \-\-verbose +Print verbose output (when used with \fB\-\-clear-cache\fR or \fB\-\-update\fR). .SH EXIT STATUS -0 on success, any other positive value otherwise +0 on success, any other positive value otherwise. .SH SEE ALSO The source is available at: -. +. .SH REPORTING BUGS Report bugs through the GitHub repository: -. +. .SH COPYRIGHT The MIT License (MIT) Copyright (c) 2016 Arvid Gerstmann. - From fbeca5dab16abd32c374991a02bbf476a77ae7de Mon Sep 17 00:00:00 2001 From: "K.B.Dharun Krishna" Date: Tue, 31 Oct 2023 10:03:19 +0530 Subject: [PATCH 22/24] tldr.c: fix EOL --- src/tldr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tldr.c b/src/tldr.c index 75d0d1e..f61e9bc 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -236,4 +236,4 @@ void print_usage(char const *arg){ fprintf(stdout, " %-23s %s\n", "--osx", "show command page for OSX"); fprintf(stdout, " %-23s %s\n", "--sunos", "show command page for SunOS"); /* *INDENT-ON* */ -} \ No newline at end of file +} From ae82b4fdccde6d0690c188096fe2828101c157a3 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Fri, 17 Nov 2023 17:14:33 -0800 Subject: [PATCH 23/24] Properly align print_usage --- src/tldr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tldr.c b/src/tldr.c index f61e9bc..fee8e9a 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -221,7 +221,7 @@ void print_usage(char const *arg){ /* *INDENT-OFF* */ fprintf(stdout, out, arg); fprintf(stdout, "available commands:\n"); - fprintf(stdout, " %-20s %-30s\n", "-C, --color", "force color display"); + fprintf(stdout, " %-23s %s\n", "-C, --color", "force color display"); fprintf(stdout, " %-23s %s\n", "-h, --help", "print this help and exit"); fprintf(stdout, " %-23s %s\n", "-p, --platform=PLATFORM", "select platform, supported are linux / osx / sunos / windows / common"); From 9bf6e744ccc68d0a6be3149c8e904ff48fad5f82 Mon Sep 17 00:00:00 2001 From: 4G3NT Date: Sun, 19 Nov 2023 18:02:30 -0800 Subject: [PATCH 24/24] Fix whitespace and argument phrasing --- src/parser.c | 4 ++-- src/tldr.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser.c b/src/parser.c index 9443ab2..fa12cac 100644 --- a/src/parser.c +++ b/src/parser.c @@ -80,13 +80,13 @@ parse_tldrpage(char const *input, int color_enabled) case '-': start = i; - if (color_enabled) + if (color_enabled) fprintf(stdout, "%s", ANSI_COLOR_COMMENT_FG); continue; case '`': start = i; - if (color_enabled) + if (color_enabled) fprintf(stdout, "%s", ANSI_COLOR_CODE_FG); fprintf(stdout, " "); continue; diff --git a/src/tldr.c b/src/tldr.c index fee8e9a..fcf66c6 100644 --- a/src/tldr.c +++ b/src/tldr.c @@ -70,7 +70,7 @@ int main(int argc, char **argv) { while (1) { option_index = 0; - c = getopt_long_only(argc, argv, "v", long_options, &option_index); + c = getopt_long_only(argc, argv, "vp:r:C", long_options, &option_index); /* reached the end, bail out */ if (c == -1) {