Sha256: 037f5417dc7c4eaff5479cb4af5965789bb1f3eb3d8088bbe23ef8caeec85337

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require "sod"

module SublimeTextKit
  module CLI
    module Actions
      # Handles snippets action.
      class Snippets < Sod::Action
        include Import[:configuration, :logger]

        description "View snippets."

        on %w[-s --snippets], argument: "[FORMAT]", allow: %w[markdown ascii_doc]

        default { Container[:configuration].snippets_format }

        def initialize(printer: SublimeTextKit::Snippets::Printer.new, **)
          super(**)
          @printer = printer
        end

        def call kind = default
          case kind
            when "ascii_doc" then printer.call "*"
            when "markdown" then printer.call "-"
            else logger.error { "Invalid snippet format: #{kind}. Use ascii_doc or markdown." }
          end
        end

        private

        attr_reader :printer
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sublime_text_kit-15.0.1 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-15.0.0 lib/sublime_text_kit/cli/actions/snippets.rb