Module: TaskMaker

Extended by:
Template
Defined in:
lib/umu/generators/task_maker.rb

Overview

TaskMaker is a module for generating task.

Constant Summary

Constants included from Color

Color::COLORS

Class Method Summary collapse

Methods included from Template

checker, command, cover, hover, logo, pointer, show_command

Class Method Details

.generatorObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/umu/generators/task_maker.rb', line 12

def generator
  task_name = Umu::Inputter.input(I18n.t('task.make_name'))
  cover(1)
  show_command('task', task_name)
  make_action = Umu::Selector.single_choice(I18n.t('task.make_actions'))
  cover(1)
  actions = []
  while make_action
    action_name = Umu::Inputter.input(I18n.t('task.make_action_name'), true, actions)
    cover(1)
    actions << action_name
    cover(1)
    show_command('task', task_name, actions.join(' '))
    make_action = Umu::Selector.single_choice(I18n.t('task.make_action_continue'))
    cover(1)
  end

  is_make_options = Umu::Selector.single_choice(I18n.t('common.make_options'))
  cover(1)
  options = ''
  options = Umu::Inputter.input(I18n.t('common.add_option'), true) if is_make_options
  cover(1) if is_make_options
  command = command('task', task_name, actions.join(' '), options)
  cover(1)
  puts command
  confirm_content = I18n.t('common.run_command')
  run_command = Umu::Selector.single_choice(confirm_content)
  cover(1)
  puts confirm_content + (run_command ? I18n.t('affirm') : I18n.t('deny'))
  system(command) if run_command
  true
end