Class: GitLogTime::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/git-log-time/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Cli

Returns a new instance of Cli.



10
11
12
# File 'lib/git-log-time/cli.rb', line 10

def initialize(*args)
  @args = args
end

Instance Method Details

#configObject



48
49
50
# File 'lib/git-log-time/cli.rb', line 48

def config
  @config ||= GitLogTime::Configuration.new(GitLogTime.pluginator)
end

#executeObject



14
15
16
17
18
19
20
21
# File 'lib/git-log-time/cli.rb', line 14

def execute()
  action_name = @args.shift or 'help'
  action = :"execute_#{action_name}"
  if respond_to?(action)
  then send(action, *@args)
  else execute_help(action_name, *@args)
  end
end

#execute_help(*args) ⇒ Object



23
24
25
26
27
# File 'lib/git-log-time/cli.rb', line 23

def execute_help(*args)
  warn "Usage: git-log-time install"
  warn "Usage: git-log-time uninstall"
  args.empty? # return status, it's ok if user requested help
end

#execute_install(key = nil, *args) ⇒ Object



29
30
31
32
33
# File 'lib/git-log-time/cli.rb', line 29

def execute_install(key = nil, *args)
  ['post-commit', 'pre-push' ].each do |key|
    GitLogTime::Installer.new(key).install
  end
end

#execute_new(*args) ⇒ Object



41
42
43
44
45
46
# File 'lib/git-log-time/cli.rb', line 41

def execute_new(*args)
  GitLogTime::Template.new(*args).save
rescue ArgumentError => e
  warn e
  warn "Usage: git-log-time new plugin-name 'Author Name' author@email 'description of the plugin'"
end

#execute_uninstall(key = nil, *args) ⇒ Object



35
36
37
38
39
# File 'lib/git-log-time/cli.rb', line 35

def execute_uninstall(key = nil, *args)
  ['post-commit', 'pre-push' ].each do |key|
    GitLogTime::Installer.new(key).uninstall
  end
end

#list_evaluatorObject



52
53
54
# File 'lib/git-log-time/cli.rb', line 52

def list_evaluator
  @list_evaluator ||= GitLogTime::ListEvaluator.new(config)
end