brew 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +139 -0
- data/Gemfile.lock +3 -1
- data/README.md +3 -1
- data/brew.gemspec +1 -0
- data/lib/brew.rb +23 -1
- data/lib/brew/commands/info.rb +88 -0
- data/lib/brew/commands/install.rb +138 -0
- data/lib/brew/commands/list.rb +82 -0
- data/lib/brew/commands/search.rb +101 -0
- data/lib/brew/commands/uninstall.rb +52 -0
- data/lib/brew/commands/update.rb +56 -0
- data/lib/brew/commands/upgrade.rb +93 -0
- data/lib/brew/home_brew.rb +27 -34
- data/lib/brew/utils/string_utils.rb +11 -0
- data/lib/brew/utils/system_runner.rb +35 -0
- data/lib/brew/version.rb +1 -1
- metadata +26 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba316612244193e94d89526fd42dcee2a7df11a369fa952cb746fecb39f7f1d6
|
4
|
+
data.tar.gz: a482c96e2b956d8bb8c601394836669feb7a392ba472ce6f00278f1f641c2160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe354e971f779affbc00fe155a73bee8c2e77433ed9172e2b86b52a0c70db9d8ce2195922f978648cfcd2db3e4cec0a0208b4ed8db0e627f356beabc65bad80
|
7
|
+
data.tar.gz: be17e8b699900cf39e5d869be3b99255094d4f94a306135d8f8ef2cad4db9e456d70b83290251e7bb23c823cb23cf851076aba7e451ea93a6d735fb3b47412da
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
Style/Documentation:
|
2
|
+
Enabled: False
|
3
|
+
|
4
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
5
|
+
Enabled: True
|
6
|
+
|
7
|
+
Layout/SpaceAroundMethodCallOperator:
|
8
|
+
Enabled: True
|
9
|
+
|
10
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
11
|
+
Enabled: True
|
12
|
+
|
13
|
+
Lint/DeprecatedOpenSSLConstant:
|
14
|
+
Enabled: True
|
15
|
+
|
16
|
+
Lint/DuplicateElsifCondition:
|
17
|
+
Enabled: True
|
18
|
+
|
19
|
+
Lint/DuplicateRescueException:
|
20
|
+
Enabled: True
|
21
|
+
|
22
|
+
Lint/EmptyConditionalBody:
|
23
|
+
Enabled: True
|
24
|
+
|
25
|
+
Lint/FloatComparison:
|
26
|
+
Enabled: True
|
27
|
+
|
28
|
+
Lint/MissingSuper:
|
29
|
+
Enabled: True
|
30
|
+
|
31
|
+
Lint/MixedRegexpCaptureTypes:
|
32
|
+
Enabled: True
|
33
|
+
|
34
|
+
Lint/OutOfRangeRegexpRef:
|
35
|
+
Enabled: True
|
36
|
+
|
37
|
+
Lint/RaiseException:
|
38
|
+
Enabled: True
|
39
|
+
|
40
|
+
Lint/SelfAssignment:
|
41
|
+
Enabled: True
|
42
|
+
|
43
|
+
Lint/StructNewOverride:
|
44
|
+
Enabled: True
|
45
|
+
|
46
|
+
Lint/TopLevelReturnWithArgument:
|
47
|
+
Enabled: True
|
48
|
+
|
49
|
+
Lint/UnreachableLoop:
|
50
|
+
Enabled: True
|
51
|
+
|
52
|
+
Metrics/AbcSize:
|
53
|
+
Exclude:
|
54
|
+
- 'lib/brew/commands/*.rb'
|
55
|
+
- 'lib/brew.rb'
|
56
|
+
|
57
|
+
Metrics/CyclomaticComplexity:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/brew/commands/*.rb'
|
60
|
+
- 'lib/brew.rb'
|
61
|
+
|
62
|
+
Metrics/MethodLength:
|
63
|
+
Exclude:
|
64
|
+
- 'lib/brew/commands/*.rb'
|
65
|
+
- 'lib/brew.rb'
|
66
|
+
- 'test/**/*.rb'
|
67
|
+
|
68
|
+
Metrics/PerceivedComplexity:
|
69
|
+
Exclude:
|
70
|
+
- 'lib/brew/commands/*.rb'
|
71
|
+
- 'lib/brew.rb'
|
72
|
+
|
73
|
+
Style/AccessorGrouping:
|
74
|
+
Enabled: True
|
75
|
+
|
76
|
+
Style/ArrayCoercion:
|
77
|
+
Enabled: True
|
78
|
+
|
79
|
+
Style/BisectedAttrAccessor:
|
80
|
+
Enabled: True
|
81
|
+
|
82
|
+
Style/CaseLikeIf:
|
83
|
+
Enabled: True
|
84
|
+
|
85
|
+
Style/ExplicitBlockArgument:
|
86
|
+
Enabled: True
|
87
|
+
|
88
|
+
Style/ExponentialNotation:
|
89
|
+
Enabled: True
|
90
|
+
|
91
|
+
Style/GlobalStdStream:
|
92
|
+
Enabled: True
|
93
|
+
|
94
|
+
Style/HashAsLastArrayItem:
|
95
|
+
Enabled: True
|
96
|
+
|
97
|
+
Style/HashEachMethods:
|
98
|
+
Enabled: True
|
99
|
+
|
100
|
+
Style/HashLikeCase:
|
101
|
+
Enabled: True
|
102
|
+
|
103
|
+
Style/HashTransformKeys:
|
104
|
+
Enabled: True
|
105
|
+
|
106
|
+
Style/HashTransformValues:
|
107
|
+
Enabled: True
|
108
|
+
|
109
|
+
Style/MixinUsage:
|
110
|
+
Exclude:
|
111
|
+
- 'lib/brew.rb'
|
112
|
+
|
113
|
+
Style/OptionalBooleanParameter:
|
114
|
+
Enabled: True
|
115
|
+
|
116
|
+
Style/RedundantAssignment:
|
117
|
+
Enabled: True
|
118
|
+
|
119
|
+
Style/RedundantFetchBlock:
|
120
|
+
Enabled: True
|
121
|
+
|
122
|
+
Style/RedundantFileExtensionInRequire:
|
123
|
+
Enabled: True
|
124
|
+
|
125
|
+
Style/RedundantRegexpCharacterClass:
|
126
|
+
Enabled: True
|
127
|
+
|
128
|
+
Style/RedundantRegexpEscape:
|
129
|
+
Enabled: True
|
130
|
+
|
131
|
+
Style/SingleArgumentDig:
|
132
|
+
Enabled: True
|
133
|
+
|
134
|
+
Style/SlicingWithRange:
|
135
|
+
Enabled: True
|
136
|
+
|
137
|
+
Style/StringConcatenation:
|
138
|
+
Enabled: True
|
139
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brew (0.
|
4
|
+
brew (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.1)
|
10
10
|
bump (0.9.0)
|
11
|
+
byebug (11.1.3)
|
11
12
|
minitest (5.14.1)
|
12
13
|
parallel (1.19.2)
|
13
14
|
parser (2.7.1.4)
|
@@ -36,6 +37,7 @@ PLATFORMS
|
|
36
37
|
DEPENDENCIES
|
37
38
|
brew!
|
38
39
|
bump
|
40
|
+
byebug
|
39
41
|
minitest (~> 5.0)
|
40
42
|
rake (~> 12.0)
|
41
43
|
rubocop
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ homebrew = Brew::HomeBrew.new
|
|
25
25
|
```
|
26
26
|
(will raise an exception if `brew` is not installed)
|
27
27
|
|
28
|
-
2)
|
28
|
+
2) `brew` to your heart's content!
|
29
29
|
```ruby
|
30
30
|
homebrew.update
|
31
31
|
|
@@ -35,6 +35,8 @@ homebrew.upgrade('redis')
|
|
35
35
|
|
36
36
|
homebrew.uninstall('rbenv')
|
37
37
|
```
|
38
|
+
|
39
|
+
Available commands are: `info`, `install`, `list`, `uninstall`, `update`, `upgrade`
|
38
40
|
(will raise an exception if any of the commands fail)
|
39
41
|
|
40
42
|
|
data/brew.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bump'
|
31
|
+
spec.add_development_dependency 'byebug'
|
31
32
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
33
|
spec.add_development_dependency 'rake', '~> 12.0'
|
33
34
|
spec.add_development_dependency 'rubocop'
|
data/lib/brew.rb
CHANGED
@@ -5,5 +5,27 @@ require 'brew/home_brew'
|
|
5
5
|
|
6
6
|
module Brew
|
7
7
|
class Error < StandardError; end
|
8
|
-
|
8
|
+
class ExecutionError < Error; end
|
9
|
+
class HomeBrewNotInstalled < Error; end
|
10
|
+
|
11
|
+
def brew(command, formula = nil, brew_path: nil, **kwargs)
|
12
|
+
client = HomeBrew.new(brew_path: brew_path)
|
13
|
+
|
14
|
+
case command.to_sym
|
15
|
+
when :info then client.info(formula, **kwargs)
|
16
|
+
when :install then client.install(formula, **kwargs)
|
17
|
+
when :list then client.list(formula, **kwargs)
|
18
|
+
when :ls then client.ls(formula, **kwargs)
|
19
|
+
when :rm then client.rm(formula, **kwargs)
|
20
|
+
when :remove then client.remove(formula, **kwargs)
|
21
|
+
when :uninstall then client.uninstall(formula, **kwargs)
|
22
|
+
when :update then client.update(**kwargs)
|
23
|
+
when :up then client.up(**kwargs)
|
24
|
+
when :upgrade then client.upgrade(formula, **kwargs)
|
25
|
+
else
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
28
|
+
end
|
9
29
|
end
|
30
|
+
|
31
|
+
include Brew
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Info
|
9
|
+
attr_reader :brew_path, :formulae, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, *formulae, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@formulae = formulae.join(' ')
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
info_command = "#{brew_path} info #{options} #{formulae}".squish
|
20
|
+
system_runner.print_output(info_command)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise Brew::ExecutionError, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
BOOLEAN_OPTIONS = %i[github json installed all verbose debug].freeze
|
28
|
+
|
29
|
+
ARGUMENT_OPTIONS = %i[analytics days category].freeze
|
30
|
+
|
31
|
+
def parse_args(args)
|
32
|
+
option_list = []
|
33
|
+
|
34
|
+
BOOLEAN_OPTIONS.each do |option|
|
35
|
+
str_option = option.to_s
|
36
|
+
kebab_option = str_option.snake_to_kebab
|
37
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
38
|
+
end
|
39
|
+
|
40
|
+
ARGUMENT_OPTIONS.each do |option|
|
41
|
+
str_option = option.to_s
|
42
|
+
kebab_option = str_option.snake_to_kebab
|
43
|
+
if (value = args[option] || args[str_option] || args[kebab_option])
|
44
|
+
option_list << "--#{kebab_option} #{value}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
option_list.join(' ')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Usage: brew info [options] [formula]
|
55
|
+
|
56
|
+
# Display brief statistics for your Homebrew installation.
|
57
|
+
|
58
|
+
# If formula is provided, show summary of information about formula.
|
59
|
+
|
60
|
+
# --analytics List global Homebrew analytics data or, if
|
61
|
+
# specified, installation and build error
|
62
|
+
# data for formula (provided neither
|
63
|
+
# HOMEBREW_NO_ANALYTICS nor
|
64
|
+
# HOMEBREW_NO_GITHUB_API are set).
|
65
|
+
# --days How many days of analytics data to
|
66
|
+
# retrieve. The value for days must be
|
67
|
+
# 30, 90 or 365. The default is 30.
|
68
|
+
# --category Which type of analytics data to retrieve.
|
69
|
+
# The value for category must be install,
|
70
|
+
# install-on-request or build-error;
|
71
|
+
# cask-install or os-version may be
|
72
|
+
# specified if formula is not. The default
|
73
|
+
# is install.
|
74
|
+
# --github Open the GitHub source page for formula
|
75
|
+
# in a browser. To view formula history
|
76
|
+
# locally: brew log -p formula
|
77
|
+
# --json Print a JSON representation of formula.
|
78
|
+
# Currently the default and only accepted
|
79
|
+
# value for version is v1. See the docs
|
80
|
+
# for examples of using the JSON output:
|
81
|
+
# https://docs.brew.sh/Querying-Brew
|
82
|
+
# --installed Print JSON of formulae that are currently
|
83
|
+
# installed.
|
84
|
+
# --all Print JSON of all available formulae.
|
85
|
+
# -v, --verbose Show more verbose analytics data for
|
86
|
+
# formula.
|
87
|
+
# -d, --debug Display any debugging information.
|
88
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Install
|
9
|
+
attr_reader :brew_path, :formulae, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, *formulae, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@formulae = formulae.join(' ')
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
install_command = "#{brew_path} install #{options} #{formulae}".squish
|
20
|
+
system_runner.print_output(install_command)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise Brew::ExecutionError, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
BOOLEAN_OPTIONS = %i[
|
28
|
+
ignore_dependencies build_from_source force_bottle
|
29
|
+
include_test devel HEAD fetch_HEAD keep_tmp
|
30
|
+
build_bottle force verbose display_times git
|
31
|
+
].freeze
|
32
|
+
|
33
|
+
ARGUMENT_OPTIONS = %i[
|
34
|
+
env only_dependencies cc bottle_arch
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
def parse_args(args)
|
38
|
+
option_list = []
|
39
|
+
|
40
|
+
BOOLEAN_OPTIONS.each do |option|
|
41
|
+
str_option = option.to_s
|
42
|
+
kebab_option = str_option.snake_to_kebab
|
43
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
44
|
+
end
|
45
|
+
|
46
|
+
ARGUMENT_OPTIONS.each do |option|
|
47
|
+
str_option = option.to_s
|
48
|
+
kebab_option = str_option.snake_to_kebab
|
49
|
+
if (value = args[option] || args[str_option] || args[kebab_option])
|
50
|
+
option_list << "--#{kebab_option} #{value}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
option_list.join(' ')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Usage: brew install [options] formula
|
61
|
+
|
62
|
+
# Install formula. Additional options specific to formula may be appended to
|
63
|
+
# the command.
|
64
|
+
|
65
|
+
# Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run for
|
66
|
+
# the installed formulae or, every 30 days, for all formulae.
|
67
|
+
|
68
|
+
# -d, --debug If brewing fails, open an interactive
|
69
|
+
# debugging session with access to IRB or a
|
70
|
+
# shell inside the temporary build directory.
|
71
|
+
# --env If std is passed, use the standard build
|
72
|
+
# environment instead of superenv. If super
|
73
|
+
# is passed, use superenv even if the formula
|
74
|
+
# specifies the standard build environment.
|
75
|
+
# --ignore-dependencies An unsupported Homebrew development flag to
|
76
|
+
# skip installing any dependencies of any
|
77
|
+
# kind. If the dependencies are not already
|
78
|
+
# present, the formula will have issues. If
|
79
|
+
# you're not developing Homebrew, consider
|
80
|
+
# adjusting your PATH rather than using this
|
81
|
+
# flag.
|
82
|
+
# --only-dependencies Install the dependencies with specified
|
83
|
+
# options but do not install the formula
|
84
|
+
# itself.
|
85
|
+
# --cc Attempt to compile using the specified
|
86
|
+
# compiler, which should be the name of the
|
87
|
+
# compiler's executable, e.g. gcc-7 for GCC
|
88
|
+
# 7. In order to use LLVM's clang, specify
|
89
|
+
# llvm_clang. To use the Apple-provided
|
90
|
+
# clang, specify clang. This option will
|
91
|
+
# only accept compilers that are provided by
|
92
|
+
# Homebrew or bundled with macOS. Please do
|
93
|
+
# not file issues if you encounter errors
|
94
|
+
# while using this option.
|
95
|
+
# -s, --build-from-source Compile formula from source even if a
|
96
|
+
# bottle is provided. Dependencies will still
|
97
|
+
# be installed from bottles if they are
|
98
|
+
# available.
|
99
|
+
# --force-bottle Install from a bottle if it exists for the
|
100
|
+
# current or newest version of macOS, even if
|
101
|
+
# it would not normally be used for
|
102
|
+
# installation.
|
103
|
+
# --include-test Install testing dependencies required to
|
104
|
+
# run brew test formula.
|
105
|
+
# --devel If formula defines it, install the
|
106
|
+
# development version.
|
107
|
+
# --HEAD If formula defines it, install the HEAD
|
108
|
+
# version, aka. master, trunk, unstable.
|
109
|
+
# --fetch-HEAD Fetch the upstream repository to detect if
|
110
|
+
# the HEAD installation of the formula is
|
111
|
+
# outdated. Otherwise, the repository's HEAD
|
112
|
+
# will only be checked for updates when a new
|
113
|
+
# stable or development version has been
|
114
|
+
# released.
|
115
|
+
# --keep-tmp Retain the temporary files created during
|
116
|
+
# installation.
|
117
|
+
# --build-bottle Prepare the formula for eventual bottling
|
118
|
+
# during installation, skipping any
|
119
|
+
# post-install steps.
|
120
|
+
# --bottle-arch Optimise bottles for the specified
|
121
|
+
# architecture rather than the oldest
|
122
|
+
# architecture supported by the version of
|
123
|
+
# macOS the bottles are built on.
|
124
|
+
# -f, --force Install without checking for previously
|
125
|
+
# installed keg-only or non-migrated
|
126
|
+
# versions.
|
127
|
+
# -v, --verbose Print the verification and postinstall
|
128
|
+
# steps.
|
129
|
+
# --display-times Print install times for each formula at the
|
130
|
+
# end of the run.
|
131
|
+
# -i, --interactive Download and patch formula, then open a
|
132
|
+
# shell. This allows the user to run
|
133
|
+
# ./configure --help and otherwise
|
134
|
+
# determine how to turn the software package
|
135
|
+
# into a Homebrew package.
|
136
|
+
# -g, --git Create a Git repository, useful for
|
137
|
+
# creating patches to the software.
|
138
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class List
|
9
|
+
attr_reader :brew_path, :formulae, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, *formulae, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@formulae = formulae.join(' ')
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
list_command = "#{brew_path} list #{options} #{formulae}".squish
|
20
|
+
system_runner.print_output(list_command)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise ExecutionError, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
BOOLEAN_OPTIONS = %i[
|
28
|
+
full_name unbrewed versions multiple
|
29
|
+
pinned cask 1 l r t verbose debug
|
30
|
+
].freeze
|
31
|
+
|
32
|
+
def parse_args(args)
|
33
|
+
option_list = []
|
34
|
+
|
35
|
+
BOOLEAN_OPTIONS.each do |option|
|
36
|
+
str_option = option.to_s
|
37
|
+
kebab_option = str_option.snake_to_kebab
|
38
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
39
|
+
end
|
40
|
+
|
41
|
+
option_list.join(' ')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Usage: brew list, ls [options] [formula]
|
48
|
+
|
49
|
+
# List all installed formulae.
|
50
|
+
|
51
|
+
# If formula is provided, summarise the paths within its current keg.
|
52
|
+
|
53
|
+
# --full-name Print formulae with fully-qualified names.
|
54
|
+
# If --full-name is not passed, other
|
55
|
+
# options (i.e. -1, -l, -r and -t)
|
56
|
+
# are passed to ls(1) which produces the
|
57
|
+
# actual output.
|
58
|
+
# --unbrewed List files in Homebrew's prefix not
|
59
|
+
# installed by Homebrew.
|
60
|
+
# --versions Show the version number for installed
|
61
|
+
# formulae, or only the specified formulae if
|
62
|
+
# formula are provided.
|
63
|
+
# --multiple Only show formulae with multiple versions
|
64
|
+
# installed.
|
65
|
+
# --pinned Show the versions of pinned formulae, or
|
66
|
+
# only the specified (pinned) formulae if
|
67
|
+
# formula are provided. See also pin,
|
68
|
+
# unpin.
|
69
|
+
# --cask List casks
|
70
|
+
# -1 Force output to be one entry per line. This
|
71
|
+
# is the default when output is not to a
|
72
|
+
# terminal.
|
73
|
+
# -l List in long format. If the output is to a
|
74
|
+
# terminal, a total sum for all the file
|
75
|
+
# sizes is printed before the long listing.
|
76
|
+
# -r Reverse the order of the sort to list the
|
77
|
+
# oldest entries first.
|
78
|
+
# -t Sort by time modified, listing most
|
79
|
+
# recently modified first.
|
80
|
+
# -v, --verbose Make some output more verbose.
|
81
|
+
# -d, --debug Display any debugging information.
|
82
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Search
|
9
|
+
attr_reader :brew_path, :search_text, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, search_text = nil, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@search_text = search_text
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
search_command = "#{brew_path} search #{options} #{search_text}".squish
|
20
|
+
search_output = system_runner.get_output_lines(search_command)
|
21
|
+
|
22
|
+
organize_search_output(search_output)
|
23
|
+
rescue StandardError => e
|
24
|
+
raise Brew::ExecutionError, e
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
BOOLEAN_OPTIONS = %i[
|
30
|
+
formulae casks desc macports fink opensuse
|
31
|
+
fedora debian ubuntu verbose debug
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
def parse_args(args)
|
35
|
+
option_list = []
|
36
|
+
|
37
|
+
BOOLEAN_OPTIONS.each do |option|
|
38
|
+
str_option = option.to_s
|
39
|
+
kebab_option = str_option.snake_to_kebab
|
40
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
41
|
+
end
|
42
|
+
|
43
|
+
option_list.join(' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
def organize_search_output(output)
|
47
|
+
organized = {}
|
48
|
+
key = options.include?('casks') ? 'Casks' : 'Formulae'
|
49
|
+
|
50
|
+
output.each do |val|
|
51
|
+
val.strip!
|
52
|
+
if val.start_with?('==>')
|
53
|
+
key = val.split.last.squish
|
54
|
+
organized[key] ||= []
|
55
|
+
else
|
56
|
+
organized[key] ||= []
|
57
|
+
organized[key] << val.squish
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
organized
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Usage: brew search [options] [text|/text/]
|
68
|
+
|
69
|
+
# Perform a substring search of cask tokens and formula names for text. If
|
70
|
+
# text is flanked by slashes, it is interpreted as a regular expression. The
|
71
|
+
# search for text is extended online to homebrew/core and homebrew/cask.
|
72
|
+
|
73
|
+
# If no text is provided, list all locally available formulae (including tapped
|
74
|
+
# ones). No online search is performed.
|
75
|
+
|
76
|
+
# --formulae Without text, list all locally available
|
77
|
+
# formulae (no online search is performed).
|
78
|
+
# With text, search online and locally for
|
79
|
+
# formulae.
|
80
|
+
# --casks Without text, list all locally available
|
81
|
+
# casks (including tapped ones, no online
|
82
|
+
# search is performed). With text, search
|
83
|
+
# online and locally for casks.
|
84
|
+
# --desc Search for formulae with a description
|
85
|
+
# matching text and casks with a name
|
86
|
+
# matching text.
|
87
|
+
# --macports Search for text in the given package
|
88
|
+
# manager's list.
|
89
|
+
# --fink Search for text in the given package
|
90
|
+
# manager's list.
|
91
|
+
# --opensuse Search for text in the given package
|
92
|
+
# manager's list.
|
93
|
+
# --fedora Search for text in the given package
|
94
|
+
# manager's list.
|
95
|
+
# --debian Search for text in the given package
|
96
|
+
# manager's list.
|
97
|
+
# --ubuntu Search for text in the given package
|
98
|
+
# manager's list.
|
99
|
+
# -v, --verbose Make some output more verbose.
|
100
|
+
# -d, --debug Display any debugging information.
|
101
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Uninstall
|
9
|
+
attr_reader :brew_path, :formulae, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, *formulae, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@formulae = formulae.join(' ')
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
uninstall_command = "#{brew_path} uninstall #{options} #{formulae}".squish
|
20
|
+
system_runner.print_output(uninstall_command)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise Brew::ExecutionError, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
BOOLEAN_OPTIONS = %i[force ignore_dependencies debug].freeze
|
28
|
+
|
29
|
+
def parse_args(args)
|
30
|
+
option_list = []
|
31
|
+
|
32
|
+
BOOLEAN_OPTIONS.each do |option|
|
33
|
+
str_option = option.to_s
|
34
|
+
kebab_option = str_option.snake_to_kebab
|
35
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
36
|
+
end
|
37
|
+
|
38
|
+
option_list.join(' ')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Usage: brew uninstall, rm, remove [options] formula
|
45
|
+
|
46
|
+
# Uninstall formula.
|
47
|
+
|
48
|
+
# -f, --force Delete all installed versions of formula.
|
49
|
+
# --ignore-dependencies Don't fail uninstall, even if formula is
|
50
|
+
# a dependency of any installed formulae.
|
51
|
+
# -d, --debug Display any debugging information.
|
52
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Update
|
9
|
+
attr_reader :brew_path, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@options = parse_args(kwargs)
|
14
|
+
@system_runner = SystemRunner.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute!
|
18
|
+
update_command = "#{brew_path} update #{options}".squish
|
19
|
+
system_runner.print_output(update_command)
|
20
|
+
rescue StandardError => e
|
21
|
+
raise Brew::ExecutionError, e
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
BOOLEAN_OPTIONS = %i[merge force verbose debug].freeze
|
27
|
+
|
28
|
+
def parse_args(args)
|
29
|
+
option_list = []
|
30
|
+
|
31
|
+
BOOLEAN_OPTIONS.each do |option|
|
32
|
+
str_option = option.to_s
|
33
|
+
kebab_option = str_option.snake_to_kebab
|
34
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
35
|
+
end
|
36
|
+
|
37
|
+
option_list.join(' ')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Usage: brew update, up [options]
|
44
|
+
|
45
|
+
# Fetch the newest version of Homebrew and all formulae from GitHub using git(1)
|
46
|
+
# and perform any necessary migrations.
|
47
|
+
|
48
|
+
# --merge Use git merge to apply updates (rather
|
49
|
+
# than git rebase).
|
50
|
+
# -f, --force Always do a slower, full update check (even
|
51
|
+
# if unnecessary).
|
52
|
+
# -v, --verbose Print the directories checked and git
|
53
|
+
# operations performed.
|
54
|
+
# -d, --debug Display a trace of all shell commands as
|
55
|
+
# they are executed.
|
56
|
+
# -h, --help Show this message.
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'brew/utils/string_utils'
|
4
|
+
require 'brew/utils/system_runner'
|
5
|
+
|
6
|
+
module Brew
|
7
|
+
module Commands
|
8
|
+
class Upgrade
|
9
|
+
attr_reader :brew_path, :formulae, :options, :system_runner
|
10
|
+
|
11
|
+
def initialize(brew_path, *formulae, **kwargs)
|
12
|
+
@brew_path = brew_path
|
13
|
+
@formulae = formulae.join(' ')
|
14
|
+
@options = parse_args(kwargs)
|
15
|
+
@system_runner = SystemRunner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute!
|
19
|
+
upgrade_command = "#{brew_path} upgrade #{options} #{formulae}".squish
|
20
|
+
system_runner.print_output(upgrade_command)
|
21
|
+
rescue StandardError => e
|
22
|
+
raise Brew::ExecutionError, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
BOOLEAN_OPTIONS = %i[
|
28
|
+
build_from_source force_bottle fetch_HEAD
|
29
|
+
ignore_pinned keep_tmp force verbose
|
30
|
+
display_times dry_run greedy
|
31
|
+
].freeze
|
32
|
+
|
33
|
+
def parse_args(args)
|
34
|
+
option_list = []
|
35
|
+
|
36
|
+
BOOLEAN_OPTIONS.each do |option|
|
37
|
+
str_option = option.to_s
|
38
|
+
kebab_option = str_option.snake_to_kebab
|
39
|
+
option_list << "--#{kebab_option}" if args[option] || args[str_option] || args[kebab_option]
|
40
|
+
end
|
41
|
+
|
42
|
+
option_list.join(' ')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Usage: brew upgrade [options] [formula]
|
49
|
+
|
50
|
+
# Upgrade outdated, unpinned formulae using the same options they were originally
|
51
|
+
# installed with, plus any appended brew formula options. If formula are
|
52
|
+
# specified, upgrade only the given formula kegs (unless they are pinned; see
|
53
|
+
# pin, unpin).
|
54
|
+
|
55
|
+
# Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run for
|
56
|
+
# the upgraded formulae or, every 30 days, for all formulae.
|
57
|
+
|
58
|
+
# -d, --debug If brewing fails, open an interactive
|
59
|
+
# debugging session with access to IRB or a
|
60
|
+
# shell inside the temporary build directory.
|
61
|
+
# -s, --build-from-source Compile formula from source even if a
|
62
|
+
# bottle is available.
|
63
|
+
# -i, --interactive Download and patch formula, then open a
|
64
|
+
# shell. This allows the user to run
|
65
|
+
# ./configure --help and otherwise
|
66
|
+
# determine how to turn the software package
|
67
|
+
# into a Homebrew package.
|
68
|
+
# --force-bottle Install from a bottle if it exists for the
|
69
|
+
# current or newest version of macOS, even if
|
70
|
+
# it would not normally be used for
|
71
|
+
# installation.
|
72
|
+
# --fetch-HEAD Fetch the upstream repository to detect if
|
73
|
+
# the HEAD installation of the formula is
|
74
|
+
# outdated. Otherwise, the repository's HEAD
|
75
|
+
# will only be checked for updates when a new
|
76
|
+
# stable or development version has been
|
77
|
+
# released.
|
78
|
+
# --ignore-pinned Set a successful exit status even if pinned
|
79
|
+
# formulae are not upgraded.
|
80
|
+
# --keep-tmp Retain the temporary files created during
|
81
|
+
# installation.
|
82
|
+
# -f, --force Install without checking for previously
|
83
|
+
# installed keg-only or non-migrated
|
84
|
+
# versions.
|
85
|
+
# -v, --verbose Print the verification and postinstall
|
86
|
+
# steps.
|
87
|
+
# --display-times Print install times for each formula at the
|
88
|
+
# end of the run.
|
89
|
+
# -n, --dry-run Show what would be upgraded, but do not
|
90
|
+
# actually upgrade anything.
|
91
|
+
# --greedy Upgrade casks with auto_updates or
|
92
|
+
# version :latest
|
93
|
+
# -h, --help Show this message.
|
data/lib/brew/home_brew.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'brew/commands/info'
|
4
|
+
require 'brew/commands/install'
|
5
|
+
require 'brew/commands/list'
|
6
|
+
require 'brew/commands/search'
|
7
|
+
require 'brew/commands/uninstall'
|
8
|
+
require 'brew/commands/update'
|
9
|
+
require 'brew/commands/upgrade'
|
4
10
|
|
5
11
|
module Brew
|
6
|
-
class HomeBrewError < StandardError; end
|
7
|
-
class HomeBrewNotInstalled < HomeBrewError; end
|
8
|
-
|
9
|
-
# Main class to call 'brew' functions
|
10
12
|
class HomeBrew
|
11
13
|
DEFAULT_BREW_PATH = '/usr/local/bin/brew'
|
12
14
|
|
@@ -18,45 +20,36 @@ module Brew
|
|
18
20
|
raise HomeBrewNotInstalled unless File.executable?(@brew_path)
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
-
run_command(install_command)
|
24
|
-
rescue StandardError => e
|
25
|
-
raise HomeBrewError, e
|
23
|
+
def info(formula = [], **kwargs)
|
24
|
+
Commands::Info.new(brew_path, formula, **kwargs).execute!
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
29
|
-
|
30
|
-
run_command(update_command)
|
31
|
-
rescue StandardError => e
|
32
|
-
raise HomeBrewError, e
|
27
|
+
def install(formula, **kwargs)
|
28
|
+
Commands::Install.new(brew_path, formula, **kwargs).execute!
|
33
29
|
end
|
34
30
|
|
35
|
-
def
|
36
|
-
|
37
|
-
run_command(update_command)
|
38
|
-
rescue StandardError => e
|
39
|
-
raise HomeBrewError, e
|
31
|
+
def list(formulae = [], **kwargs)
|
32
|
+
Commands::List.new(brew_path, formulae, **kwargs).execute!
|
40
33
|
end
|
34
|
+
alias ls list
|
41
35
|
|
42
|
-
def
|
43
|
-
|
44
|
-
run_command(update_command)
|
45
|
-
rescue StandardError => e
|
46
|
-
raise HomeBrewError, e
|
36
|
+
def search(text = nil, **kwargs)
|
37
|
+
Commands::Search.new(brew_path, text, **kwargs).execute!
|
47
38
|
end
|
48
39
|
|
49
|
-
|
40
|
+
def uninstall(formula, **kwargs)
|
41
|
+
Commands::Uninstall.new(brew_path, formula, **kwargs).execute!
|
42
|
+
end
|
43
|
+
alias rm uninstall
|
44
|
+
alias remove uninstall
|
50
45
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
io.close
|
57
|
-
end
|
46
|
+
def update(**kwargs)
|
47
|
+
Commands::Update.new(brew_path, **kwargs).execute!
|
48
|
+
end
|
49
|
+
alias up update
|
58
50
|
|
59
|
-
|
51
|
+
def upgrade(formula = [], **kwargs)
|
52
|
+
Commands::Upgrade.new(brew_path, formula, **kwargs).execute!
|
60
53
|
end
|
61
54
|
end
|
62
55
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
|
5
|
+
module Brew
|
6
|
+
class SystemRunner
|
7
|
+
def print_output(command)
|
8
|
+
lines = run_with_output(command) do |line|
|
9
|
+
$stdout.puts line
|
10
|
+
end
|
11
|
+
lines.join
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_output_lines(command)
|
15
|
+
run_with_output(command)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def run_with_output(command)
|
21
|
+
lines = []
|
22
|
+
IO.popen(command, 'r+') do |io|
|
23
|
+
while (line = io.gets)
|
24
|
+
yield line if block_given?
|
25
|
+
lines << line
|
26
|
+
end
|
27
|
+
io.close
|
28
|
+
end
|
29
|
+
|
30
|
+
raise "Exited with code #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
|
31
|
+
|
32
|
+
lines
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/brew/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin C Roos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: minitest
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +88,7 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".rubocop.yml"
|
77
92
|
- CODE_OF_CONDUCT.md
|
78
93
|
- Gemfile
|
79
94
|
- Gemfile.lock
|
@@ -83,7 +98,16 @@ files:
|
|
83
98
|
- bin/setup
|
84
99
|
- brew.gemspec
|
85
100
|
- lib/brew.rb
|
101
|
+
- lib/brew/commands/info.rb
|
102
|
+
- lib/brew/commands/install.rb
|
103
|
+
- lib/brew/commands/list.rb
|
104
|
+
- lib/brew/commands/search.rb
|
105
|
+
- lib/brew/commands/uninstall.rb
|
106
|
+
- lib/brew/commands/update.rb
|
107
|
+
- lib/brew/commands/upgrade.rb
|
86
108
|
- lib/brew/home_brew.rb
|
109
|
+
- lib/brew/utils/string_utils.rb
|
110
|
+
- lib/brew/utils/system_runner.rb
|
87
111
|
- lib/brew/version.rb
|
88
112
|
homepage:
|
89
113
|
licenses: []
|