From 2121094f5130be0e47910dcd0aa410c19ba2e225 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sun, 11 Nov 2018 19:56:53 +0530 Subject: [PATCH 1/2] list: Use CLI::Parser to parse args --- Library/Homebrew/cmd/list.rb | 48 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 3e1aa57ba2..fcdec9e227 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -25,20 +25,44 @@ require "cli_parser" module Homebrew module_function - def list - Homebrew::CLI::Parser.parse do - switch "--unbrewed" - switch "--pinned" - switch "--versions" - switch "--full-name" - switch "--multiple", depends_on: "--versions" - switch :verbose + def list_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `list`, `ls` [] [`-1`] [`-l`] [`-t`] [`-r`] + + List all installed formulae. + EOS + switch "--full-name", + description: "Print formulae with fully-qualified names. If `--full-name` is not "\ + "passed, other options (i.e. `-1`, `-l`, `-t` and `-r`) are passed to `ls` "\ + "which produces the actual output." + switch "--unbrewed", + description: "List all files in the Homebrew prefix not installed by Homebrew." + switch "--versions", + description: "Show the version number for installed formulae, or only the specified "\ + "formulae if are given." + switch "--multiple", + depends_on: "--versions", + description: "Only show formulae with multiple versions installed." + switch "--pinned", + description: "Show the versions of pinned formulae, or only the specified (pinned) "\ + "formulae if are given. See also `pin`, `unpin`." # passed through to ls - switch "-1" - switch "-l" - switch "-t" - switch "-r" + switch "-1", + description: "Option passed to `ls`" + switch "-l", + description: "Option passed to `ls`" + switch "-t", + description: "Option passed to `ls`" + switch "-r", + description: "Option passed to `ls`" + switch :verbose + switch :debug end + end + + def list + list_args.parse # Use of exec means we don't explicitly exit list_unbrewed if args.unbrewed? From 1177f04094b51d92d51bcfffbb1ac83f9179515e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 24 Nov 2018 11:23:14 +0000 Subject: [PATCH 2/2] cmd/list: improve passed through option descriptions. --- Library/Homebrew/cmd/list.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index fcdec9e227..74a3d1c1ca 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -49,13 +49,15 @@ module Homebrew "formulae if are given. See also `pin`, `unpin`." # passed through to ls switch "-1", - description: "Option passed to `ls`" + description: "Force output to be one entry per line. " \ + "This is the default when output is not to a terminal." switch "-l", - description: "Option passed to `ls`" - switch "-t", - description: "Option passed to `ls`" + description: "List in long format. If the output is to a terminal, "\ + "a total sum for all the file sizes is output on a line before the long listing." switch "-r", - description: "Option passed to `ls`" + description: "Reverse the order of the sort to get the oldest entries first." + switch "-t", + description: "Sort by time modified (most recently modified first)." switch :verbose switch :debug end