Class: OmaGem::Client
- Inherits:
-
Object
- Object
- OmaGem::Client
- 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
Instance Method Summary collapse
-
#initialize(command: 'omarchy') ⇒ Client
constructor
A new instance of Client.
-
#run(*args) ⇒ Object
Run an
omarchycommand as in: client.run("theme", "set", "catppuccin").
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 |