Class: Homebrew::DevCmd::Edit Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/edit.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/edit.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::Edit::Args

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.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/edit.rbi', line 10

def args; end

#runvoid

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'dev-cmd/edit.rb', line 29

def run
  ENV["COLORTERM"] = ENV.fetch("HOMEBREW_COLORTERM", nil)
  # Recover $TMPDIR for emacsclient
  ENV["TMPDIR"] = ENV.fetch("HOMEBREW_TMPDIR", nil)

  unless (HOMEBREW_REPOSITORY/".git").directory?
    odie <<~EOS
      Changes will be lost!
      The first time you `brew update`, all local changes will be lost; you should
      thus `brew update` before you `brew edit`!
    EOS
  end

  paths = if args.named.empty?
    # Sublime requires opting into the project editing path,
    # as opposed to VS Code which will infer from the .vscode path
    if which_editor(silent: true) == "subl"
      ["--project", HOMEBREW_REPOSITORY/".sublime/homebrew.sublime-project"]
    else
      # If no formulae are listed, open the project root in an editor.
      [HOMEBREW_REPOSITORY]
    end
  else
    expanded_paths = args.named.to_paths
    expanded_paths.each do |path|
      raise_with_message!(path, args.cask?) unless path.exist?
    end
    expanded_paths
  end

  if args.print_path?
    paths.each { puts _1 }
    return
  end

  exec_editor(*paths)

  if paths.any? do |path|
       next if path == "--project"

       !Homebrew::EnvConfig.no_install_from_api? &&
       !Homebrew::EnvConfig.no_env_hints? &&
       (core_formula_path?(path) || core_cask_path?(path) || core_formula_tap?(path) || core_cask_tap?(path))
     end
    opoo <<~EOS
      `brew install` ignores locally edited casks and formulae if
      HOMEBREW_NO_INSTALL_FROM_API is not set.
    EOS
  end
end