Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diy: Use CLI::Parser to parse args #5200

Merged
merged 1 commit into from
Nov 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions Library/Homebrew/cmd/diy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,36 @@
#: installing.

require "formula"
require "cli_parser"

module Homebrew
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
diy_args.parse

path = Pathname.getwd

version = ARGV.value("version") || detect_version(path)
name = ARGV.value("name") || detect_name(path, version)
version = args.version || detect_version(path)
name = args.name || detect_name(path, version)

prefix = HOMEBREW_CELLAR/name/version

Expand Down