Add crew version <name> command to get versions of packages. (#13027)

* Add crew version <name> command to get versions of packages.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* bump version

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add to Readme.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
Satadru Pramanik, DO, MPH, MEng
2025-10-03 15:13:00 -04:00
committed by GitHub
parent 3394408370
commit befb8fe6b7
3 changed files with 16 additions and 2 deletions

View File

@@ -100,6 +100,7 @@ Where available commands are:
| upgrade | update all or specific package(s) |
| upload | upload binaries for all or specific package(s) |
| upstream | check if an upstream version is available for package(s) |
| version | check for the Chromebrew version, or if a package is specified, the package version |
| whatprovides | regex search for package(s) that contains file(s) |
Available packages are listed in the [packages directory](https://github.com/chromebrew/chromebrew/tree/master/packages).

View File

@@ -46,7 +46,7 @@ begin
rescue Docopt::Exit => e
if ARGV[0]
case ARGV[0]
when '-V', '--version', 'version'
when '-V', '--version'
puts CREW_VERSION
exit 0
when '-L', '--license', 'license'
@@ -2046,6 +2046,18 @@ def upstream_command(args)
end
end
def version_command(args)
args = { '<name>' => args.split } if args.is_a? String
if args['<name>'].empty?
puts CREW_VERSION
else
args['<name>'].each do |name|
search name
puts @pkg.version
end
end
end
def whatprovides_command(args)
args['<pattern>'].each do |regex|
Command.whatprovides(regex)

View File

@@ -4,7 +4,7 @@ require 'etc'
require 'open3'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.67.3' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
CREW_VERSION ||= '1.67.4' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine]
@@ -466,6 +466,7 @@ CREW_DOCOPT ||= <<~DOCOPT
crew upgrade [options] [-f|--force] [-k|--keep] [-s|--source] [-v|--verbose] [<name> ...]
crew upload [options] [-f|--force] [-v|--verbose] [<name> ...]
crew upstream [options] [-j|--json|-u|--update-package-files|-v|--verbose] <name> ...
crew version [options] [<name>]
crew whatprovides [options] <pattern> ...
-b --include-build-deps Include build dependencies in output.