Sha256: 859e11f8f7880258a5ae04143c86ae480d9a899dd96a20d4204f72496b98a1eb

Contents?: true

Size: 1019 Bytes

Versions: 2

Compression:

Stored size: 1019 Bytes

Contents

module PDK
  module CLI
    @new_define_cmd = @new_cmd.define_command do
      name 'defined_type'
      usage 'defined_type [options] <name>'
      summary 'Create a new defined type named <name> using given options'

      run do |opts, args, _cmd|
        PDK::CLI::Util.ensure_in_module!(
          message: 'Defined types can only be created from inside a valid module directory.',
          log_level: :info
        )

        defined_type_name = args[0]

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

        raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid defined type name", name: defined_type_name) unless Util::OptionValidator.valid_defined_type_name?(defined_type_name)

        require 'pdk/generate/defined_type'

        updates = PDK::Generate::DefinedType.new(PDK.context, defined_type_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/defined_type.rb
pdk-3.3.0 lib/pdk/cli/new/defined_type.rb