Class: Dotsync::WatchAction

Inherits:
BaseAction show all
Includes:
MappingsTransfer
Defined in:
lib/dotsync/actions/watch_action.rb

Constant Summary

Constants included from MappingsTransfer

MappingsTransfer::DIFFERENCES_LEGEND, MappingsTransfer::MAPPINGS_LEGEND

Constants included from PathUtils

PathUtils::ENV_VARS_COLOR

Instance Attribute Summary

Attributes inherited from BaseAction

#logger

Instance Method Summary collapse

Methods included from MappingsTransfer

#show_differences, #show_differences_legend, #show_env_vars, #show_mappings, #show_mappings_legend, #transfer_mappings

Methods included from PathUtils

#colorize_env_vars, #expand_env_vars, #extract_env_vars, #path_is_parent_or_same?, #relative_to_absolute, #sanitize_path, #translate_tmp_path

Constructor Details

#initialize(config, logger) ⇒ WatchAction

Returns a new instance of WatchAction.



9
10
11
12
13
# File 'lib/dotsync/actions/watch_action.rb', line 9

def initialize(config, logger)
  super
  setup_listeners
  setup_signal_trap
end

Instance Method Details

#execute(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/dotsync/actions/watch_action.rb', line 15

def execute(options = {})
  show_mappings_legend unless options[:quiet] || options[:no_legend] || options[:no_mappings]
  show_mappings unless options[:quiet] || options[:no_mappings]

  @listeners.each(&:start)

  logger.action("Listening for changes...") unless options[:quiet]
  logger.action("Press Ctrl+C to exit.") unless options[:quiet]
  sleep
end