Module: RedmineCLI::Helpers::Output
- Included in:
- Client, Input, Subcommands::Conf, Subcommands::Conf, Subcommands::Issue, Subcommands::Issue, Subcommands::Project, Subcommands::Project, Subcommands::User, Subcommands::User, TemplateRenderer::ErbEnvironment
- Defined in:
- lib/redmine_cli/helpers/output.rb
Overview
Helpers for output
Instance Method Summary collapse
-
#erb(template, vars = {}) ⇒ Object
Alias for TemplateRenderer#render.
-
#message(name, params = {}) ⇒ Object
(also: #m)
Gets text from I18n and replaces params e.g.
-
#print_object_list(list) ⇒ Object
for Helpers::Input.
-
#print_prompt_message(text, params = {}) ⇒ Object
for Helpers::Input.
Instance Method Details
#erb(template, vars = {}) ⇒ Object
Alias for TemplateRenderer#render
31 32 33 |
# File 'lib/redmine_cli/helpers/output.rb', line 31 def erb(template, vars = {}) RedmineCLI::TemplateRenderer.render(template, vars) end |
#message(name, params = {}) ⇒ Object Also known as: m
Gets text from I18n and replaces params e.g.
I18n.t(:hello) => 'Hello, {{ user }}'
(:hello, user: 'Vasya') => 'Hello, Vasya'
44 45 46 47 48 |
# File 'lib/redmine_cli/helpers/output.rb', line 44 def (name, params = {}) result = I18n.t name params.each { |k, e| result.gsub!("{{ #{k} }}", e.to_s) } result end |
#print_object_list(list) ⇒ Object
for Helpers::Input.
Prints keys of ‘list` and `value.name`
14 15 16 17 |
# File 'lib/redmine_cli/helpers/output.rb', line 14 def print_object_list(list) key_max_len = list.keys.map { |key| key.to_s.size }.max list.each { |k, v| puts "#{k.to_s.ljust(key_max_len)} - #{v.name}" } end |
#print_prompt_message(text, params = {}) ⇒ Object
for Helpers::Input
22 23 24 25 26 |
# File 'lib/redmine_cli/helpers/output.rb', line 22 def (text, params = {}) print text print "[#{params[:default]}] " if params.key? :default print "(#{params[:limited_to].join(', ')}) " if params[:limited_to].is_a? Array end |