Class: SnippetCli::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/snippet_cli/cli.rb

Overview

Handle the application command line parsing and the dispatch to various command objects

Constant Summary collapse

Error =

Error raised by this runner

Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/snippet_cli/cli.rb', line 11

def self.exit_on_failure?
  true
  puts "Something went wrong, try again."
end

Instance Method Details

#info(docs = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/snippet_cli/cli.rb', line 28

def info(docs = nil)
  if options[:help]
    invoke :help, ['info']
  else
    require_relative 'commands/info'
    SnippetCli::Commands::Info.new(docs, options).execute
  end
end

#newObject



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

def new(*)
  if options[:help]
    invoke :help, ['new']
  else
    require_relative 'commands/new'
    SnippetCli::Commands::New.new(options).execute
  end
end

#setupObject



52
53
54
55
56
57
58
59
# File 'lib/snippet_cli/cli.rb', line 52

def setup(*)
  if options[:help]
    invoke :help, ['setup']
  else
    require_relative 'commands/setup'
    SnippetCli::Commands::Setup.new().execute
  end
end

#versionObject



19
20
21
22
# File 'lib/snippet_cli/cli.rb', line 19

def version
  require_relative 'version'
  puts "v#{SnippetCli::VERSION}"
end