Class: Command::Help

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from CommandBase

#stream_io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommandBase

#disable_logging, #display_help!, #execute!, execute!, #force_change_settings_function, help, #hook_call, #initialize, #load_local_settings, #tagname_to_ids

Constructor Details

This class inherits a constructor from Command::CommandBase

Class Method Details

.oneline_helpObject



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

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

Instance Method Details

#display_helpObject



24
25
26
27
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
53
# File 'lib/command/help.rb', line 24

def display_help
  stream_io.puts("    \#{HEADER}\n\n     <bold><green>Usage: narou &lt;command&gt; [arguments...] [options...]\n                  [--no-color] [--multiple] [--time] [--backtrace]</green></bold>\n\n     \u30B3\u30DE\u30F3\u30C9\u306E\u7C21\u5358\u306A\u8AAC\u660E:\n  HELP\n  cmd_list = Command.get_list\n  cmd_list.each do |key, command|\n    oneline = command.oneline_help.split(\"\\n\")\n    stream_io.puts \"   <bold><green>\#{key.ljust(12)}</green></bold> \#{oneline.shift}\".termcolor\n    oneline.each do |h|\n      stream_io.puts \" \" * 16 + h\n    end\n  end\n  stream_io.puts(<<-HELP.termcolor)\n\n  \u5404\u30B3\u30DE\u30F3\u30C9\u306E\u8A73\u7D30\u306F narou &lt;command&gt; -h \u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n  \u5404\u30B3\u30DE\u30F3\u30C9\u306F\u5148\u982D\u306E\u4E00\u6587\u5B57\u304B\u4E8C\u6587\u5B57\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n  (e.g. `narou <bold><yellow>d</yellow></bold> n4259s', `narou <bold><yellow>fr</yellow></bold> musyoku')\n\n  <underline><bold>Global Options:</bold></underline>\n--no-color   \u30AB\u30E9\u30FC\u8868\u793A\u3092\u7121\u52B9\u306B\u3059\u308B\n--multiple   \u5F15\u6570\u306E\u533A\u5207\u308A\u306B\u30B9\u30DA\u30FC\u30B9\u306E\u4ED6\u306B\",\"\u3082\u4F7F\u3048\u308B\u3088\u3046\u306B\u3059\u308B\n--time       \u5B9F\u884C\u6642\u9593\u8868\u793A\n--backtrace  \u30A8\u30E9\u30FC\u767A\u751F\u6642\u8A73\u7D30\u60C5\u5831\u3092\u8868\u793A\n  HELP\nend\n".termcolor)

#display_help_first_timeObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/command/help.rb', line 55

def display_help_first_time
  stream_io.puts("    \#{HEADER}\n\n     <bold><green>Usage: narou init</green></bold>\n\n       \u307E\u3060\u3053\u306E\u30D5\u30A9\u30EB\u30C0\u306F\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\n       <bold><yellow>narou init</yellow></bold> \u30B3\u30DE\u30F3\u30C9\u3092\u5B9F\u884C\u3057\u3066\u521D\u671F\u5316\u3092\u884C\u3044\u307E\u3057\u3087\u3046\u3002\n  HELP\nend\n".termcolor)

#execute(_argv) ⇒ Object



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

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