Sha256: f819de30b9dfd1f7d2f819eb4abd6b76937284c881505a67ae63cbf8b634b8f4

Contents?: true

Size: 878 Bytes

Versions: 6

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

require "sod"

module SublimeTextKit
  module CLI
    module Actions
      # Handles snippets action.
      class Snippets < Sod::Action
        include Import[: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

6 entries across 6 versions & 1 rubygems

Version Path
sublime_text_kit-17.6.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-17.5.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-17.4.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-17.3.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-17.2.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-17.1.0 lib/sublime_text_kit/cli/actions/snippets.rb