Sha256: f63fd2a0acc7682bfc4be3502e4c839c498680cf7ef50af05b080180c847910e

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

module PDK::CLI
  @new_task_cmd = @new_cmd.define_command do
    name 'task'
    usage _('task [options] <name>')
    summary _('Create a new task named <name> using given options')

    option nil, :description, _('A short description of the purpose of the task'), argument: :required

    run do |opts, args, _cmd|
      require 'pdk/generate/task'

      PDK::CLI::Util.ensure_in_module!(
        message:   _('Tasks can only be created from inside a valid module directory.'),
        log_level: :info,
      )

      task_name = args[0]

      if task_name.nil? || task_name.empty?
        puts command.help
        exit 1
      end

      unless Util::OptionValidator.valid_task_name?(task_name)
        raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid task name") % { name: task_name }
      end

      PDK::CLI::Util.analytics_screen_view('new_task', opts)

      PDK::Generate::Task.new(PDK::Util.module_root, task_name, opts).run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdk-1.17.0 lib/pdk/cli/new/task.rb
pdk-1.16.0 lib/pdk/cli/new/task.rb