Class: OmaGem::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/omagem/client.rb

Overview

Wraps the omarchy CLI. It shells out to the single omarchy binary and exposes the resulting output, whether the command succeeded, and the exit status. Errors raised by the command are captured rather than thrown.

The class is designed to be subclassed or stubbed in tests (see OmaGem::Client::Fake) so the DSL can be exercised without a live system.

Defined Under Namespace

Classes: Fake, Result

Instance Method Summary collapse

Constructor Details

#initialize(command: 'omarchy') ⇒ Client

Returns a new instance of Client.



23
24
25
# File 'lib/omagem/client.rb', line 23

def initialize(command: 'omarchy')
  @command = command
end

Instance Method Details

#run(*args) ⇒ Object

Run an omarchy command as in: client.run("theme", "set", "catppuccin")



28
29
30
31
32
33
34
35
36
37
# File 'lib/omagem/client.rb', line 28

def run(*args)
  cmd = [@command, *args.map(&:to_s)]
  stdout, stderr, status = Open3.capture3(*cmd)
  Result.new(
    success: status.success?,
    stdout: stdout.to_s.strip,
    stderr: stderr.to_s.strip,
    status: status.exitstatus
  )
end