From a4c8fc74f7315ee3459676ea42974dd031060469 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 12 Feb 2019 16:50:13 -0800 Subject: [PATCH 1/4] man: parse short and long options in shell commands Add a regex to handle two comma-separated options on the same line in command help strings. --- Library/Homebrew/dev-cmd/man.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index c610ef523dde6..587e44b0e9359 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -195,7 +195,9 @@ def cmd_comment_manpage_lines(cmd_path) line = line.slice(4..-1) next unless line - lines << line.gsub(/^ +(-+[a-z-]+) */, "* `\\1`:\n ") + # Format one option or a comma-separated pair of short and long options. + lines << line.gsub(/^ +(-+[a-z-]+), (-+[a-z-]+) +/, "* `\\1`, `\\2`:\n ") + .gsub(/^ +(-+[a-z-]+) +/, "* `\\1`:\n ") end lines end From 56ac7ed58b0aa3ed7e05a62b6a18f8e6f6624bfe Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Fri, 15 Mar 2019 01:15:58 -0700 Subject: [PATCH 2/4] man: omit global options from shell command usage When reading the comment header of a shell command, omit options that are in Homebrew::CLI::Parser.global_options, since they are documented separately for all commands. --- Library/Homebrew/dev-cmd/man.rb | 3 +++ docs/Manpage.md | 3 --- manpages/brew.1 | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index 587e44b0e9359..9f3fca487553b 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -195,6 +195,9 @@ def cmd_comment_manpage_lines(cmd_path) line = line.slice(4..-1) next unless line + # Omit the common global_options documented separately in the man page. + next if line =~ /--(debug|force|help|quiet|verbose) / + # Format one option or a comma-separated pair of short and long options. lines << line.gsub(/^ +(-+[a-z-]+), (-+[a-z-]+) +/, "* `\\1`, `\\2`:\n ") .gsub(/^ +(-+[a-z-]+) +/, "* `\\1`:\n ") diff --git a/docs/Manpage.md b/docs/Manpage.md index 9bb1e9789d72f..948500a123a05 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -540,9 +540,6 @@ Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) * `--merge`: `git merge` is used to include updates (rather than `git rebase`). -* `--force`: - Always do a slower, full update check (even if unnecessary). - ### `update-reset` [*`repository`*] Fetches and resets Homebrew and all tap repositories (or any specified `repository`) using `git`(1) to their latest `origin/master`. Note this will destroy all your uncommitted or committed changes. diff --git a/manpages/brew.1 b/manpages/brew.1 index f15edcf778ee0..86758337517c9 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -660,10 +660,6 @@ Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\f \fB\-\-merge\fR \fBgit merge\fR is used to include updates (rather than \fBgit rebase\fR)\. . -.TP -\fB\-\-force\fR -Always do a slower, full update check (even if unnecessary)\. -. .SS "\fBupdate\-reset\fR [\fIrepository\fR]" Fetches and resets Homebrew and all tap repositories (or any specified \fBrepository\fR) using \fBgit\fR(1) to their latest \fBorigin/master\fR\. Note this will destroy all your uncommitted or committed changes\. . From e3ec8a7d47f0c0cefb8a1fa9f65a9145410fd8e3 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 12 Feb 2019 16:25:12 -0800 Subject: [PATCH 3/4] update: add `-f` short option alias for `--force` --- Library/Homebrew/cmd/update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index dee3b8d0d351c..0b72480bd4090 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -306,6 +306,7 @@ homebrew-update() { -*) [[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1 [[ "$option" = *d* ]] && HOMEBREW_DEBUG=1 + [[ "$option" = *f* ]] && HOMEBREW_UPDATE_FORCE=1 ;; *) odie < Date: Tue, 12 Feb 2019 17:10:28 -0800 Subject: [PATCH 4/4] update: make `--help` consistent, add options Document short options and common global options. Apply the same indent as other command help strings. --- Library/Homebrew/cmd/update.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 0b72480bd4090..b2327a4c30a86 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -2,8 +2,11 @@ #: #: Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. #: -#: --merge `git merge` is used to include updates (rather than `git rebase`). -#: --force Always do a slower, full update check (even if unnecessary). +#: --merge `git merge` is used to include updates (rather than `git rebase`). +#: -f, --force Always do a slower, full update check (even if unnecessary). +#: -v, --verbose Print the directories checked and `git` operations performed. +#: -d, --debug Display a trace of all shell commands as they are executed. +#: -h, --help Show this message. # Don't need shellcheck to follow this `source`. # shellcheck disable=SC1090