Sha256: b2020088513a9b141b7c12a2bfd91c309b013fde66a4a18afdf9cc0493292919

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

require "sod"

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

        description "View snippets."

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

        default { Container[:settings].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

1 entries across 1 versions & 1 rubygems

Version Path
sublime_text_kit-18.0.0 lib/sublime_text_kit/cli/actions/snippets.rb