Sha256: cd360adb0bf66f84390e3d3fde2095626db6eb42668a5fa76ac2f61f3c3c0883

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

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)

      updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
      PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pdk-2.6.1 lib/pdk/cli/new/task.rb
pdk-2.6.0 lib/pdk/cli/new/task.rb
pdk-2.5.0 lib/pdk/cli/new/task.rb
pdk-2.3.0 lib/pdk/cli/new/task.rb
pdk-2.2.0 lib/pdk/cli/new/task.rb
pdk-2.1.1 lib/pdk/cli/new/task.rb
pdk-2.1.0 lib/pdk/cli/new/task.rb
pdk-2.0.0 lib/pdk/cli/new/task.rb
pdk-1.18.1 lib/pdk/cli/new/task.rb
pdk-1.18.0 lib/pdk/cli/new/task.rb