Class: Michael::Commands::Repos

Inherits:
Thor
  • Object
show all
Defined in:
lib/michael/commands/repos.rb,
lib/michael/commands/repos/edit.rb,
lib/michael/commands/repos/pull_requests.rb

Defined Under Namespace

Classes: Edit, PullRequests

Instance Method Summary collapse

Instance Method Details

#editObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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

#prsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 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