Class: Mxup::CLI

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

Overview

Argv parser + dispatch. Keeps parsing rules in one place; the actual behaviour lives in Runner and the focused modules it drives.

Constant Summary collapse

COMMANDS =
%w[up status down restart layout target exec watch].freeze

Instance Method Summary collapse

Instance Method Details

#run(argv) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mxup/cli.rb', line 11

def run(argv)
  args, options = parse(argv.dup)
  command       = extract_command(args)

  # `mxup [config] <window>:<command>` — run a window's named command.
  # Only in the default (no explicit command keyword) path; `restart`/
  # `target` etc. keep their own `session:windows` colon syntax.
  if command == 'up' && (spec = window_command_spec(args))
    return run_window_command(spec, options)
  end

  dispatch(command, args, options)
end