Class: ModpackLocalizer::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/modpack_localizer/util/help.rb

Overview

ModpackLocalizer gemについてのヘルプを表示するクラス

Class Method Summary collapse

Class Method Details

.cyan(str) ⇒ String

出力を青色にする

Parameters:

  • str (String)

Returns:

  • (String)


128
129
130
# File 'lib/modpack_localizer/util/help.rb', line 128

def self.cyan(str)
  Rainbow(str).cyan
end

.green(str) ⇒ String

出力を緑色にする

Parameters:

  • str (String)

Returns:

  • (String)


136
137
138
# File 'lib/modpack_localizer/util/help.rb', line 136

def self.green(str)
  Rainbow(str).green
end

.helpvoid

This method returns an undefined value.

ModpackLocalizer gemについてのヘルプを表示する



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/modpack_localizer/util/help.rb', line 9

def self.help
  puts <<~HELP
    #{cyan("=== ModpackLocalizer Help ==========================================================").bold}\n
    #{help_warning}
    #{help_intro}
    #{help_steps}
    #{help_init_options}
    #{help_information}
    #{cyan("====================================================================================").bold}
  HELP
end

.help_informationString

その他gemに関する情報

Returns:

  • (String)


112
113
114
115
116
117
118
119
120
121
122
# File 'lib/modpack_localizer/util/help.rb', line 112

def self.help_information
  <<~INFORMATION
    #{cyan("Information:").bold}
      modpack_localizer:
        #{link("https://github.com/milkeclair/modpack_localizer")}
        current version: #{ModpackLocalizer::VERSION}
      translator:
        #{link("https://github.com/milkeclair/jp_translator_from_gpt")}
        current version: #{JpTranslatorFromGpt::VERSION}
  INFORMATION
end

.help_init_optionsString

newメソッドのオプション

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/modpack_localizer/util/help.rb', line 69

def self.help_init_options
  <<~OPTIONS
    #{cyan("ModpackLocalizer.omakase Options:").bold}
      language:
        Which language do you want to translate to?
        (default: Japanese)
      country:
        Your country name
        (default: Japan)
      locale_code:
        Which locale code do you want to use?
        If you specified this, you don't need to specify the country.
        (default: nil)
      threadable:
        Do you want to exec in parallel?
        (default: false)
    #{cyan("Initialize Options:").bold}
      output_logs:
        Want to output OpenAI usage logs?
        (default: true)
      except_words:
        Words that you don't want to translate
        (default: empty array)
      language:
        Which language do you want to translate to?
        (default: Japanese)
      display_help:
        Want to display help?
        (default: true)
    Only for jar performer:
      country:
        Your country name
        (default: Japan)
      locale_code:
        Which locale code do you want to use?
        If you specified this, you don't need to specify the country.
        (default: nil)
  OPTIONS
end

.help_introString

gemの説明

Returns:

  • (String)


33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/modpack_localizer/util/help.rb', line 33

def self.help_intro
  <<~INTRO
    #{cyan("Introduction:").bold}
      Translator for #{green(".snbt")} and #{green(".jar")} files.
      If you want to translate to other languages than Japanese,
      please add the #{green("language")} option during initialization.
      Example:
        #{green("ModpackLocalizer::SNBT::Performer.new(language: \"English\")")}
        #{green("ModpackLocalizer::JAR::Performer.new(language: \"English\")")}
        or if no specific configs required
        #{green("ModpackLocalizer.omakase(language: \"English\")")}
  INTRO
end

.help_stepsString

使用手順

Returns:

  • (String)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/modpack_localizer/util/help.rb', line 50

def self.help_steps
  <<~STEPS
    #{cyan("Steps:").bold}
      1. exec #{green("touch .env")} bash command
      2. Add #{green("OPENAI_API_KEY=your_api_key")} to .env
      3. Optional: Add #{green("OPENAI_MODEL=some_openai_model")} to .env (default: gpt-4o-mini)
      4. Add "quests" directory to your project
      5. #{green("gem install modpack_localizer")} or #{green("gem \"modpack_localizer\"")}
      6. Add #{green("require \"modpack_localizer\"")}
      7. Add #{green("modpack_localizer = ModpackLocalizer::SNBT::Performer.new")}
      8. #{green("modpack_localizer.perform(\"file_path\")")} or
         #{green("modpack_localizer.perform_directory(dir_path: \"dir_path\")")}
      9. Check "output" directory
  STEPS
end

.help_warningString

警告

Returns:

  • (String)


24
25
26
27
28
# File 'lib/modpack_localizer/util/help.rb', line 24

def self.help_warning
  <<~WARNING
    #{red("Warning:").bold} Please be careful your OpenAI API usage cost.
  WARNING
end

出力をリンクのスタイルにする

Parameters:

  • str (String)

Returns:

  • (String)


152
153
154
# File 'lib/modpack_localizer/util/help.rb', line 152

def self.link(str)
  Rainbow(str).underline.bright
end

.red(str) ⇒ String

出力を赤色にする

Parameters:

  • str (String)

Returns:

  • (String)


144
145
146
# File 'lib/modpack_localizer/util/help.rb', line 144

def self.red(str)
  Rainbow(str).red
end