2020-10-10 14:16:11 +02:00
|
|
|
# typed: false
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2019-01-20 20:42:15 +05:30
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2020-10-20 12:03:48 +02:00
|
|
|
extend T::Sig
|
|
|
|
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(CLI::Parser) }
|
2019-01-20 20:42:15 +05:30
|
|
|
def commands_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
2021-01-15 15:04:02 -05:00
|
|
|
description <<~EOS
|
2019-08-19 22:44:50 -04:00
|
|
|
Show lists of built-in and external commands.
|
2019-01-20 20:42:15 +05:30
|
|
|
EOS
|
2020-07-30 18:40:10 +02:00
|
|
|
switch "-q", "--quiet",
|
2019-08-19 22:44:50 -04:00
|
|
|
description: "List only the names of commands without category headers."
|
2019-01-20 20:42:15 +05:30
|
|
|
switch "--include-aliases",
|
2019-04-30 08:44:35 +01:00
|
|
|
depends_on: "--quiet",
|
2019-08-20 00:04:14 -04:00
|
|
|
description: "Include aliases of internal commands."
|
2020-07-30 18:40:10 +02:00
|
|
|
|
2021-01-10 14:26:40 -05:00
|
|
|
named_args :none
|
2019-01-20 20:42:15 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-14 16:58:26 -07:00
|
|
|
def commands
|
2020-07-30 18:40:10 +02:00
|
|
|
args = commands_args.parse
|
2019-01-20 20:42:15 +05:30
|
|
|
|
|
|
|
if args.quiet?
|
2020-02-02 17:05:45 +01:00
|
|
|
puts Formatter.columns(Commands.commands(aliases: args.include_aliases?))
|
2017-11-05 15:37:57 +00:00
|
|
|
return
|
2013-09-14 16:58:26 -07:00
|
|
|
end
|
2017-11-05 15:37:57 +00:00
|
|
|
|
2020-07-23 12:23:36 -04:00
|
|
|
prepend_separator = false
|
2020-07-22 22:45:47 -04:00
|
|
|
|
2020-07-26 22:03:04 -04:00
|
|
|
{
|
|
|
|
"Built-in commands" => Commands.internal_commands,
|
2020-07-23 12:23:36 -04:00
|
|
|
"Built-in developer commands" => Commands.internal_developer_commands,
|
|
|
|
"External commands" => Commands.external_commands,
|
2020-07-26 22:03:04 -04:00
|
|
|
}.each do |title, commands|
|
2020-07-26 22:12:08 -04:00
|
|
|
next if commands.blank?
|
2020-07-23 12:23:36 -04:00
|
|
|
|
|
|
|
puts if prepend_separator
|
|
|
|
ohai title, Formatter.columns(commands)
|
|
|
|
|
2020-07-26 22:03:04 -04:00
|
|
|
prepend_separator ||= true
|
2020-07-20 13:18:09 -04:00
|
|
|
end
|
2015-07-09 19:50:53 +08:00
|
|
|
end
|
2013-09-14 16:58:26 -07:00
|
|
|
end
|