Sha256: 69256cc29168ad1972adf976a29af91235b861fd65e7ef948b2a8f66d098cf81

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

module PDK::CLI
  @new_class_cmd = @new_cmd.define_command do
    name 'class'
    usage _('class [options] <class_name>')
    summary _('Create a new class named <class_name> using given options')

    run do |opts, args, _cmd|
      require 'pdk/generate/puppet_class'

      PDK::CLI::Util.ensure_in_module!(
        message:   _('Classes can only be created from inside a valid module directory.'),
        log_level: :info,
      )

      class_name = args[0]
      module_dir = Dir.pwd

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

      unless Util::OptionValidator.valid_class_name?(class_name)
        raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid class name") % { name: class_name }
      end

      PDK::Generate::PuppetClass.new(module_dir, class_name, opts).run
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdk-1.10.0 lib/pdk/cli/new/class.rb