Class: Worklog::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Utilities
Defined in:
lib/git/worklog.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#default_git_email, #default_git_user, #default_git_username, #pwd, #repos, #root_repository_name, #user

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/git/worklog.rb', line 51

def self.exit_on_failure?
  true
end

Instance Method Details

#showObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/git/worklog.rb', line 65

def show
  commits = {}
  git_command = "git --no-pager log --exclude=refs/stash --pretty=oneline --date=short --since=#{options[:days] || 7}.days --author=\"#{user(options[:user])}\" --all"
  repos.each do |repo|
    repo_name = repo.split("/").last
    output = `cd #{repo} && #{git_command}`
    commits[repo_name] = output
    system("cd #{pwd}")
  end
  commits = commits.filter { |key, value| value != ""}
  commits.map do |key, value|
    if key == "."
      puts "\n\n---------------- PROJECT: #{root_repository_name} -----------------\n\n"
    else
      puts "\n\n---------------- PROJECT: #{key} -----------------\n\n"
    end
    puts value
  end
end