Class: Gistory::Cli::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/gistory/cli/main.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo_path:, args:, io: Gistory::Cli::Io.new) ⇒ Main

Returns a new instance of Main.



6
7
8
9
10
# File 'lib/gistory/cli/main.rb', line 6

def initialize(repo_path:, args:, io: Gistory::Cli::Io.new)
  @repo_path = repo_path
  @args = args
  @io = io
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gistory/cli/main.rb', line 12

def run
  repo = GitRepo.new(path: @repo_path)
  parser = Cli::ArgParser.new(args: @args, io: @io)
  config = parser.parse
  history(repo, config.gem_name)
rescue Gistory::ParserError => e
  @io.error e.message
  @io.puts parser
rescue Gistory::Error => e
  @io.error e.message
end