Class: Lyp::CLI
- Inherits:
-
Thor
- Object
- Thor
- Lyp::CLI
- Defined in:
- lib/lyp/cli.rb
Instance Method Summary collapse
- #compile(*args) ⇒ Object
- #deps(fn) ⇒ Object
- #install(*args) ⇒ Object
- #list(pattern = nil) ⇒ Object
- #resolve(fn) ⇒ Object
- #search(pattern = '') ⇒ Object
- #test(*args) ⇒ Object
- #uninstall(*args) ⇒ Object
- #use(version) ⇒ Object
- #version ⇒ Object
- #which(pattern = nil) ⇒ Object
Instance Method Details
#compile(*args) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/lyp/cli.rb', line 99 def compile(*args) $stderr.puts "Lyp #{Lyp::VERSION}" Lyp::System.test_installed_status! if [:env] Lyp::Lilypond.force_env_version! if [:install] && !Lyp::Lilypond.forced_lilypond Lyp::Lilypond.install(Lyp::Lilypond.forced_version) end else # check lilypond default / current settings Lyp::Lilypond.check_lilypond! end Lyp::Lilypond.compile(args) end |
#deps(fn) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/lyp/cli.rb', line 236 def deps(fn) resolver = Lyp::Resolver.new(fn) tree = resolver.get_dependency_tree(ignore_missing: true) tree[:dependencies].each do |package, leaf| versions = leaf[:versions].keys.map {|k| k =~ Lyp::PACKAGE_RE; $2 }.sort if versions.empty? puts " #{leaf[:clause]} => (no local version found)" else puts " #{leaf[:clause]} => #{versions.join(', ')}" end end end |
#install(*args) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/lyp/cli.rb', line 144 def install(*args) raise "No package specified" if args.empty? args.each do |package| case package when 'self' Lyp::System.install! when Lyp::LILYPOND_RE Lyp::System.test_installed_status! Lyp::Lilypond.install($1, ) else Lyp::System.test_installed_status! Lyp::Package.install(package, ) end end end |
#list(pattern = nil) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/lyp/cli.rb', line 195 def list(pattern = nil) Lyp::System.test_installed_status! if pattern == 'lilypond' STDOUT.puts LILYPOND_PREAMBLE Lyp::Lilypond.list.each {|info| puts format_lilypond_entry(info)} STDOUT.puts LILYPOND_LEGEND else list = Lyp::Package.list(args.first) if list.empty? if args.first return puts "\nNo installed packages found matching '#{args.first}'\n\n" else return puts "\nNo packages are currently installed\n\n" end end by_package = list.inject({}) do |m, p| p =~ Lyp::PACKAGE_RE; (m[$1] ||= []) << $2; m end puts "\nInstalled packages:\n\n" by_package.keys.sort.each do |p| puts " #{p} => (#{by_package[p].sort.join(', ')})" end puts "\n\n" end end |
#resolve(fn) ⇒ Object
251 252 253 254 255 256 257 258 259 |
# File 'lib/lyp/cli.rb', line 251 def resolve(fn) resolver = Lyp::Resolver.new(fn) tree = resolver.get_dependency_tree(ignore_missing: true) tree[:dependencies].each do |package, leaf| if [:all] || leaf[:versions].empty? Lyp::Package.install(leaf[:clause]) end end end |
#search(pattern = '') ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/lyp/cli.rb', line 53 def search(pattern = '') # Lyp::System.test_installed_status! pattern =~ Lyp::PACKAGE_RE package, version = $1, $2 if package == 'lilypond' search_lilypond(version) else search_package(pattern) end end |
#test(*args) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/lyp/cli.rb', line 120 def test(*args) $stderr.puts "Lyp #{Lyp::VERSION}" if [:env] Lyp::Lilypond.force_env_version! if [:install] && !Lyp::Lilypond.forced_lilypond Lyp::Lilypond.install(Lyp::Lilypond.forced_version) end else # check lilypond default / current settings Lyp::Lilypond.check_lilypond! end case args when ['.'] Lyp::Package.run_local_tests('.') else Lyp::Package.run_package_tests(args) end end |
#uninstall(*args) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/lyp/cli.rb', line 163 def uninstall(*args) Lyp::System.test_installed_status! raise "No package specified" if args.empty? args.each do |package| case package when 'self' Lyp::System.uninstall! when Lyp::LILYPOND_RE Lyp::System.test_installed_status! Lyp::Lilypond.uninstall($1) else Lyp::System.test_installed_status! Lyp::Package.uninstall(package, ) end end end |
#use(version) ⇒ Object
183 184 185 186 187 188 189 190 191 192 |
# File 'lib/lyp/cli.rb', line 183 def use(version) Lyp::System.test_installed_status! if version =~ Lyp::LILYPOND_RE version = $1 end lilypond = Lyp::Lilypond.use(version, ) puts "Using version #{lilypond[:version]}" end |
#version ⇒ Object
48 49 50 |
# File 'lib/lyp/cli.rb', line 48 def version $stderr.puts "Lyp #{Lyp::VERSION}" end |
#which(pattern = nil) ⇒ Object
225 226 227 228 229 230 231 232 233 |
# File 'lib/lyp/cli.rb', line 225 def which(pattern = nil) Lyp::System.test_installed_status! if pattern == 'lilypond' puts Lyp::Lilypond.current_lilypond else Lyp::Package.which(args.first).each {|p| puts p} end end |