log: use CLI::Parser.

This commit is contained in:
Mike McQuaid 2019-01-30 21:30:18 +00:00
parent dbd8de7148
commit 9144625940
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -1,13 +1,30 @@
#: * `log` [<git-log-options>] <formula> ...:
#: Show the git log for the given formulae. Options that `git-log`(1)
#: recognizes can be passed before the formula list.
require "formula" require "formula"
require "cli_parser"
module Homebrew module Homebrew
module_function module_function
def log_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`log` [<options>] <formula>
Show the `git log` for the given <formula>.
EOS
switch "-p", "-u", "--patch",
description: "Also output patch from commit."
switch "--stat",
description: "Also output diffstat from commit."
switch "--oneline",
description: "Output only one line per commit."
switch "-1", "--max-count=1",
description: "Output only one commit."
end
end
def log def log
log_args.parse
if ARGV.named.empty? if ARGV.named.empty?
git_log HOMEBREW_REPOSITORY git_log HOMEBREW_REPOSITORY
else else