Class: Nanoc3::CLI::Commands::Help

  • Cri::Command
    • Nanoc3::CLI::Commands::Help

Public Visibility

Public Instance Method Summary

#aliases
#long_desc
#name
#run(options, arguments)
#short_desc
#usage

Public Instance Method Details

aliases

public aliases
[View source]


11
12
13
# File 'lib/nanoc3/cli/commands/help.rb', line 11

def aliases
  []
end

long_desc

public long_desc
[View source]


19
20
21
22
23
24
25
# File 'lib/nanoc3/cli/commands/help.rb', line 19

def long_desc
  'Show help for the given command, or show general help. When no ' +
  'command is given, a list of available commands is displayed, as ' +
  'well as a list of global commandline options. When a command is ' +
  'given, a command description as well as command-specific ' +
  'commandline options are shown.'
end

name

public name
[View source]


7
8
9
# File 'lib/nanoc3/cli/commands/help.rb', line 7

def name
  'help'
end

run

public run(options, arguments)
[View source]


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/nanoc3/cli/commands/help.rb', line 31

def run(options, arguments)
  # Check arguments
  if arguments.size > 1
    $stderr.puts "usage: #{usage}"
    exit 1
  end

  if arguments.length == 0
    # Build help text
    text = ''

    # Add title
    text << "nanoc, a static site compiler written in Ruby.\n"

    # Add available commands
    text << "\n"
    text << "Available commands:\n"
    text << "\n"
    @base.commands.sort.each do |command|
      text << sprintf("    %-20s %s\n", command.name, command.short_desc)
    end

    # Add global options
    text << "\n"
    text << "Global options:\n"
    text << "\n"
    @base.global_option_definitions.sort { |x,y| x[:long] <=> y[:long] }.each do |opt_def|
      text << sprintf("    -%1s --%-15s %s\n", opt_def[:short], opt_def[:long], opt_def[:desc])
    end

    # Display text
    puts text
  elsif arguments.length == 1
    command = @base.command_named(arguments[0])
    puts command.help
  end
end

short_desc

public short_desc
[View source]


15
16
17
# File 'lib/nanoc3/cli/commands/help.rb', line 15

def short_desc
  'show help for a command'
end

usage

public usage
[View source]


27
28
29
# File 'lib/nanoc3/cli/commands/help.rb', line 27

def usage
  "nanoc3 help [command]"
end
Generated on Sunday, August 09 2009 at 01:43:06 PM by YARD 0.2.3.2 (ruby-1.8.7).