lyp 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lilypond +1 -0
- data/lib/lyp/cli.rb +178 -7
- data/lib/lyp/lilypond.rb +24 -2
- data/lib/lyp/package.rb +73 -24
- data/lib/lyp/system.rb +1 -0
- data/lib/lyp/version.rb +1 -1
- metadata +7 -8
- data/lib/lyp/cli/commands.rb +0 -178
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b10bc684d3755cd63fde5175e4769e7ee8d1ae
|
4
|
+
data.tar.gz: dc4c7568047ba01915131cba0125e717f6c9f107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f3845fec6418ec6221659d9f04a8e5d6919fd77fe714ee0d91a02f3664cc66ffc1c3e1189c1d8f903ad96bbeffce7e28e361c7ca098d780e76c2afbb80b80ca
|
7
|
+
data.tar.gz: 97ecbadebd13b96c51861c160c62b7e14f2546882d2cad65d9578c9488f2bed997abfb7678b8b43f8c04ee6bf5a4ddbb5f37b03b1c18a07d3947b1c8c8e72e91
|
data/bin/lilypond
CHANGED
@@ -5,6 +5,7 @@ require 'lyp'
|
|
5
5
|
|
6
6
|
STDERR.puts "Lyp version #{Lyp::VERSION}"
|
7
7
|
|
8
|
+
Lyp::Lilypond.check_lilypond!
|
8
9
|
lilypond_path = Lyp::Lilypond.current_lilypond
|
9
10
|
unless lilypond_path && File.file?(lilypond_path)
|
10
11
|
STDERR.puts "No version of lilypond found. To install lilypond run 'lyp install lilypond'."
|
data/lib/lyp/cli.rb
CHANGED
@@ -1,11 +1,182 @@
|
|
1
|
-
require '
|
1
|
+
require 'thor'
|
2
2
|
require "lyp/version"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def lilypond_prefix(info)
|
5
|
+
if info[:current] && info[:default]
|
6
|
+
"=* "
|
7
|
+
elsif info[:current]
|
8
|
+
"=> "
|
9
|
+
elsif info[:default]
|
10
|
+
" * "
|
11
|
+
else
|
12
|
+
" "
|
13
|
+
end
|
14
|
+
end
|
8
15
|
|
9
|
-
|
16
|
+
def lilypond_postfix(info)
|
17
|
+
if info[:system]
|
18
|
+
" (system)"
|
19
|
+
else
|
20
|
+
""
|
21
|
+
end
|
22
|
+
end
|
10
23
|
|
11
|
-
|
24
|
+
def format_lilypond_entry(info)
|
25
|
+
"#{lilypond_prefix(info)}#{info[:version]}#{lilypond_postfix(info)}"
|
26
|
+
end
|
27
|
+
|
28
|
+
LILYPOND_PREAMBLE = <<EOF
|
29
|
+
|
30
|
+
Lilypond versions:
|
31
|
+
|
32
|
+
EOF
|
33
|
+
|
34
|
+
LILYPOND_LEGEND = <<EOF
|
35
|
+
|
36
|
+
# => - current
|
37
|
+
# =* - current && default
|
38
|
+
# * - default
|
39
|
+
|
40
|
+
EOF
|
41
|
+
|
42
|
+
class Lyp::CLI < Thor
|
43
|
+
package_name "lyp"
|
44
|
+
map "-v" => :version
|
45
|
+
check_unknown_options! :except => :compile
|
46
|
+
|
47
|
+
desc "version", "show Lyp version"
|
48
|
+
def version
|
49
|
+
require 'lyp/version'
|
50
|
+
$stderr.puts "Lyp #{Lyp::VERSION}"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "search [PATTERN|lilypond]", "List available packages matching PATTERN or versions of lilypond"
|
54
|
+
def search(pattern)
|
55
|
+
# Lyp::System.test_installed_status!
|
56
|
+
|
57
|
+
pattern =~ Lyp::PACKAGE_RE
|
58
|
+
package, version = $1, $2
|
59
|
+
|
60
|
+
if package == 'lilypond'
|
61
|
+
search_lilypond(version)
|
62
|
+
else
|
63
|
+
search_package(pattern)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
no_commands do
|
68
|
+
def search_lilypond(version)
|
69
|
+
versions = Lyp::Lilypond.search(version)
|
70
|
+
|
71
|
+
if versions.empty?
|
72
|
+
puts "\nNo versions of lilypond are available for download\n\n"
|
73
|
+
else
|
74
|
+
puts "\nAvailable versions of lilypond:\n\n"
|
75
|
+
versions.each do |v|
|
76
|
+
prefix = v[:installed] ? " * " : " "
|
77
|
+
puts "#{prefix}#{v[:version]}"
|
78
|
+
end
|
79
|
+
puts "\n * Currently installed\n\n"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def search_package(pattern)
|
84
|
+
packages = Lyp::Package.list_lyp_index(pattern)
|
85
|
+
if packages.empty?
|
86
|
+
puts "\nNo matching package found in lyp-index\n\n"
|
87
|
+
else
|
88
|
+
puts "\nAvailable packages:\n\n"
|
89
|
+
packages.each do |p|
|
90
|
+
puts " #{p[:name]}"
|
91
|
+
end
|
92
|
+
puts "\n\n"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "compile [<option>...] <FILE>", "Invokes lilypond with given file"
|
98
|
+
def compile(*args)
|
99
|
+
Lyp::System.test_installed_status!
|
100
|
+
Lyp::Lilypond.check_lilypond!
|
101
|
+
|
102
|
+
Lyp::Lilypond.compile(*args)
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "install <PACKAGE|lilypond|self>...", "Install a package or a version of lilypond. When 'install self' is invoked, lyp installs itself in ~/.lyp."
|
106
|
+
method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
|
107
|
+
def install(*args)
|
108
|
+
raise "No package specified" if args.empty?
|
109
|
+
|
110
|
+
args.each do |package|
|
111
|
+
case package
|
112
|
+
when 'self'
|
113
|
+
Lyp::System.install!
|
114
|
+
when /^lilypond(?:@(.+))?$/
|
115
|
+
Lyp::System.test_installed_status!
|
116
|
+
Lyp::Lilypond.install($1, options)
|
117
|
+
else
|
118
|
+
Lyp::System.test_installed_status!
|
119
|
+
Lyp::Package.install(package)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
desc "uninstall <PACKAGE|lilypond|self>...", "Uninstall a package or a version of lilypond. When 'uninstall self' is invoked, lyp uninstalls itself from ~/.lyp."
|
125
|
+
def uninstall(*args)
|
126
|
+
Lyp::System.test_installed_status!
|
127
|
+
|
128
|
+
raise "No package specified" if args.empty?
|
129
|
+
args.each do |package|
|
130
|
+
case package
|
131
|
+
when 'self'
|
132
|
+
Lyp::System.uninstall!
|
133
|
+
when /^lilypond(?:@(.+))?$/
|
134
|
+
Lyp::System.test_installed_status!
|
135
|
+
Lyp::Lilypond.uninstall($1)
|
136
|
+
else
|
137
|
+
Lyp::System.test_installed_status!
|
138
|
+
Lyp::Package.uninstall(package)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
desc "use [lilypond@]<VERSION>", "Switch version of lilypond"
|
144
|
+
method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
|
145
|
+
def use(version)
|
146
|
+
Lyp::System.test_installed_status!
|
147
|
+
|
148
|
+
if version =~ /^lilypond@(.+)$/
|
149
|
+
version = $1
|
150
|
+
end
|
151
|
+
|
152
|
+
lilypond = Lyp::Lilypond.use(version, options)
|
153
|
+
puts "Using version #{lilypond[:version]}"
|
154
|
+
end
|
155
|
+
|
156
|
+
desc "list [PATTERN|lilypond]", "List installed packages matching PATTERN or versions of lilypond"
|
157
|
+
def list(pattern = nil)
|
158
|
+
Lyp::System.test_installed_status!
|
159
|
+
|
160
|
+
if pattern == 'lilypond'
|
161
|
+
STDOUT.puts LILYPOND_PREAMBLE
|
162
|
+
Lyp::Lilypond.list.each {|info| puts format_lilypond_entry(info)}
|
163
|
+
STDOUT.puts LILYPOND_LEGEND
|
164
|
+
else
|
165
|
+
Lyp::Package.list(args.first).each {|p| puts p}
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
desc "which [PATTERN|lilypond]", "List locations of installed packages matching PATTERN or versions of lilypond"
|
170
|
+
def which(pattern = nil)
|
171
|
+
Lyp::System.test_installed_status!
|
172
|
+
|
173
|
+
if pattern == 'lilypond'
|
174
|
+
puts Lyp::Lilypond.current_lilypond
|
175
|
+
else
|
176
|
+
Lyp::Package.which(args.first).each {|p| puts p}
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
Lyp::CLI.start(ARGV)
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'uri'
|
3
|
+
require 'open3'
|
3
4
|
|
4
5
|
module Lyp::Lilypond
|
5
6
|
class << self
|
@@ -13,7 +14,7 @@ module Lyp::Lilypond
|
|
13
14
|
def invoke(argv)
|
14
15
|
lilypond = detect_use_version_argument(argv) || current_lilypond
|
15
16
|
|
16
|
-
exec(
|
17
|
+
Kernel.exec(lilypond, *argv)
|
17
18
|
end
|
18
19
|
|
19
20
|
def detect_use_version_argument(argv)
|
@@ -47,6 +48,25 @@ module Lyp::Lilypond
|
|
47
48
|
set_session_settings(settings)
|
48
49
|
end
|
49
50
|
|
51
|
+
def check_lilypond!
|
52
|
+
# check default
|
53
|
+
select_default_lilypond! unless valid_lilypond?(default_lilypond)
|
54
|
+
|
55
|
+
set_current_lilypond(default_lilypond) unless valid_lilypond?(current_lilypond)
|
56
|
+
end
|
57
|
+
|
58
|
+
def valid_lilypond?(path)
|
59
|
+
File.file?(path) && (`#{path} -v` =~ /^GNU LilyPond/)
|
60
|
+
end
|
61
|
+
|
62
|
+
def select_default_lilypond!
|
63
|
+
latest = system_lilyponds.sort(&CMP_VERSION).last || lyp_lilyponds.sort(&CMP_VERSION).last
|
64
|
+
if latest
|
65
|
+
default = latest[:path]
|
66
|
+
set_default_lilypond(default)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
def get_session_settings
|
51
71
|
YAML.load(IO.read(session_settings_filename)) rescue {}
|
52
72
|
end
|
@@ -406,8 +426,10 @@ module Lyp::Lilypond
|
|
406
426
|
def exec(cmd)
|
407
427
|
Open3.popen3(cmd) do |_in, _out, _err, wait_thr|
|
408
428
|
exit_value = wait_thr.value
|
429
|
+
$_out = _out.read
|
430
|
+
$_err = _err.read
|
409
431
|
if exit_value != 0
|
410
|
-
raise "Error executing cmd #{cmd}: #{_err.read}"
|
432
|
+
raise "Error executing cmd #{cmd}: #{$_err.read}"
|
411
433
|
end
|
412
434
|
end
|
413
435
|
|
data/lib/lyp/package.rb
CHANGED
@@ -12,7 +12,27 @@ module Lyp::Package
|
|
12
12
|
end
|
13
13
|
|
14
14
|
if pattern
|
15
|
-
|
15
|
+
if (pattern =~ /@/) && (pattern =~ Lyp::PACKAGE_RE)
|
16
|
+
package, version = $1, $2
|
17
|
+
req = Gem::Requirement.new(version) rescue nil
|
18
|
+
packages.select! do |p|
|
19
|
+
p =~ Lyp::PACKAGE_RE
|
20
|
+
p_pack, p_ver = $1, $2
|
21
|
+
|
22
|
+
next false unless p_pack == package
|
23
|
+
|
24
|
+
if req && (p_gemver = Gem::Version.new(p_ver) rescue nil)
|
25
|
+
req =~ p_gemver
|
26
|
+
else
|
27
|
+
p_ver == version
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
packages.select! do |p|
|
32
|
+
p =~ Lyp::PACKAGE_RE
|
33
|
+
$1 =~ /#{pattern}/
|
34
|
+
end
|
35
|
+
end
|
16
36
|
end
|
17
37
|
|
18
38
|
packages.sort do |x, y|
|
@@ -30,6 +50,10 @@ module Lyp::Package
|
|
30
50
|
end
|
31
51
|
end
|
32
52
|
|
53
|
+
def which(pattern = nil)
|
54
|
+
list(pattern).map {|p| "#{Lyp.packages_dir}/#{p}" }
|
55
|
+
end
|
56
|
+
|
33
57
|
def install(package_specifier, opts = {})
|
34
58
|
unless package_specifier =~ Lyp::PACKAGE_RE
|
35
59
|
raise "Invalid package specifier #{package_specifier}"
|
@@ -59,6 +83,23 @@ module Lyp::Package
|
|
59
83
|
version
|
60
84
|
end
|
61
85
|
|
86
|
+
def uninstall(package, opts = {})
|
87
|
+
if opts[:all_versions]
|
88
|
+
Dir["#{Lyp.packages_dir}/#{package}@*"].each do |path|
|
89
|
+
puts "Uninstalling #{File.basename(path)}" unless opts[:silent]
|
90
|
+
FileUtils.rm_rf(path)
|
91
|
+
end
|
92
|
+
else
|
93
|
+
path = "#{Lyp.packages_dir}/#{package}"
|
94
|
+
if File.directory?(path)
|
95
|
+
puts "Uninstalling #{package}" unless opts[:silent]
|
96
|
+
FileUtils.rm_rf(path)
|
97
|
+
else
|
98
|
+
raise "Could not find #{package}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
62
103
|
def package_repository(url, tmp_path, opts = {})
|
63
104
|
# Create repository
|
64
105
|
if File.directory?(tmp_path)
|
@@ -74,20 +115,18 @@ module Lyp::Package
|
|
74
115
|
|
75
116
|
def checkout_package_version(repo, version, opts = {})
|
76
117
|
# Select commit to checkout
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
version = 'head'
|
81
|
-
else
|
82
|
-
tag = select_git_tag(repo, version)
|
83
|
-
unless tag
|
84
|
-
raise "Could not find tag matching #{version_specifier}"
|
85
|
-
end
|
86
|
-
puts "Checkout #{tag.name} tag" unless opts[:silent]
|
87
|
-
repo.checkout(tag.name, strategy: :force)
|
88
|
-
version = tag_version(tag)
|
118
|
+
checkout_ref = select_checkout_ref(repo, version)
|
119
|
+
unless checkout_ref
|
120
|
+
raise "Could not find tag matching #{version}"
|
89
121
|
end
|
90
|
-
|
122
|
+
|
123
|
+
begin
|
124
|
+
repo.checkout(checkout_ref, strategy: :force)
|
125
|
+
rescue
|
126
|
+
raise "Invalid version specified (#{version})"
|
127
|
+
end
|
128
|
+
|
129
|
+
tag_version(checkout_ref) || version
|
91
130
|
end
|
92
131
|
|
93
132
|
def install_package_dependencies(package_path, opts = {})
|
@@ -180,20 +219,30 @@ module Lyp::Package
|
|
180
219
|
|
181
220
|
TAG_VERSION_RE = /^v?(\d.*)$/
|
182
221
|
|
183
|
-
def
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
req =~ Gem::Version.new(v)
|
222
|
+
def select_checkout_ref(repo, version_specifier)
|
223
|
+
case version_specifier
|
224
|
+
when nil, '', 'latest'
|
225
|
+
highest_versioned_tag(repo) || 'master'
|
226
|
+
when /^(\>=|~\>|\d)/
|
227
|
+
req = Gem::Requirement.new(version_specifier)
|
228
|
+
tag = repo_tags(repo).reverse.find do |t|
|
229
|
+
(v = tag_version(t.name)) && (req =~ Gem::Version.new(v))
|
230
|
+
end
|
231
|
+
unless tag
|
232
|
+
raise "Could not find a version matching #{version_specifier}"
|
191
233
|
else
|
192
|
-
|
234
|
+
tag.name
|
193
235
|
end
|
236
|
+
else
|
237
|
+
version_specifier
|
194
238
|
end
|
195
239
|
end
|
196
240
|
|
241
|
+
def highest_versioned_tag(repo)
|
242
|
+
tag = repo_tags(repo).select {|t| Gem::Version.new(tag_version(t.name)) rescue nil}.last
|
243
|
+
tag && tag.name
|
244
|
+
end
|
245
|
+
|
197
246
|
# Returns a list of tags sorted by version
|
198
247
|
def repo_tags(repo)
|
199
248
|
tags = []
|
@@ -210,7 +259,7 @@ module Lyp::Package
|
|
210
259
|
end
|
211
260
|
|
212
261
|
def tag_version(tag)
|
213
|
-
(tag
|
262
|
+
(tag =~ TAG_VERSION_RE) ? $1 : nil
|
214
263
|
end
|
215
264
|
end
|
216
265
|
end
|
data/lib/lyp/system.rb
CHANGED
data/lib/lyp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -51,25 +51,25 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.7.5
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: thor
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '0.19'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 0.19.1
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '0.19'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: 0.19.1
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: nokogiri
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +144,6 @@ files:
|
|
144
144
|
- bin/lyp
|
145
145
|
- lib/lyp.rb
|
146
146
|
- lib/lyp/cli.rb
|
147
|
-
- lib/lyp/cli/commands.rb
|
148
147
|
- lib/lyp/directories.rb
|
149
148
|
- lib/lyp/lilypond.rb
|
150
149
|
- lib/lyp/package.rb
|
data/lib/lyp/cli/commands.rb
DELETED
@@ -1,178 +0,0 @@
|
|
1
|
-
# package commands
|
2
|
-
|
3
|
-
def lilypond_prefix(info)
|
4
|
-
if info[:current] && info[:default]
|
5
|
-
"=* "
|
6
|
-
elsif info[:current]
|
7
|
-
"=> "
|
8
|
-
elsif info[:default]
|
9
|
-
" * "
|
10
|
-
else
|
11
|
-
" "
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def lilypond_postfix(info)
|
16
|
-
if info[:system]
|
17
|
-
" (system)"
|
18
|
-
else
|
19
|
-
""
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def format_lilypond_entry(info)
|
24
|
-
"#{lilypond_prefix(info)}#{info[:version]}#{lilypond_postfix(info)}"
|
25
|
-
end
|
26
|
-
|
27
|
-
LILYPOND_PREAMBLE = <<EOF
|
28
|
-
|
29
|
-
Lilypond versions:
|
30
|
-
|
31
|
-
EOF
|
32
|
-
|
33
|
-
LILYPOND_LEGEND = <<EOF
|
34
|
-
|
35
|
-
# => - current
|
36
|
-
# =* - current && default
|
37
|
-
# * - default
|
38
|
-
|
39
|
-
EOF
|
40
|
-
|
41
|
-
command :list do |c|
|
42
|
-
c.syntax = "list [PATTERN]"
|
43
|
-
c.description = "Lists installed versions of packages whose name matches PATTERN"
|
44
|
-
c.action do |args, opts|
|
45
|
-
Lyp::System.test_installed_status!
|
46
|
-
|
47
|
-
pattern = args.first
|
48
|
-
if pattern == 'lilypond'
|
49
|
-
STDOUT.puts LILYPOND_PREAMBLE
|
50
|
-
Lyp::Lilypond.list.each {|info| puts format_lilypond_entry(info)}
|
51
|
-
STDOUT.puts LILYPOND_LEGEND
|
52
|
-
else
|
53
|
-
Lyp::Package.list(args.first).each {|p| puts p}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
command :compile do |c|
|
59
|
-
c.syntax = "compile <FILE>"
|
60
|
-
c.description = "Resolves package dependencies and invokes lilypond"
|
61
|
-
c.action do |args, opts|
|
62
|
-
Lyp::System.test_installed_status!
|
63
|
-
|
64
|
-
begin
|
65
|
-
raise "File not specified" if args.empty?
|
66
|
-
Lyp::Lilypond.compile(ARGV[1..-1])
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
command :search do |c|
|
72
|
-
c.syntax = "search <PATTERN>"
|
73
|
-
c.description = "Search for a package or a version of lilypond"
|
74
|
-
c.action do |args, opts|
|
75
|
-
Lyp::System.test_installed_status!
|
76
|
-
|
77
|
-
pattern = args.first
|
78
|
-
pattern =~ Lyp::PACKAGE_RE
|
79
|
-
package, version = $1, $2
|
80
|
-
req = (version && Gem::Requirement.new(version)) rescue nil
|
81
|
-
|
82
|
-
if package == 'lilypond'
|
83
|
-
begin
|
84
|
-
versions = Lyp::Lilypond.search(version)
|
85
|
-
|
86
|
-
if versions.empty?
|
87
|
-
puts "\nNo versions of lilypond are available for download\n\n"
|
88
|
-
else
|
89
|
-
puts "\nAvailable versions of lilypond:\n\n"
|
90
|
-
versions.each do |v|
|
91
|
-
prefix = v[:installed] ? " * " : " "
|
92
|
-
puts "#{prefix}#{v[:version]}"
|
93
|
-
end
|
94
|
-
puts "\n * Currently installed\n\n"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
else
|
98
|
-
packages = Lyp::Package.list_lyp_index(pattern)
|
99
|
-
if packages.empty?
|
100
|
-
puts "\nNo matching package found in lyp-index\n\n"
|
101
|
-
else
|
102
|
-
puts "\nAvailable packages:\n\n"
|
103
|
-
packages.each do |p|
|
104
|
-
puts " #{p[:name]}"
|
105
|
-
end
|
106
|
-
puts "\n\n"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
command :install do |c|
|
113
|
-
c.syntax = "install <PACKAGE...>"
|
114
|
-
c.description = "Install a package or a version of lilypond"
|
115
|
-
c.option "-d", "--default", "Set default version"
|
116
|
-
c.action do |args, opts|
|
117
|
-
|
118
|
-
begin
|
119
|
-
raise "No package specified" if args.empty?
|
120
|
-
|
121
|
-
args.each do |package|
|
122
|
-
case package
|
123
|
-
when 'self'
|
124
|
-
Lyp::System.install!
|
125
|
-
when /^lilypond(?:@(.+))?$/
|
126
|
-
Lyp::System.test_installed_status!
|
127
|
-
Lyp::Lilypond.install($1, opts.__hash__)
|
128
|
-
else
|
129
|
-
Lyp::System.test_installed_status!
|
130
|
-
Lyp::Package.install(package)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
command :use do |c|
|
138
|
-
c.syntax = "use [lilypond@]<VERSION>"
|
139
|
-
c.description = "Switch version of lilypond"
|
140
|
-
c.option "-d", "--default", "Set default version"
|
141
|
-
|
142
|
-
c.action do |args, opts|
|
143
|
-
Lyp::System.test_installed_status!
|
144
|
-
|
145
|
-
begin
|
146
|
-
version = args.first
|
147
|
-
if version =~ /^lilypond@(.+)$/
|
148
|
-
version = $1
|
149
|
-
end
|
150
|
-
|
151
|
-
lilypond = Lyp::Lilypond.use(version, opts.__hash__)
|
152
|
-
puts "Using version #{lilypond[:version]}"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
command :uninstall do |c|
|
158
|
-
c.syntax = "uninstall <PACKAGE>"
|
159
|
-
c.description = "Uninstall a package or version of lilypond"
|
160
|
-
|
161
|
-
c.action do |args, opts|
|
162
|
-
Lyp::System.test_installed_status!
|
163
|
-
|
164
|
-
begin
|
165
|
-
raise "No package specified" if args.empty?
|
166
|
-
|
167
|
-
args.each do |package|
|
168
|
-
case package
|
169
|
-
when 'self'
|
170
|
-
Lyp::System.uninstall!
|
171
|
-
when /^lilypond(?:@(.+))?$/
|
172
|
-
Lyp::System.test_installed_status!
|
173
|
-
Lyp::Lilypond.uninstall($1)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|