Sha256: 26ef4ab21c032bded6b4b17232076d8ecb989eea6cd6523baaaf013e104de0ed

Contents?: true

Size: 922 Bytes

Versions: 8

Compression:

Stored size: 922 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::CLI::Util.analytics_screen_view('new_class', opts)

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
pdk-1.15.0 lib/pdk/cli/new/class.rb
pdk-1.14.1 lib/pdk/cli/new/class.rb
pdk-akerl-1.14.0.1 lib/pdk/cli/new/class.rb
pdk-1.14.0 lib/pdk/cli/new/class.rb
pdk-1.13.0 lib/pdk/cli/new/class.rb
pdk-1.12.0 lib/pdk/cli/new/class.rb
pdk-1.11.1 lib/pdk/cli/new/class.rb
pdk-1.11.0 lib/pdk/cli/new/class.rb