Class: Mxup::Reconciler

Inherits:
Object
  • Object
show all
Defined in:
lib/mxup/reconciler.rb

Overview

Drives ‘mxup up`: creates a session from scratch when missing, or brings the existing session in line with the config.

Reconciliation rules:

- missing windows   → create + start command
- extra windows     → kill (with warning)
- idle/crashed      → re-send the command
- running healthy   → leave alone
- layout changed    → regroup panes without killing PIDs

Instance Method Summary collapse

Constructor Details

#initialize(config, launcher:, resolver:, layout_manager:, dry_run: false, out: nil, err: nil) ⇒ Reconciler

Returns a new instance of Reconciler.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mxup/reconciler.rb', line 14

def initialize(config, launcher:, resolver:, layout_manager:,
               dry_run: false, out: nil, err: nil)
  @config         = config
  @session        = config.session
  @launcher       = launcher
  @resolver       = resolver
  @layout_manager = layout_manager
  @dry_run        = dry_run
  @out_override   = out
  @err_override   = err
end

Instance Method Details

#errObject



30
31
32
# File 'lib/mxup/reconciler.rb', line 30

def err
  @err_override || $stderr
end

#outObject



26
27
28
# File 'lib/mxup/reconciler.rb', line 26

def out
  @out_override || $stdout
end

#upObject



34
35
36
37
38
39
40
# File 'lib/mxup/reconciler.rb', line 34

def up
  if Tmux.has_session?(@session)
    reconcile
  else
    create_fresh
  end
end