Module: Homebrew::Aliases Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- aliases/alias.rb,
aliases/aliases.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Alias
Class Method Summary collapse
- .add(name, command) ⇒ void private
- .each(only, &block) ⇒ void private
- .edit(name, command = nil) ⇒ void private
- .edit_all ⇒ void private
- .init ⇒ void private
- .remove(name) ⇒ void private
- .reserved ⇒ Array<String> private
- .show(*aliases) ⇒ void private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_once, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_incompatible, pretty_install_status, pretty_installed, pretty_removed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning
Class Method Details
.add(name, command) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
29 30 31 32 33 |
# File 'aliases/aliases.rb', line 29 def self.add(name, command) new_alias = Alias.new(name, command) odie "alias 'brew #{name}' already exists!" if new_alias.script.exist? new_alias.write end |
.each(only, &block) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'aliases/aliases.rb', line 41 def self.each(only, &block) Dir["#{HOMEBREW_ALIASES}/*"].each do |path| next if path.end_with? "~" # skip Emacs-like backup files next if File.directory?(path) _shebang, , *lines = File.readlines(path) name = .to_s[/alias: brew (\S+)/, 1] || File.basename(path) next if !only.empty? && only.exclude?(name) lines.reject! { |line| line.start_with?("#") || line =~ /^\s*$/ } first_line = lines.fetch(0) command = first_line.chomp command.sub!(/ \$\*$/, "") if command.start_with? "brew " command.sub!(/^brew /, "") else command = "!#{command}" end yield name, command if block.present? end end |
.edit(name, command = nil) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
75 76 77 78 |
# File 'aliases/aliases.rb', line 75 def self.edit(name, command = nil) Alias.new(name, command).write unless command.nil? Alias.new(name, command).edit end |
.edit_all ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
81 82 83 |
# File 'aliases/aliases.rb', line 81 def self.edit_all Utils::Editor.open(*Dir[HOMEBREW_ALIASES]) end |
.init ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
24 25 26 |
# File 'aliases/aliases.rb', line 24 def self.init FileUtils.mkdir_p HOMEBREW_ALIASES end |
.remove(name) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
36 37 38 |
# File 'aliases/aliases.rb', line 36 def self.remove(name) Alias.new(name).remove end |
.reserved ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
16 17 18 19 20 21 |
# File 'aliases/aliases.rb', line 16 def self.reserved @reserved ||= (Commands.internal_commands + Commands.internal_developer_commands + Commands.internal_commands_aliases + %w[alias unalias]).freeze end |
.show(*aliases) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
66 67 68 69 70 71 72 |
# File 'aliases/aliases.rb', line 66 def self.show(*aliases) each([*aliases]) do |name, command| puts "brew alias #{name}='#{command}'" existing_alias = Alias.new(name, command) existing_alias.link unless existing_alias.symlink.exist? end end |