Module: Stic::CLI

Defined in:
lib/stic/cli.rb,
lib/stic/cli/command.rb

Defined Under Namespace

Classes: Build, Command

Class Method Summary collapse

Class Method Details

.helpObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/stic/cli.rb', line 28

def help
  $stdout.puts "    NAME\n          stic - The static site generator. v\#{Stic::VERSION}\n\n    SYNOPSIS\n          stic [command] [options]\n\n    DESCRIPTION\n          stic is a static site generation tool used to generate a set\n          of styled and linked HTML pages from different sources\n          like markdown.\n\n    GLOBAL OPTIONS\n          --help, -h\n              Print this help text.\n          --version, -v\n              Print stic version.\n\n    COMMANDS\n".gsub(/^ {10}/, '')
  parser.commands.each do |command|
    $stdout.puts command.to_help
  end
end

.parserObject



7
8
9
10
11
12
# File 'lib/stic/cli.rb', line 7

def parser
  @opt ||= ::Opt.new.tap do |opt|
    opt.option '--help, -h'
    opt.option '--version, -v'
  end
end

.run(argv) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stic/cli.rb', line 14

def run(argv)
  result = parser.parse(argv)

  if result.version
    $stdout.puts "stic v#{Stic::VERSION}"
    exit 0
  elsif result.help
    help
    exit 0
  else
    result.command.shift.run(result)
  end
end