lib/git_topic/cli.rb in git_topic-0.1.0 vs lib/git_topic/cli.rb in git_topic-0.2.0
- old
+ new
@@ -1,19 +1,27 @@
require 'thor'
require 'open3'
+require 'git_topic/version'
require 'git_topic/commands/list'
require 'git_topic/commands/edit'
require 'git_topic/commands/show'
module GitTopic
# CLI command entry point
class Cli < Thor
default_command :list
desc 'list', 'Show managed topics'
+ option :version, aliases: 'v'
def list
+ # Show version if -v specified
+ if options[:version]
+ version and return if options[:version]
+ return
+ end
+
command = GitTopic::Commands::List.new
command.execute
end
desc 'edit [branch_name]', 'Edit topic description'
@@ -24,9 +32,14 @@
desc 'show [branch_name]', 'Show topic description'
def show(branch_name = nil)
command = GitTopic::Commands::Show.new branch_name
command.execute
+ end
+
+ desc 'version', 'Show version'
+ def version
+ puts GitTopic::VERSION
end
desc 'add topic_name', 'Remember topic'
def add(topic_name)
puts "add #{topic_name}"