Sha256: 2ec17facc884c18e06a38057832ff169b6e054d17cb3e7c11d437a1151421cf3

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 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 :omit
        aliases               %i[ignore comment_out]
        description           'this content will not get written out, useful for commenting out code'
        result                'empty stting'

        parameter             :value, 'value to omit', param_type: 'String|Int'

        ruby <<-RUBY
          ''
        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

3 entries across 3 versions & 1 rubygems

Version Path
cmdlet-0.12.3 .builders/generators/cmdlets/misc.rb
cmdlet-0.12.1 .builders/generators/cmdlets/misc.rb
cmdlet-0.12.0 .builders/generators/cmdlets/misc.rb