diy: Use CLI::Parser to parse args
This commit is contained in:
parent
322075130e
commit
e7e0dcfdd1
@ -9,15 +9,36 @@
|
|||||||
#: installing.
|
#: installing.
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def diy_args
|
||||||
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`diy` [<options>]
|
||||||
|
|
||||||
|
Automatically determine the installation prefix for non-Homebrew software.
|
||||||
|
Using the output from this command, you can install your own software into
|
||||||
|
the Cellar and then link it into Homebrew's prefix with `brew link`.
|
||||||
|
EOS
|
||||||
|
flag "--name=",
|
||||||
|
description: "Explicitly set the provided <name> of the package being installed."
|
||||||
|
flag "--version=",
|
||||||
|
description: "Explicitly set the provided <version> of the package being installed."
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def diy
|
def diy
|
||||||
|
diy_args.parse
|
||||||
|
|
||||||
path = Pathname.getwd
|
path = Pathname.getwd
|
||||||
|
|
||||||
version = ARGV.value("version") || detect_version(path)
|
version = args.version || detect_version(path)
|
||||||
name = ARGV.value("name") || detect_name(path, version)
|
name = args.name || detect_name(path, version)
|
||||||
|
|
||||||
prefix = HOMEBREW_CELLAR/name/version
|
prefix = HOMEBREW_CELLAR/name/version
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user