Class: GitLogTime::Cli
- Inherits:
-
Object
- Object
- GitLogTime::Cli
- Defined in:
- lib/git-log-time/cli.rb
Instance Method Summary collapse
- #config ⇒ Object
- #execute ⇒ Object
- #execute_help(*args) ⇒ Object
- #execute_install(key = nil, *args) ⇒ Object
- #execute_new(*args) ⇒ Object
- #execute_uninstall(key = nil, *args) ⇒ Object
-
#initialize(*args) ⇒ Cli
constructor
A new instance of Cli.
- #list_evaluator ⇒ Object
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
#config ⇒ Object
48 49 50 |
# File 'lib/git-log-time/cli.rb', line 48 def config @config ||= GitLogTime::Configuration.new(GitLogTime.pluginator) end |
#execute ⇒ Object
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_evaluator ⇒ Object
52 53 54 |
# File 'lib/git-log-time/cli.rb', line 52 def list_evaluator @list_evaluator ||= GitLogTime::ListEvaluator.new(config) end |