Addresses https://github.com/github/licensed/issues/62

Adds the "version" command. This command simply outputs the current
installed version of the gem.
This commit is contained in:
Matt Wagner 2018-10-23 21:17:48 -04:00
Родитель 24b6023224
Коммит 7def785cc0
5 изменённых файлов: 43 добавлений и 1 удалений

Просмотреть файл

@ -74,9 +74,11 @@ Warnings:
3 dependencies checked, 3 warnings found.
```
- `licensed version`: Show current installed version of Licensed. Aliases: `-v|--version`
### Configuration
All commands accept a `-c|--config` option to specify a path to a configuration file or directory.
All commands, except `version`, accept a `-c|--config` option to specify a path to a configuration file or directory.
If a directory is specified, `licensed` will look in that directory for a file named (in order of preference):
1. `.licensed.yml`

Просмотреть файл

@ -17,4 +17,5 @@ require "licensed/configuration"
require "licensed/command/cache"
require "licensed/command/status"
require "licensed/command/list"
require "licensed/command/version"
require "licensed/ui/shell"

Просмотреть файл

@ -30,6 +30,13 @@ module Licensed
run Licensed::Command::List.new(config)
end
map "-v" => :version
map "--version" => :version
desc "version", "Show Installed Version of Licensed, [-v, --version]"
def version
run Licensed::Command::Version.new
end
private
# Returns a configuration object for the CLI command

Просмотреть файл

@ -0,0 +1,18 @@
# frozen_string_literal: true
module Licensed
module Command
class Version
def initialize
@ui = Licensed::UI::Shell.new
end
def run
@ui.info(Licensed::VERSION)
end
def success?
true
end
end
end
end

Просмотреть файл

@ -68,4 +68,18 @@ describe "licensed" do
refute out =~ /Usage/i
end
end
describe "version" do
it "outputs VERSION constant" do
expected_out = "#{Licensed::VERSION}\n"
out, status = Open3.capture2 "bundle exec exe/licensed version"
assert_equal out, expected_out
out, status = Open3.capture2 "bundle exec exe/licensed -v"
assert_equal out, expected_out
out, status = Open3.capture2 "bundle exec exe/licensed --version"
assert_equal out, expected_out
end
end
end