Sha256: ee2044c2c26b7c31e8de5a4df170d03d0ba39c9111e7e544446086b10c43f924

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 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|
      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]
      module_dir = Dir.pwd

      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(module_dir, task_name, opts).run
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pdk-1.13.0 lib/pdk/cli/new/task.rb
pdk-1.12.0 lib/pdk/cli/new/task.rb
pdk-1.11.1 lib/pdk/cli/new/task.rb
pdk-1.11.0 lib/pdk/cli/new/task.rb