Port Homebrew::DevCmd::InstallBundlerGems

This commit is contained in:
Douglas Eichelberger 2024-03-21 10:25:16 -07:00
parent 485574ac98
commit 0e489a8c04
3 changed files with 37 additions and 30 deletions

View File

@ -11,6 +11,7 @@ module Homebrew
module DevCmd
class GenerateManCompletions < AbstractCommand
include SystemCommand::Mixin
cmd_args do
description <<~EOS
Generate Homebrew's manpages and shell completions.

View File

@ -1,41 +1,39 @@
# typed: true
# typed: strict
# frozen_string_literal: true
require "cli/parser"
module Homebrew
module_function
module DevCmd
class InstallBundlerGems < AbstractCommand
cmd_args do
description <<~EOS
Install Homebrew's Bundler gems.
EOS
comma_array "--groups",
description: "Installs the specified comma-separated list of gem groups (default: last used). " \
"Replaces any previously installed groups."
comma_array "--add-groups",
description: "Installs the specified comma-separated list of gem groups, " \
"in addition to those already installed."
sig { returns(CLI::Parser) }
def install_bundler_gems_args
Homebrew::CLI::Parser.new do
description <<~EOS
Install Homebrew's Bundler gems.
EOS
comma_array "--groups",
description: "Installs the specified comma-separated list of gem groups (default: last used). " \
"Replaces any previously installed groups."
comma_array "--add-groups",
description: "Installs the specified comma-separated list of gem groups, " \
"in addition to those already installed."
conflicts "--groups", "--add-groups"
conflicts "--groups", "--add-groups"
named_args :none
end
named_args :none
sig { override.void }
def run
groups = args.groups || args.add_groups || []
if groups.delete("all")
groups |= Homebrew.valid_gem_groups
elsif args.groups # if we have been asked to replace
Homebrew.forget_user_gem_groups!
end
Homebrew.install_bundler_gems!(groups:)
end
end
end
def install_bundler_gems
args = install_bundler_gems_args.parse
groups = args.groups || args.add_groups || []
if groups.delete("all")
groups |= Homebrew.valid_gem_groups
elsif args.groups # if we have been asked to replace
Homebrew.forget_user_gem_groups!
end
Homebrew.install_bundler_gems!(groups:)
end
end

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "dev-cmd/install-bundler-gems"
RSpec.describe Homebrew::DevCmd::InstallBundlerGems do
it_behaves_like "parseable arguments"
end