Commit fe6ac03c authored by Damian Montero's avatar Damian Montero Committed by GitHub

Merge pull request #334 from uberhacker/feature/add-crew-whatprovides-command

Add crew whatprovides command
parents 41258993 4ada4e25
...@@ -28,7 +28,6 @@ case ARCH ...@@ -28,7 +28,6 @@ case ARCH
SHORTARCH="32" SHORTARCH="32"
end end
$LOAD_PATH.unshift "#{CREW_LIB_PATH}lib" $LOAD_PATH.unshift "#{CREW_LIB_PATH}lib"
USER = `whoami`.chomp USER = `whoami`.chomp
...@@ -52,8 +51,8 @@ end ...@@ -52,8 +51,8 @@ end
def list_packages def list_packages
Find.find (CREW_LIB_PATH + 'packages') do |filename| Find.find (CREW_LIB_PATH + 'packages') do |filename|
Find.find(CREW_CONFIG_PATH + 'meta/') do |packageList| Find.find(CREW_CONFIG_PATH + 'meta/') do |packageList|
packageName = File.basename filename, '.rb' packageName = File.basename filename, '.rb'
print '(i) ' if packageList == CREW_CONFIG_PATH + 'meta/' + packageName + '.filelist' print '(i) ' if packageList == CREW_CONFIG_PATH + 'meta/' + packageName + '.filelist'
end end
puts File.basename filename, '.rb' if File.extname(filename) == '.rb' puts File.basename filename, '.rb' if File.extname(filename) == '.rb'
end end
...@@ -66,6 +65,32 @@ def search (pkgName, silent = false) ...@@ -66,6 +65,32 @@ def search (pkgName, silent = false)
abort "package #{pkgName} not found :(" abort "package #{pkgName} not found :("
end end
def whatprovides (pkgName)
fileArray = []
Find.find (CREW_CONFIG_PATH + 'meta/') do |packageList|
if File.file? packageList
if packageList[/\.filelist$/]
packageName = File.basename packageList, '.filelist'
File.readlines(packageList).each do |line|
found = line[/#{Regexp.new(pkgName)}/]
if found
fileLine = packageName + ': ' + line
if not fileArray.include? fileLine
fileArray.push(fileLine)
end
end
end
end
end
end
if not fileArray.empty?
fileArray.sort.each do |item|
puts item
end
puts "\nTotal found: #{fileArray.length}"
end
end
def update def update
abort "'crew update' is used to update crew itself. Use 'crew upgrade <packageName> to upgrade a specific package." if @pkgName abort "'crew update' is used to update crew itself. Use 'crew upgrade <packageName> to upgrade a specific package." if @pkgName
...@@ -371,6 +396,12 @@ when "search" ...@@ -371,6 +396,12 @@ when "search"
else else
list_packages list_packages
end end
when "whatprovides"
if @pkgName
whatprovides @pkgName
else
puts "Usage: crew whatprovides [pattern]"
end
when "download" when "download"
search @pkgName search @pkgName
download download
...@@ -386,10 +417,10 @@ when "remove" ...@@ -386,10 +417,10 @@ when "remove"
search @pkgName search @pkgName
remove remove
when nil when nil
puts "Chromebrew, version 0.2.1" puts "Chromebrew, version 0.2.2"
puts "Usage: crew [command] [package]" puts "Usage: crew [command] [package]"
puts "Available commands: search, download, install, remove" puts "Available commands: search, download, install, remove, whatprovides"
else else
puts "I have no idea how to do #{@command} :(" puts "I have no idea how to do #{@command} :("
puts "Available commands: search, download, install, remove" puts "Available commands: search, download, install, remove, whatprovides"
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment