Sha256: b6304f565a66ef6b54be63d1dc622d93e612cb1ce50a067bacac3c71e48ea0ee
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
require "cp8_cli/version" require "cp8_cli/local_config" require "cp8_cli/global_config" require "cp8_cli/github/issue" require "cp8_cli/current_user" module Cp8Cli class Main def initialize(global_config = GlobalConfig.new, local_config = LocalConfig.new) Trello::Base.configure(key: global_config.trello_key, token: global_config.trello_token) Github::Base.configure(token: global_config.github_token) @local_config = local_config end def start(name) Command.error "Your `cp8_cli` version is out of date. Please run `gem update cp8_cli`." unless Version.latest? story = create_or_pick_story(name) story.assign(current_user) story.start Branch.from_story(user: current_user, story: story).checkout rescue Trello::Error => error Command.error(error.message) end def open Branch.current.open_story_in_browser end def finish(options = {}) branch = Branch.current branch.push branch.open_pull_request(options) end def cleanup Cleanup.new(Branch.current.target).run end private attr_reader :local_config def board @_board ||= local_config.board end def create_or_pick_story(name) if name.to_s.start_with?("https://github.com") Github::Issue.find_by_url(name) elsif name.to_s.start_with?("http") Trello::Card.find_by_url(name) elsif name.present? create_new_card(name) else pick_existing_card end end def create_new_card(name) label = Table.pick board.labels, caption: "Add label:" card = board.lists.backlog.cards.create name: name card.add_label(label) if label card end def pick_existing_card Table.pick board.lists.backlog.cards end def current_user @_current_user ||= CurrentUser.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cp8_cli-4.0.1 | lib/cp8_cli/main.rb |