Sha256: 4a61aca13c41d1761f343b3b9e18c6e2c70671dd3bd61ab4c0c6b71cddb1010c

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

module PDK
  module CLI
    @new_function_cmd = @new_cmd.define_command do
      name 'function'
      usage 'function [options] <name>'
      summary 'Create a new function named <name> using given options'
      option :t, :type, 'The function type, (native or v4)', argument: :required, default: 'native'

      run do |opts, args, _cmd|
        PDK::CLI::Util.ensure_in_module!

        function_name = args[0]

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

        raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid function name", name: function_name) unless Util::OptionValidator.valid_function_name?(function_name)

        require 'pdk/generate/function'
        updates = PDK::Generate::Function.new(PDK.context, function_name, opts).run
        PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdk-3.4.0 lib/pdk/cli/new/function.rb
pdk-3.3.0 lib/pdk/cli/new/function.rb