Sha256: 7487fe4136003315d003b5ce9a52f0c2468b26860edf6ea8f6ad7fc6c6717103

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "sod"

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

        description "Update project and session metadata based on current settings."

        on %w[-u --update]

        def initialize(
          metadata: SublimeTextKit::Metadata::Handler,
          session: Sessions::Rebuilder.new,
          **
        )
          super(**)
          @metadata = metadata
          @session = session
        end

        def call(*)
          logger.info "Updating metadata and session..."
          create_metadata
          session.call
          logger.info { "Metadata and session updated." }
        end

        private

        attr_reader :metadata, :session

        def create_metadata
          settings.project_dirs.each do |directory|
            metadata.with_project(directory, metadata_dir).create
            metadata.with_workspace(directory, metadata_dir).create
          end
        end

        def metadata_dir = Pathname(settings.metadata_dir).expand_path
      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/update.rb