Sha256: ed8775d1fab2d439f86bf56df2e7e94efa8a7d9eb112a72b0b588c6fe99cbb65

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

module PDK
  module CLI
    @new_fact_cmd = @new_cmd.define_command do
      name 'fact'
      usage 'fact [options] <name>'
      summary 'Create a new custom fact named <name> using given options'

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

        fact_name = args[0]

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

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

        require 'pdk/generate/fact'

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