Sha256: aee8cd1f33c1d2417c5c3270fecc31ee39d220550a3f09079d3ae8c13281445e

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

module PDK::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]
      module_dir = Dir.pwd

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

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

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

      PDK::Generate::DefinedType.new(module_dir, defined_type_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/defined_type.rb
pdk-1.12.0 lib/pdk/cli/new/defined_type.rb
pdk-1.11.1 lib/pdk/cli/new/defined_type.rb
pdk-1.11.0 lib/pdk/cli/new/defined_type.rb