Class: Resumer::CLI

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/resumer.rb

Overview

Commander CLI interface

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



15
16
17
18
19
20
21
# File 'lib/resumer.rb', line 15

def initialize
  program :name, Resumer::PKG
  program :version, Resumer::VERSION
  program :description, Resumer::DESCRIPTION
  program :help_formatter, :compact
  program :help, *Resumer::AUTHOR
end

Instance Method Details

#add_export_commandObject

rubocop:disable Metrics/MethodLength



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/resumer.rb', line 24

def add_export_command
  command :export do |c|
    c.option '-c', '--config FILE', 'Load a custom configuration file'
    c.option '--format STRING', 'Destination format (HTML or PDF)'
    c.summary = 'Export a YAML resume to HTML or PDF format'
    c.syntax = "#{Resumer::BIN} export <source.yml> [destination.html|.pdf]"
    c.action do |args, options|
      Resumer::Command::Export.new(args, options).run
    rescue StandardError => e
      say "Error (#{e.class.name}): #{e.message}"
      exit 1
    end
  end
end

#runObject

rubocop:enable Metrics/MethodLength



40
41
42
43
44
45
46
47
# File 'lib/resumer.rb', line 40

def run
  default_command :usage
  add_command(Resumer::Command::Usage.new)
  add_command(Resumer::Command::Init.new)
  add_command(Resumer::Command::Validate.new)
  add_export_command
  run!
end