magellan-cli 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c33ee36cf2a036e44f83936430b41069da6652
4
- data.tar.gz: fff038dcf11eaf7803f3907337830193904d57e1
3
+ metadata.gz: 6866ac1eb4257aa70ffe11c82edc26493a786fb6
4
+ data.tar.gz: bf38863f6b051a386a66c33d2b8df394d2241a63
5
5
  SHA512:
6
- metadata.gz: f842ef103745ff900ffb4c6c814192bd33b6d30f65de08a62224e2039f901369da12b36c4e1589b90b4a4209bcc2034e2bd356238398a37fc04fa72242d8c0ab
7
- data.tar.gz: 9766570f91bca86217cdff7a33a89b948ab24a0351f439f6d29e21d5523293b260cf71a9760bc90228ba6b5eafaee3fe728158b7a6c7c85efd0103482fff7ac1
6
+ metadata.gz: 459749e482a36da9f0faad00e657688533ecde77c058cace932978b0fdd21919b3f45793820249087e5de6b2d8224f7b285a7f8e63e6a6d2dcc911b1bc9869e9
7
+ data.tar.gz: 0dcf7832d2e8bdb368a97bb8232cc478083262623d3a70a26147b850e031b9177216ebdfd4bd204043680bdf0cf84d238c96fdc51585be6ece307799ee9f55a8
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.3.2)
4
+ magellan-cli (0.3.3)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
8
+ i18n
8
9
  nokogiri
9
10
  text-table (~> 1.2.3)
10
11
 
@@ -30,7 +31,7 @@ GEM
30
31
  groovenauts-thor (0.19.1)
31
32
  httpclient (2.6.0.1)
32
33
  i18n (0.7.0)
33
- json (1.8.1)
34
+ json (1.8.2)
34
35
  method_source (0.8.2)
35
36
  mini_portile (0.6.2)
36
37
  minitest (5.5.0)
data/README.md CHANGED
@@ -22,7 +22,9 @@ Or install it yourself as:
22
22
  ## generate reference pages
23
23
 
24
24
  ```
25
- DEST=/path/to/magellan-devcenter.github.io bundle exec rake reference
25
+ export DEVCENTER_DIR=/path/to/magellan-devcenter.github.io
26
+ LANG=en DEST=$DEVCENTER_DIR SUBDIR=reference/magellan-cli/$LANG bundle exec rake reference
27
+ LANG=ja DEST=$DEVCENTER_DIR SUBDIR=reference/magellan-cli/$LANG bundle exec rake reference
26
28
  ```
27
29
 
28
30
  then
@@ -32,7 +34,8 @@ cd /path/to/magellan-devcenter.github.io
32
34
  bundle exec jekyll serve
33
35
  ```
34
36
 
35
- open http://localhost:4000/reference/magellan-cli
37
+ open http://localhost:4000/reference/magellan-cli/en
38
+ open http://localhost:4000/reference/magellan-cli/ja
36
39
 
37
40
  After check the pages, you can commit the .md files to magellan-devcenter.github.io repogitory.
38
41
 
@@ -111,8 +111,15 @@ module Magellan
111
111
  return list
112
112
  end
113
113
 
114
+ def update_common_help_message
115
+ if cmd = all_commands["help"]
116
+ cmd.description = I18n.t(:help, scope: [:base, :cmd])
117
+ end
118
+ end
119
+
114
120
  # overwrite Thor.help method
115
121
  def help(shell, subcommand = false)
122
+ update_common_help_message
116
123
  if defined?(@package_name) && @package_name
117
124
  shell.say "#{@package_name} commands:"
118
125
  else
@@ -37,13 +37,13 @@ module Magellan
37
37
  shell.say
38
38
  shell.say "RESOURCES:"
39
39
  shell.say " " << Resources::MAPPING.keys.join(", ")
40
- shell.say " type `#{File.basename($0)} help RESOURCE` for more detail"
40
+ shell.say " " << I18n.t(:for_more_detail, scope: [:command, :cmd_help], command: File.basename($0))
41
41
  shell.say
42
42
  end
43
43
  end
44
44
 
45
45
  Resources::MAPPING.each do |classname, name|
46
- desc "#{name} SUBCOMMAND ...ARGS", "Manage #{name.pluralize}"
46
+ desc "#{name} SUBCOMMAND ...ARGS", I18n.t(:manage_resource, scope: [:command, :cmd], resource: name.pluralize)
47
47
  subcommand name, ::Magellan::Cli::Resources.const_get(classname)
48
48
  end
49
49
 
@@ -52,9 +52,9 @@ module Magellan
52
52
  #desc "direct SUBCOMMAND ...ARGS", "Send request directly"
53
53
  #subcommand "direct", ::Magellan::Cli::Direct
54
54
 
55
- desc "login", "Login to the Magellan server"
56
- method_option :email, aliases: "-e", desc: "email address for login"
57
- method_option :password, aliases: "-p", desc: "password for login"
55
+ desc "login", I18n.t(:login, scope: [:command, :cmd])
56
+ method_option :email, aliases: "-e", desc: I18n.t(:email, scope: [:command, :cmd_login])
57
+ method_option :password, aliases: "-p", desc: I18n.t(:password, scope: [:command, :cmd_login])
58
58
  def login
59
59
  unless email = options[:email]
60
60
  print "email: "
@@ -70,7 +70,7 @@ module Magellan
70
70
  Magellan::Cli::Http.new.login!(email, password)
71
71
  end
72
72
 
73
- desc "info", "Show login user and selected resources"
73
+ desc "info", I18n.t(:info, scope: [:command, :cmd])
74
74
  def info
75
75
  cli = Magellan::Cli::Login.new
76
76
  cli.check_login_auth!
@@ -29,7 +29,7 @@ module Magellan
29
29
  end
30
30
  sel = load_selections
31
31
  s = sel[name]
32
- raise NotSelected, "No #{label} selected" unless s
32
+ raise NotSelected, I18n.t(:not_selected, scope: [:file_access, :load_selection], label: label) unless s
33
33
  return s
34
34
  end
35
35
 
@@ -14,9 +14,9 @@ module Magellan
14
14
  def login!(email, password)
15
15
  logined = cli.api_login!(email, password)
16
16
  if logined
17
- log_success("OK")
17
+ log_success I18n.t(:success, scope: [:http, :login])
18
18
  else
19
- log_error("Login Failure.")
19
+ log_error I18n.t(:error, scope: [:http, :login])
20
20
  end
21
21
  end
22
22
 
@@ -25,7 +25,7 @@ module Magellan
25
25
  cli.check_login_auth!
26
26
  return yield(cli)
27
27
  else
28
- return log_success("OK")
28
+ return log_success(I18n.t(:ok, scope: [:http, :access_api]))
29
29
  end
30
30
  end
31
31
 
@@ -0,0 +1,12 @@
1
+ require 'i18n'
2
+
3
+ I18n.config.backend.load_translations(*Dir.glob(File.expand_path("../locales/*.yml", __FILE__)))
4
+
5
+ if current_locale = ENV["LANG"]
6
+ I18n.config.backend.available_locales.each do |locale|
7
+ if current_locale =~ /\A#{locale}/
8
+ I18n.config.locale = locale
9
+ break
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,71 @@
1
+ en:
2
+ base:
3
+ cmd:
4
+ help: "Describe available commands or one specific command"
5
+ command:
6
+ cmd:
7
+ manage_resource: "Manage %{resource}"
8
+ login: "Login to the Magellan server"
9
+ info: "Show login user and selected resources"
10
+ cmd_login:
11
+ email: "email address for login"
12
+ password: "password for login"
13
+ cmd_help:
14
+ for_more_detail: "type `%{command} help RESOURCE` for more detail"
15
+ file_access:
16
+ load_selection:
17
+ not_selected: "No %{label} selected"
18
+ http:
19
+ login:
20
+ succes: "Logged in"
21
+ error: "Login failure"
22
+ access_api:
23
+ ok: "OK"
24
+ login:
25
+ check_login_auth:
26
+ not_logged_in: "Not logined yet. type `%{command} login`."
27
+ resources_base:
28
+ default_query:
29
+ not_selected: "No %{label} selected"
30
+ get_first_result:
31
+ not_found: "%{name} not found by using %{query}"
32
+ resources_common:
33
+ cmd:
34
+ create: "Create a new %{resource_name} with NAME"
35
+ delete: "Delete the %{resource_name} specified by NAME"
36
+ update: "Update the ATTRIBUTES of the selected %{resource_name}"
37
+ list: "Show a list of the %{res_names}"
38
+ show: "Show the detail of the %{res_name} specified by ID"
39
+ select: "Select the %{res_name} by NAME"
40
+ deselect: "Deselect the %{res_name}"
41
+ client_version:
42
+ cmd:
43
+ create: "Create a new %{resource_name} with VERSION"
44
+ delete: "Delete the %{resource_name} specified by VERSION"
45
+ stage:
46
+ cmd:
47
+ planning: "Switch to planning to build next released version"
48
+ current: "Switch to current released version"
49
+ prepare: "Prepare the %{containers_name}"
50
+ repair: "Repair the %{resource_name} status"
51
+ release_now: "Release the changes now"
52
+ logs: "Fetch the logs of the %{workers_name}"
53
+ set_container_num: "Set the number of %{containers_name} for the selected %{image_name}"
54
+ reload: "Reload the last selections"
55
+ cmd_release_now:
56
+ async: "-A async mode. release_now returns soon"
57
+ interval: "-i polling interval(seconds)"
58
+ timeout: "-t timeout(seconds)"
59
+ team:
60
+ cmd:
61
+ create: "Create a new %{resource_name} with NAME and ROLE"
62
+ invite: "Invite a user to the %{resource_name}"
63
+ worker:
64
+ cmd:
65
+ create: "Create a new %{resource_name} with NAME and IMAGE"
66
+ update: "Update the ATTRIBUTES(filename or JSON) of the selected %{resource_name}"
67
+ prepare_images: "Prepare the %{images_name} for the selected %{worker_name}"
68
+ reference:
69
+ commands: "Commands"
70
+ global_options: "Global Options"
71
+ details: "Details"
@@ -0,0 +1,71 @@
1
+ ja:
2
+ base:
3
+ cmd:
4
+ help: "利用可能なコマンドの一覧か特定のコマンドの説明を表示します"
5
+ command:
6
+ cmd:
7
+ manage_resource: "%{resource}を操作します"
8
+ login: "MAGELLANのサーバにログインします"
9
+ info: "ログイン情報と選択されているリソースを表示します"
10
+ cmd_login:
11
+ email: "ログインするアカウントのメールアドレス"
12
+ password: "ログインするアカウントのパスワード"
13
+ cmd_help:
14
+ for_more_detail: "詳しくは `%{command} help RESOURCE` を実行してください"
15
+ file_access:
16
+ load_selection:
17
+ not_selected: "%{label}が選択されていません"
18
+ http:
19
+ login:
20
+ succes: "ログインしました"
21
+ error: "ログインに失敗しました"
22
+ access_api:
23
+ ok: "OK"
24
+ login:
25
+ check_login_auth:
26
+ not_logged_in: "ログインしていません。`%{command} login` を実行してログインしてください"
27
+ resources_base:
28
+ default_query:
29
+ not_selected: "%{label}が選択されていません"
30
+ get_first_result:
31
+ not_found: "%{name}は見つかりませんでした。クエリ %{query}"
32
+ resources_common:
33
+ cmd:
34
+ create: "NAMEを指定して%{resource_name}を登録します"
35
+ delete: "NAMEを指定して%{resource_name}を削除します"
36
+ update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します"
37
+ list: "%{res_names} の一覧を表示します"
38
+ show: "IDで指定された%{res_name}の詳細を表示します"
39
+ select: "NAMEを指定して%{res_name}を選択します"
40
+ deselect: "%{res_name}の選択を解除します"
41
+ client_version:
42
+ cmd:
43
+ create: "VERSIONを指定して%{resource_name}を登録します"
44
+ delete: "VERSIONを指定して%{resource_name}を削除します"
45
+ stage:
46
+ cmd:
47
+ planning: "次回リリースのステージの計画に切り替えます"
48
+ current: "現在リリースされているステージの情報に切り替えます"
49
+ prepare: "%{containers_name}を準備します"
50
+ repair: "%{resource_name}の状態を修正します"
51
+ release_now: "すぐにリリースを開始します"
52
+ logs: "%{workers_name}のログを表示します"
53
+ set_container_num: "選択された%{image_name}の%{containers_name}の数を設定します"
54
+ reload: "最後にselectされたものをロードし直します"
55
+ cmd_release_now:
56
+ async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
57
+ interval: "-i 状態を取得する間隔を秒で指定します"
58
+ timeout: "-t タイムアウトを秒で指定します"
59
+ team:
60
+ cmd:
61
+ create: "NAMEとROLEを指定して%{resource_name}を登録します"
62
+ invite: "%{resource_name}にユーザを招待します"
63
+ worker:
64
+ cmd:
65
+ create: "NAMEとIMAGEを指定して%{resource_name}を登録します"
66
+ update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します。ATTRIBUTESにはYAMLのファイル名かJSON文字列を指定可能です"
67
+ prepare_images: "選択された%{worker_name}の%{images_name}を準備します"
68
+ reference:
69
+ commands: "コマンドの一覧"
70
+ global_options: "共通オプション"
71
+ details: "コマンドの詳細"
@@ -59,7 +59,7 @@ module Magellan
59
59
  def check_login_auth!
60
60
  auth = login_auth
61
61
  if auth.nil? || auth.empty?
62
- raise Magellan::Cli::Error, "Not logined yet. type `#{File.basename($0)} login`."
62
+ raise Magellan::Cli::Error, I18n.t(:not_logged_in, scope: [:login, :check_login_auth], command: File.basename($0))
63
63
  end
64
64
  end
65
65
 
@@ -39,17 +39,21 @@ module Magellan
39
39
  end
40
40
 
41
41
  def process(klass, filename, res_name = nil)
42
+ if cmd = klass.all_commands["help"]
43
+ cmd.description = I18n.t(:help, scope: [:base, :cmd])
44
+ end
45
+
42
46
  path = File.expand_path(File.join(@subdir, filename), @dest)
43
47
  FileUtils.mkdir_p(File.dirname(path))
44
48
  instance = klass.new
45
49
  open(path, "w") do |f|
46
50
  f.puts "---"
47
51
  f.puts "layout: index"
48
- f.puts %!breadcrumb: <a href="/">Top</a> / <a href="/reference">Reference</a> / <a href="/reference/magellan-cli">magellan-cli</a> / magellan-cli #{res_name}!
52
+ f.puts %!breadcrumb: <a href="/">Top</a> / <a href="/reference">Reference</a> / <a href="/reference/magellan-cli">magellan-cli</a> / #{res_name}!
49
53
  f.puts "---"
50
54
  f.puts
51
55
 
52
- f.puts "## Commands"
56
+ f.puts "## "<< I18n.t(:commands, scope: :reference)
53
57
  f.puts
54
58
  klass.sorted_commands.each do |cmd|
55
59
  rel_path = Magellan::Cli::Resources::MAPPING.values.include?(cmd.name) ? "./#{cmd.name}.html" : "##{cmd.name}"
@@ -57,7 +61,7 @@ module Magellan
57
61
  end
58
62
  f.puts
59
63
 
60
- f.puts "## Global Options"
64
+ f.puts "## " << I18n.t(:global_options, scope: :reference)
61
65
  f.puts
62
66
  change_global_var_temporarily(["$stdout", f], ["$stderr", f]) do
63
67
  f.puts "```text"
@@ -67,7 +71,7 @@ module Magellan
67
71
  end
68
72
  f.puts
69
73
 
70
- f.puts "## Details"
74
+ f.puts "## " << I18n.t(:details, scope: :reference)
71
75
  klass.sorted_commands.each do |cmd|
72
76
  next if Magellan::Cli::Resources::MAPPING.values.include?(cmd.name)
73
77
  f.puts "### <a name=\"#{cmd.name}\"></a>#{cmd.name}"
@@ -46,7 +46,7 @@ module Magellan
46
46
  q = {}
47
47
  (self.class.resource_dependency || {}).each do |f, res|
48
48
  r = sel[res]
49
- raise NotSelected, "No #{f} selected" unless r
49
+ raise NotSelected, I18n.t(:not_selected, scope: [:resources_base, :default_query], label: f) unless r
50
50
  q[f] = r["id"]
51
51
  end
52
52
  build_query(q)
@@ -55,7 +55,7 @@ module Magellan
55
55
 
56
56
  def get_first_result!(name, path, query)
57
57
  results = get_json(path, query)
58
- raise NotFound, "#{name} not found for #{query.inspect}" if results.blank? || results.first.blank?
58
+ raise NotFound, I18n.t(:not_found, scope: [:resources_base, :get_first_result], name: name, query: query.inspect) if results.blank? || results.first.blank?
59
59
  results.first
60
60
  end
61
61
 
@@ -210,22 +210,22 @@ module Magellan
210
210
  end
211
211
  end
212
212
 
213
- desc "list", "Show a list of the #{res_name.pluralize}"
213
+ desc "list", "#{I18n.t(:list, scope: [:resources_common, :cmd], res_names: res_name.pluralize)}"
214
214
  def list
215
215
  super
216
216
  end
217
217
 
218
- desc "show ID", "Show the detail of the #{res_name} specified by ID"
218
+ desc "show ID", "#{I18n.t(:show, scope: [:resources_common, :cmd], res_name: res_name)}"
219
219
  def show(id)
220
220
  super(id)
221
221
  end
222
222
 
223
- desc "select NAME", "Select the #{res_name} by NAME"
223
+ desc "select NAME", "#{I18n.t(:select, scope: [:resources_common, :cmd], res_name: res_name)}"
224
224
  def select(name)
225
225
  super
226
226
  end
227
227
 
228
- desc "deselect", "Deselect the #{res_name}"
228
+ desc "deselect", "#{I18n.t(:deselect, scope: [:resources_common, :cmd], res_name: res_name)}"
229
229
  def deselect
230
230
  super
231
231
  end
@@ -14,7 +14,7 @@ module Magellan
14
14
  "stage_title_id" => {name: "stage", class: "Stage"},
15
15
  }
16
16
 
17
- desc "create VERSION", "Create a new #{resource_name}"
17
+ desc "create VERSION", I18n.t(:create, scope: [:client_version, :cmd], resource_name: resource_name)
18
18
  def create(version)
19
19
  stage = load_selection!(Stage)
20
20
  params = {
@@ -28,7 +28,7 @@ module Magellan
28
28
  # select(version)
29
29
  end
30
30
 
31
- desc "delete VERSION", "Delete the #{resource_name} specified by VERSION"
31
+ desc "delete VERSION", I18n.t(:delete, scope: [:client_version, :cmd], resource_name: resource_name)
32
32
  def delete(version)
33
33
  q = build_query("version" => version).update(default_query)
34
34
  r = get_first_result!(self.class.resource_name, "/admin/#{resource_key}.json", q)
@@ -12,7 +12,7 @@ module Magellan
12
12
  self.resource_dependency = {"stage" => Stage.parameter_name}
13
13
  self.hidden_fields = %w[cloudsql_instance_id].map(&:freeze).freeze
14
14
 
15
- desc "create NAME", "Create a new #{resource_name} database with NAME"
15
+ desc "create NAME", I18n.t(:create, scope: [:resources_common, :cmd], resource_name: "#{resource_name} database")
16
16
  def create(name)
17
17
  o = load_selection!(Stage)
18
18
  params = {
@@ -10,7 +10,7 @@ module Magellan
10
10
  def self.included(klass)
11
11
  klass.module_eval do
12
12
 
13
- desc "delete NAME", "Delete the #{resource_name} named by NAME"
13
+ desc "delete NAME", I18n.t(:delete, scope: [:resources_common, :cmd], resource_name: resource_name)
14
14
  def delete(name)
15
15
  q = build_query("name" => name).update(default_query)
16
16
  r = get_first_result!(self.class.resource_name, "/admin/#{resource_key}.json", q)
@@ -11,7 +11,7 @@ module Magellan
11
11
  self.resource_key = "magellan~auth~organization"
12
12
  # self.field_associations = {"creator_id" => {name: "creator", class: "User"} }
13
13
 
14
- desc "create NAME", "Create a new #{resource_name} with NAME"
14
+ desc "create NAME", I18n.t(:create, scope: [:resources_common, :cmd], resource_name: resource_name)
15
15
  def create(name)
16
16
  params = {
17
17
  parameter_name => {
@@ -13,14 +13,14 @@ module Magellan
13
13
  self.hidden_fields = %w[default_nebula_id created_at updated_at].map(&:freeze).freeze
14
14
  self.field_associations = {"organization_id" => {name: "organization", class: "Organization"} }
15
15
 
16
- desc "update ATTRIBUTES", "Update the ATTRIBUTES of the selected #{resource_name}"
16
+ desc "update ATTRIBUTES", I18n.t(:update, scope: [:resources_common, :cmd], resource_name: resource_name)
17
17
  def update(attrs)
18
18
  s = load_selection!(self.class)
19
19
  attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs)
20
20
  put_json("/admin/project/#{s['id']}/edit", {"project" => attrs})
21
21
  end
22
22
 
23
- desc "create NAME", "Create a new #{resource_name} with NAME"
23
+ desc "create NAME", I18n.t(:create, scope: [:resources_common, :cmd], resource_name: resource_name)
24
24
  def create(name)
25
25
  o = load_selection!(Organization)
26
26
  params = {
@@ -36,7 +36,7 @@ module Magellan
36
36
  select(name)
37
37
  end
38
38
 
39
- desc "select NAME", "Select the #{resource_name} named by NAME"
39
+ desc "select NAME", I18n.t(:select, scope: [:resources_common, :cmd], res_name: resource_name)
40
40
  def select(name)
41
41
  if selected = load_selections[parameter_name]
42
42
  deselect unless selected["name"] == name
@@ -54,7 +54,7 @@ module Magellan
54
54
  update_first_result(VERSION_PARAMETER_NAME, "/admin/stage~version.json", q, %w[id])
55
55
  end
56
56
 
57
- desc "deselect", "Deselect the #{resource_name}"
57
+ desc "deselect", I18n.t(:deselect, scope: [:resources_common, :cmd], res_name: resource_name)
58
58
  def deselect
59
59
  update_selections! do |s|
60
60
  s.delete(parameter_name)
@@ -63,12 +63,12 @@ module Magellan
63
63
  deselect_dependants
64
64
  end
65
65
 
66
- desc "planning", "Switch to planning to build next released version"
66
+ desc "planning", I18n.t(:planning, scope: [:stage, :cmd])
67
67
  def planning
68
68
  switch_version(1)
69
69
  end
70
70
 
71
- desc "current", "Switch to current released version"
71
+ desc "current", I18n.t(:current, scope: [:stage, :cmd])
72
72
  def current
73
73
  switch_version(2)
74
74
  end
@@ -81,7 +81,7 @@ module Magellan
81
81
  end
82
82
  end
83
83
 
84
- desc "prepare", "Prepare the #{Container.resource_name.pluralize}"
84
+ desc "prepare", I18n.t(:prepare, scope: [:stage, :cmd], containers_name: Container.resource_name.pluralize)
85
85
  def prepare
86
86
  s = load_selection!(self.class)
87
87
  id = s["id"]
@@ -89,7 +89,7 @@ module Magellan
89
89
  Container.new.show_list(r["result"])
90
90
  end
91
91
 
92
- desc "repair", "Repair the #{resource_name} status"
92
+ desc "repair", I18n.t(:repair, scope: [:stage, :cmd], resource_name: resource_name)
93
93
  def repair
94
94
  r = call_repair
95
95
  puts r["success"] ? "\e[32msucceeded to repair stage\e[0m" : "\e[31mfailed to repair stage\e[0m"
@@ -103,17 +103,17 @@ module Magellan
103
103
  end
104
104
  end
105
105
 
106
- desc "update ATTRIBUTES", "Update ATTRIBUTES of the #{resource_name}"
106
+ desc "update ATTRIBUTES", I18n.t(:update, scope: [:resources_common, :cmd], resource_name: resource_name)
107
107
  def update(attrs)
108
108
  s = load_selection!(self.class)
109
109
  attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs)
110
110
  put_json("/admin/stage~title/#{s['id']}/edit", {"stage_title" => attrs})
111
111
  end
112
112
 
113
- desc "release_now", "Release the changes now"
114
- option :A, type: :boolean, default: false, desc: "-A async mode. release_now returns soon"
115
- option :i, type: :numeric, default: 10, desc: "-i polling interval(seconds)"
116
- option :t, type: :numeric, default: 600, desc: "-t timeout(seconds)"
113
+ desc "release_now", I18n.t(:release_now, scope: [:stage, :cmd])
114
+ option :A, type: :boolean, default: false, desc: I18n.t(:async, scope: [:stage, :cmd_release_now])
115
+ option :i, type: :numeric, default: 10, desc: I18n.t(:interval, scope: [:stage, :cmd_release_now])
116
+ option :t, type: :numeric, default: 600, desc: I18n.t(:timeout, scope: [:stage, :cmd_release_now])
117
117
  def release_now
118
118
  spacer = "\r" << (" " * 20)
119
119
  stage = load_selection!(self.class)
@@ -166,7 +166,7 @@ module Magellan
166
166
  end
167
167
  end
168
168
 
169
- desc "logs", "Fetch the logs of the #{Worker.resource_name.pluralize}"
169
+ desc "logs", I18n.t(:logs, scope: [:stage, :cmd], workers_name: Worker.resource_name.pluralize)
170
170
  def logs
171
171
  s = load_selection!(self.class)
172
172
  id = s["id"]
@@ -178,7 +178,7 @@ module Magellan
178
178
  end
179
179
  end
180
180
 
181
- desc "set_container_num NUM", "Set the number of #{Container.resource_name.pluralize} for the selected #{Image.resource_name}"
181
+ desc "set_container_num NUM", I18n.t(:set_container_num, scope: [:stage, :cmd], containers_name: Container.resource_name.pluralize, image_name: Image.resource_name)
182
182
  def set_container_num(num)
183
183
  s = load_selection!(self.class)
184
184
  v = load_selection!(VERSION_PARAMETER_NAME)
@@ -186,7 +186,7 @@ module Magellan
186
186
  post_json("/admin/stage~version/#{v["id"]}/set_container_num.json", { container_num: num, container_image_id: i["id"] })
187
187
  end
188
188
 
189
- desc "reload", "Reload the last selections"
189
+ desc "reload", I18n.t(:reload, scope: [:stage, :cmd])
190
190
  def reload
191
191
  s = load_selection!(self.class)
192
192
  select(s["name"])
@@ -10,7 +10,7 @@ module Magellan
10
10
  self.resource_dependency = { "organization" => Organization.parameter_name }
11
11
  self.field_associations = {"organization_id" => {name: "organization", class: "Organization"} }
12
12
 
13
- desc "create NAME ROLE", "Create a new #{resource_name} with NAME and ROLE"
13
+ desc "create NAME ROLE", I18n.t(:create, scope: [:team, :cmd], resource_name: resource_name)
14
14
  def create(name, role)
15
15
  unless %w{ reader admin }.include?(role)
16
16
  raise "ROLE should be 'reader' or 'admin'"
@@ -28,7 +28,7 @@ module Magellan
28
28
  end
29
29
 
30
30
  =begin
31
- desc "invite EMAIL", "Invite a user to the #{Team.resource_name}"
31
+ desc "invite EMAIL", I18n.t(:invite, scope: [:team, :cmd], resource_name: resource_name)
32
32
  def invite(email)
33
33
  o = load_selection!(self.class)
34
34
  params = {
@@ -9,7 +9,7 @@ module Magellan
9
9
  self.resource_key = "functions~transaction_router"
10
10
  self.resource_dependency = {"stage" => Stage.parameter_name}
11
11
 
12
- desc "create NAME", "Create a new #{resource_name} with NAME"
12
+ desc "create NAME", I18n.t(:create, scope: [:resources_common, :cmd], resource_name: resource_name)
13
13
  def create(name)
14
14
  s = load_selection!(Stage::VERSION_PARAMETER_NAME)
15
15
  params = {
@@ -14,7 +14,7 @@ module Magellan
14
14
  self.multiline_fields = %w[migration_command_1 migration_command_2 run_command environment_vars_yaml].map(&:freeze).freeze
15
15
  self.field_associations = {"stage_version_id" => {name: "stage", resource: "stage~version"} }
16
16
 
17
- desc "create NAME, IMAGE", "Create a new #{resource_name} with NAME and IMAGE"
17
+ desc "create NAME IMAGE", I18n.t(:create, scope: [:worker, :cmd], resource_name: resource_name)
18
18
  method_option :attributes_yaml, aliases: "-A", desc: "path to YAML file which defines attributes"
19
19
  def create(name, image_name)
20
20
  s = load_selection!(Stage::VERSION_PARAMETER_NAME)
@@ -36,7 +36,7 @@ module Magellan
36
36
  select(name)
37
37
  end
38
38
 
39
- desc "update ATTRIBUTES", "Update the ATTRIBUTES(filename or JSON) of the selected #{resource_name}"
39
+ desc "update ATTRIBUTES", I18n.t(:update, scope: [:worker, :cmd], resource_name: resource_name)
40
40
  def update(attrs)
41
41
  if File.readable?(attrs)
42
42
  attrs = YAML.load_file(attrs)
@@ -52,7 +52,7 @@ module Magellan
52
52
  put_json("/admin/#{resource_key}/#{w["id"]}/edit.js", params)
53
53
  end
54
54
 
55
- desc "prepare_images", "Prepare the #{Image.resource_name.pluralize} for the selected #{Worker.resource_name}"
55
+ desc "prepare_images", I18n.t(:prepare_images, scope: [:worker, :cmd], images_name: Image.resource_name.pluralize, worker_name: Worker.resource_name)
56
56
  def prepare_images
57
57
  s = load_selection!(Worker)
58
58
  id = s["id"]
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
data/lib/magellan/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "magellan/cli/version"
2
+ require "magellan/cli/i18n"
2
3
 
3
4
  module Magellan
4
5
  module Cli
data/magellan-cli.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "nokogiri"
24
24
  spec.add_runtime_dependency "activesupport", "~> 4.1.4"
25
25
  spec.add_runtime_dependency "text-table", "~> 1.2.3"
26
+ spec.add_runtime_dependency "i18n"
26
27
 
27
28
  spec.add_development_dependency "bundler", "~> 1.6"
28
29
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm2000
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.2.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +161,9 @@ files:
147
161
  - lib/magellan/cli/errors.rb
148
162
  - lib/magellan/cli/file_access.rb
149
163
  - lib/magellan/cli/http.rb
164
+ - lib/magellan/cli/i18n.rb
165
+ - lib/magellan/cli/locales/en.yml
166
+ - lib/magellan/cli/locales/ja.yml
150
167
  - lib/magellan/cli/login.rb
151
168
  - lib/magellan/cli/reference_generator.rb
152
169
  - lib/magellan/cli/resources.rb