Class: Milestoner::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, ThorPlus::Actions
Defined in:
lib/milestoner/cli.rb

Overview

The Command Line Interface (CLI) for the gem.

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
18
19
20
# File 'lib/milestoner/cli.rb', line 14

def initialize args = [], options = {}, config = {}
  super args, options, config
  @configuration = Milestoner::Configuration.new Milestoner::Identity.file_name, defaults: defaults
  @tagger = Milestoner::Tagger.new configuration.settings[:version],
                                   commit_prefixes: configuration.settings[:git_commit_prefixes]
  @pusher = Milestoner::Pusher.new
end

Instance Method Details

#commitsObject



24
25
26
27
28
# File 'lib/milestoner/cli.rb', line 24

def commits
  tagger.commit_list.each { |commit| say commit }
rescue Milestoner::Errors::Base => base_error
  error base_error.message
end

#editObject



60
61
62
63
# File 'lib/milestoner/cli.rb', line 60

def edit
  info "Editing: #{configuration.computed_file_path}..."
  `#{editor} #{configuration.computed_file_path}`
end

#help(task = nil) ⇒ Object



73
74
75
# File 'lib/milestoner/cli.rb', line 73

def help task = nil
  say && super
end

#publish(version = ) ⇒ Object



52
53
54
55
56
# File 'lib/milestoner/cli.rb', line 52

def publish version = configuration.settings[:version]
  tag_and_push version, options
rescue Milestoner::Errors::Base => base_error
  error base_error.message
end

#pushObject



42
43
44
45
46
47
# File 'lib/milestoner/cli.rb', line 42

def push
  pusher.push
  info "Tags pushed to remote repository."
rescue Milestoner::Errors::Base => base_error
  error base_error.message
end

#tag(version = ) ⇒ Object



33
34
35
36
37
38
# File 'lib/milestoner/cli.rb', line 33

def tag version = configuration.settings[:version]
  tagger.create version, sign: sign_tag?(options[:sign])
  say "Repository tagged: #{tagger.version_label}."
rescue Milestoner::Errors::Base => base_error
  error base_error.message
end

#versionObject



67
68
69
# File 'lib/milestoner/cli.rb', line 67

def version
  say Milestoner::Identity.version_label
end