class Michael::Commands::Repos

Public Instance Methods

edit(*) click to toggle source
# File lib/michael/commands/repos.rb, line 21
def edit(*)
  if options[:help]
    invoke :help, ['edit']
  else
    require_relative 'repos/edit'
    ttycfg = TTY::Config.new
    ttycfg.append_path(Michael::CONFIG_DIR_ABSOLUTE_PATH)
    ttycfg.filename = Michael::CONFIG_FILENAME

    ttycfgrepos = TTY::Config.new
    ttycfgrepos.append_path(Michael::CONFIG_DIR_ABSOLUTE_PATH)
    ttycfgrepos.filename = Michael::CONFIG_REPOS_FILENAME

    cfg = Michael::Services::Configuration.new(ttycfg)
    repocfg = Michael::Services::Configuration.new(ttycfgrepos)

    token = Michael::Services::Github::Token.new(cfg)
    token.validate(cfg.fetch(:token))

    repos_filepath = Michael::CONFIG_DIR_ABSOLUTE_PATH + '/' + Michael::CONFIG_REPOS_FILENAME + '.yml'
    Michael::Commands::Repos::Edit.new(repos_filepath, repocfg, TTY::Editor, options).execute
  end
end
prs(*) click to toggle source
# File lib/michael/commands/repos.rb, line 62
def prs(*)
  if options[:help]
    invoke :help, ['prs']
  else
    require_relative 'repos/pull_requests'
    ttycfgrepos = TTY::Config.new
    ttycfgrepos.append_path(Michael::CONFIG_DIR_ABSOLUTE_PATH)
    ttycfgrepos.filename = Michael::CONFIG_REPOS_FILENAME

    ttycfgtkn = TTY::Config.new
    ttycfgtkn.append_path(Michael::CONFIG_DIR_ABSOLUTE_PATH)
    ttycfgtkn.filename = Michael::CONFIG_FILENAME

    repocfg = Michael::Services::Configuration.new(ttycfgrepos)
    tkncfg = Michael::Services::Configuration.new(ttycfgtkn)

    prs = Michael::Services::Github::PullRequests.new(tkncfg)
    users = Michael::Services::Github::Users.new(tkncfg)
    repos = Michael::Services::Repositories.new(prs)
    Michael::Commands::Repos::PullRequests.new(repocfg, users, repos, options).execute
  end
end