mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
* crew: Add `diskstat` command Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Remove workarounds Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Make rubocop happy Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Allow customizing package count Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Also check for runtime directory size Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Fix file size display Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Bump version Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Minor fixes Signed-off-by: SupeChicken666 <supechicken666@gmail.com> * Suggested changes Signed-off-by: SupeChicken666 <supechicken666@gmail.com> --------- Signed-off-by: SupeChicken666 <supechicken666@gmail.com>
37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
require_relative '../lib/const'
|
|
require_relative '../lib/convenience_functions'
|
|
require_relative '../lib/misc_functions'
|
|
require_relative '../lib/package_utils'
|
|
|
|
class Command
|
|
def self.files(pkg)
|
|
# Check if the package is even installed first, as this is the most likely reason we cannot find a filelist.
|
|
unless PackageUtils.installed?(pkg.name)
|
|
puts "Package #{pkg.name} is not installed.".lightred
|
|
return
|
|
end
|
|
|
|
# Fake packages do not have any files.
|
|
if pkg.is_fake?
|
|
puts "Package #{pkg.name} is fake and has no files.".lightred
|
|
return
|
|
end
|
|
|
|
# We can't do anything if we don't have the filelist.
|
|
unless File.file?(filelist_path = File.join(CREW_META_PATH, "#{pkg.name}.filelist"))
|
|
puts "Package #{pkg.name} does not have a filelist :(".lightred
|
|
return
|
|
end
|
|
|
|
# Print the name and description of the package.
|
|
puts pkg.name.lightgreen + ": #{pkg.description}".lightblue
|
|
|
|
size, filelist = ConvenienceFunctions.read_filelist(filelist_path, always_calcuate_from_disk: true)
|
|
|
|
# Print the filelist, the total number of files, and the total size of those files.
|
|
puts filelist
|
|
puts "\nTotal found: #{filelist.count}".lightgreen
|
|
puts "Disk usage: #{MiscFunctions.human_size(size)}".lightgreen
|
|
end
|
|
end
|