Sha256: eb02bf09c2faa9e6a1597ce1a60d1f7a1eaf4a11d703c135e8e65c8cbe00dfc6

Contents?: true

Size: 476 Bytes

Versions: 13

Compression:

Stored size: 476 Bytes

Contents

module ThreeScaleToolbox
  module CLI
    class PrinterTransformer
      def call(output_format)
        raise unless %w[yaml json].include?(output_format)

        case output_format
        when 'yaml'
          YamlPrinter.new
        when 'json'
          JsonPrinter.new
        end
      end
    end

    def self.output_flag(dsl)
      dsl.option :o, :output, 'Output format. One of: json|yaml', argument: :required, transform: PrinterTransformer.new
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/cli/output_flag.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/cli/output_flag.rb