class AssistedWorkflow::CLI

Constants

GLOBAL_CONFIG
LOCAL_CONFIG

Public Class Methods

start(given_args=ARGV, config={}) click to toggle source
Calls superclass method
# File lib/assisted_workflow/cli.rb, line 133
def start(given_args=ARGV, config={})
  super
rescue AssistedWorkflow::Error => e
  config[:shell].say e.message, :red
  exit(1)
end

Public Instance Methods

config(*args) click to toggle source
# File lib/assisted_workflow/cli.rb, line 85
def config(*args)
  if args.empty?
    print_table configuration.to_hash
  else
    config_file.parse(args).save!
  end
end
config_file() click to toggle source
# File lib/assisted_workflow/cli.rb, line 118
def config_file
  @config_file ||= ConfigFile.new(awfile)
end
configuration() click to toggle source

loads all configuration, merging global and local values

# File lib/assisted_workflow/cli.rb, line 123
def configuration
  @configuration ||= begin
    ConfigFile.new(GLOBAL_CONFIG).merge_file(LOCAL_CONFIG)
  rescue TypeError
    raise AssistedWorkflow::Error, "Error on loading .awconfig files. Please check the content format."
  end
end
finish() click to toggle source
# File lib/assisted_workflow/cli.rb, line 68
def finish
  check_awfile!
  unless story_id = git.current_story_id
    raise AssistedWorkflow::Error, "story not found, make sure a feature branch in active"
  end
  git.check_merged!
  git.remove_branch
  out.next_command "well done! check your next stories using:", "$ aw start"
end
git() click to toggle source
# File lib/assisted_workflow/cli.rb, line 108
def git
  @git ||= Addons::Git.new(out)
end
github() click to toggle source
# File lib/assisted_workflow/cli.rb, line 112
def github
  @github ||= Addons::Github.new(out, 
    {"repository" => git.repository}.merge(configuration[:github])
  )
end
out() click to toggle source
# File lib/assisted_workflow/cli.rb, line 100
def out
  @out ||= Output.new(self.shell)
end
setup() click to toggle source
# File lib/assisted_workflow/cli.rb, line 18
def setup
  copy_file "awconfig.global.tt", GLOBAL_CONFIG
  copy_file "awconfig.local.tt", LOCAL_CONFIG
  if File.exists?(".git")
    copy_file "commit-msg.tt", ".git/hooks/commit-msg"
    chmod ".git/hooks/commit-msg", "a+x"
  else
    raise AssistedWorkflow::Error, ".git folder not found"
  end
  out.next_command "set your own configuration running:", "" do |c|
    c << "$ aw config pivotal.fullname='Your Pivotal User Name' --global"
    c << "$ aw config pivotal.token=MYPIVOTALTOKEN --global"
    c << "$ aw config github.token=MYGITHUBOAUTHTOKEN --global"
    c << "$ aw config branch_username='Username for branch names' --global"
    c << "$ aw config pivotal.project_id=00001"
  end
end
start(story_id=nil) click to toggle source
# File lib/assisted_workflow/cli.rb, line 39
def start(story_id=nil)
  check_awfile!
  story = tracker.find_story(story_id)
  if story.nil?
    stories = tracker.pending_stories(:include_started => options[:all])
    out.print_stories "pending stories", stories, options
    out.next_command "start a story using:", "$ aw start [STORY_ID]"
  else
    tracker.start_story(story, :estimate => options[:estimate])
    out.print_story story
    git.create_story_branch(story, configuration[:branch_username])
    out.next_command "after commiting your changes, submit a pull request using:", "$ aw submit"
  end
end
submit() click to toggle source
# File lib/assisted_workflow/cli.rb, line 55
def submit
  check_awfile!
  story_id = git.current_story_id
  unless story = tracker.find_story(story_id)
    raise AssistedWorkflow::Error, "story not found, make sure a feature branch in active"
  end
  git.rebase_and_push
  pr_url = github.create_pull_request(git.current_branch, story)
  tracker.finish_story(story, :note => pr_url)
  out.next_command "after pull request approval, remove the feature branch using:", "$ aw finish"
end
thanks() click to toggle source
# File lib/assisted_workflow/cli.rb, line 94
def thanks
  out.say "you're welcome!", :on_magenta
end
tracker() click to toggle source
# File lib/assisted_workflow/cli.rb, line 104
def tracker
  @tracker ||= Addons.load_tracker(out, configuration) || github
end
version() click to toggle source
# File lib/assisted_workflow/cli.rb, line 79
def version
  say AssistedWorkflow::VERSION
end