Class: Command::Help

Inherits:
CommandBase show all
Defined in:
lib/command/help.rb

Constant Summary collapse

HEADER =
"Narou.rb ― 小説家になろうダウンローダ&縦書き用整形スクリプト"

Instance Method Summary collapse

Methods inherited from CommandBase

execute!, #initialize, #load_local_settings

Constructor Details

This class inherits a constructor from Command::CommandBase

Instance Method Details

#display_helpObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/command/help.rb', line 22

def display_help
  puts HEADER
  puts
  puts " <bold><green>Usage: narou &lt;command&gt; [arguments...] [options...] [--no-color]</green></bold>".termcolor
  puts
  puts " コマンドの簡単な説明:"
  cmd_list = Command.get_list
  cmd_list.each do |key, command|
    oneline = command.oneline_help.split("\n")
    puts "   <bold><green>#{key.ljust(12)}</green></bold> #{oneline.shift}".termcolor
    oneline.each do |h|
      puts " " * 16 + h
    end
  end
  puts
  puts "  各コマンドの詳細は narou <command> -h/--help を参照してください。"
  puts "  各コマンドは先頭の一文字か二文字でも指定できます。"
  puts "  (e.g. `narou <bold><yellow>d</yellow></bold> n4259s', `narou <bold><yellow>fr</yellow></bold> musyoku')".termcolor
  puts "  表示の色は--no-colorとオプションを付けるか`narou s no-color=true'で消せます。".termcolor
end

#display_help_first_timeObject



43
44
45
46
47
48
49
50
# File 'lib/command/help.rb', line 43

def display_help_first_time
  puts HEADER
  puts
  puts " <bold><green>Usage: narou init</green></bold>".termcolor
  puts
  puts "   まだこのフォルダは初期化されていません。"
  puts "   <bold><yellow>narou init</yellow></bold> コマンドを実行して初期化を行いましょう。".termcolor
end

#execute(argv) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/command/help.rb', line 14

def execute(argv)
  if Narou.already_init?
    display_help
  else
    display_help_first_time
  end
end

#oneline_helpObject



10
11
12
# File 'lib/command/help.rb', line 10

def oneline_help
  "このヘルプを表示します"
end