lib/git_topic/cli.rb in git_topic-0.3.3 vs lib/git_topic/cli.rb in git_topic-0.4.0

- old
+ new

@@ -7,25 +7,27 @@ require 'git_topic/commands/add' require 'git_topic/commands/delete' require 'git_topic/commands/edit' require 'git_topic/commands/list' require 'git_topic/commands/show' +require 'git_topic/commands/start' +require 'git_topic/commands/publish' module GitTopic # CLI command entry point class Cli < Thor default_command :list desc 'list', 'Show managed topics' option :version, aliases: 'v', desc: 'Show version' option :all, aliases: 'a', desc: 'Show all information' + option :edit, aliases: 'e', desc: 'Edit current topic description' def list # Show version if -v specified - if options[:version] - version if options[:version] - return - end + version && return if options[:version] + # Edit topic if -e specified + edit && return if options[:edit] command = GitTopic::Commands::List.new options command.execute end @@ -42,10 +44,11 @@ end desc 'version', 'Show version' def version puts GitTopic::VERSION + true end desc 'add topic_name summary', 'Remember topic' def add(topic_name, summary) command = GitTopic::Commands::Add.new topic_name, summary @@ -58,16 +61,19 @@ command.execute end desc 'start topic_name', 'Transfer topic_name to branch to implement code' def start(topic_name) - puts "start #{topic_name}" - raise 'not implemented' + command = GitTopic::Commands::Start.new topic_name + command.execute end - desc 'publish [branch_name]', 'Create pull request using branch description' - def publish(branch_name) - puts "publish #{branch_name}" - raise 'not implemented' + # rubocop:disable Metrics/LineLength + desc 'publish repo base branch_name', 'Create pull request using branch description' + # rubocop:enable Metrics/LineLength + def publish(repo, base, branch_name) + client = Octokit::Client.new(netrc: true) + command = GitTopic::Commands::Publish.new client, repo, branch_name, base + command.execute end end end