зеркало из https://github.com/github/licensed.git
Add Version Command
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:
Родитель
24b6023224
Коммит
7def785cc0
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче