From e7e0dcfdd1724b9d12932670d1cd1ff500fe6380 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sat, 27 Oct 2018 22:59:08 +0530 Subject: [PATCH] diy: Use CLI::Parser to parse args --- Library/Homebrew/cmd/diy.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb index a2cdf6c1fa..c4b892a6c7 100644 --- a/Library/Homebrew/cmd/diy.rb +++ b/Library/Homebrew/cmd/diy.rb @@ -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` [] + + 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 of the package being installed." + flag "--version=", + description: "Explicitly set the provided 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