Sha256: 73c8549a34213bb0f6da31e77d668285390a5cbee16e1c51e018bec2c74731f5

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

KManager.action :misc_commands do
  action do
    CmdletDirector
      .init(k_builder, category: :misc)
      .cmdlet do
        name :safe
        description           'pass through the value with <> and single and double quotes left as is'
        result                'the value with <> and single and double quotes left as is'

        parameter             :value, 'value to pass through', param_type: 'String|Int'

        ruby <<-RUBY
          value = '' if value.nil?
          value
        RUBY
      end
      .cmdlet do
        name :format_json
        description           'FormatJson will take an object and write it out as pretty JSON'
        result                'value as pretty JSON string'

        parameter             :value, 'object to be converted to JSON string', param_type: 'Object'

        ruby <<-RUBY
          return '{}' if value.nil?

          value = JSON.pretty_generate(value)

          value
        RUBY
      end
      .generate
      # .debug
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cmdlet-0.12.2 .builders/generators/cmdlets/misc.rb
cmdlet-0.11.0 .builders/generators/cmdlets/misc.rb