omagem 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -12
- data/lib/{omarchy → omagem}/client.rb +2 -2
- data/lib/{omarchy → omagem}/config.rb +13 -13
- data/lib/{omarchy → omagem}/dsl/bar.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/misc.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/package.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/plugin.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/service.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/snapshot.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/system.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/theme.rb +1 -1
- data/lib/{omarchy → omagem}/dsl/toggle.rb +1 -1
- data/lib/{omarchy → omagem}/errors.rb +2 -2
- data/lib/{omarchy → omagem}/version.rb +2 -2
- data/lib/omagem.rb +33 -0
- metadata +15 -15
- data/lib/omarchy.rb +0 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e330b39968b7711d9f1cf9f46232efec3c2f342b207ba65a772c48a5a6cac1d7
|
|
4
|
+
data.tar.gz: dae10b20eb9dc463ca7be29c358b0f2f858cf12196604f56a67a5bd4638b1d54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7867469319e28f0f4174bb131f83808865650a561ebf375342a438b8363b201401a66722a20e21494c48878e79e4bfaf569fb3cf6529bca38d43ce7fa9083cf5
|
|
7
|
+
data.tar.gz: f9ea24917b880e554f016b459201ea7151eb95c4f14fe52e84419a1a508faeeeb654122123030aa6707df209838dccf9242fcf5adf6ab4126d972efe44235606
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OmaGem
|
|
2
2
|
|
|
3
3
|
[](https://github.com/azzenabidi/OmaGem/actions/workflows/ci.yml)
|
|
4
4
|
[](https://rubygems.org/gems/omagem)
|
|
@@ -39,9 +39,9 @@ bundle install
|
|
|
39
39
|
## Usage
|
|
40
40
|
|
|
41
41
|
```ruby
|
|
42
|
-
require "
|
|
42
|
+
require "omagem"
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
OmaGem.run do
|
|
45
45
|
theme "catppuccin"
|
|
46
46
|
background "/home/me/Pictures/forest.png"
|
|
47
47
|
|
|
@@ -62,11 +62,11 @@ Omarchy.run do
|
|
|
62
62
|
end
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
Every method is documented on `
|
|
65
|
+
Every method is documented on `OmaGem::Config`. The block is evaluated
|
|
66
66
|
against a fresh `Config`, so you can call any DSL method directly:
|
|
67
67
|
|
|
68
68
|
```ruby
|
|
69
|
-
config =
|
|
69
|
+
config = OmaGem.run do
|
|
70
70
|
theme "catppuccin"
|
|
71
71
|
add_packages "git"
|
|
72
72
|
end
|
|
@@ -173,12 +173,12 @@ focus_app "org.mozilla.firefox"
|
|
|
173
173
|
|
|
174
174
|
## From a Rails app
|
|
175
175
|
|
|
176
|
-
Because `
|
|
176
|
+
Because `OmaGem.run` returns the `Config` (and records every executed
|
|
177
177
|
command), you can invoke it from a controller, job, or service and inspect
|
|
178
178
|
the results:
|
|
179
179
|
|
|
180
180
|
```ruby
|
|
181
|
-
result =
|
|
181
|
+
result = OmaGem.run { theme params[:theme] }
|
|
182
182
|
flash[:notice] = result.current_theme
|
|
183
183
|
```
|
|
184
184
|
|
|
@@ -187,16 +187,16 @@ flash[:notice] = result.current_theme
|
|
|
187
187
|
Pass a fake (recording) client to build a config without touching the system:
|
|
188
188
|
|
|
189
189
|
```ruby
|
|
190
|
-
config =
|
|
190
|
+
config = OmaGem::Config.new(client: OmaGem::Client::Fake.new)
|
|
191
191
|
config.theme "catppuccin"
|
|
192
192
|
config.executed # => [["theme", "set", "catppuccin"]]
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
## Errors
|
|
196
196
|
|
|
197
|
-
- `
|
|
198
|
-
- `
|
|
199
|
-
- `
|
|
197
|
+
- `OmaGem::CommandFailed` — a command exited non-zero (set `ignore_errors: true` in `OmaGem.run` to raise nothing and keep going).
|
|
198
|
+
- `OmaGem::CommandNotFound` — the `omarchy` binary isn't on `PATH` (`ensure_command!`).
|
|
199
|
+
- `OmaGem::ArgumentError` — an invalid enum value (e.g. an unknown terminal).
|
|
200
200
|
|
|
201
201
|
## Development
|
|
202
202
|
|
|
@@ -208,4 +208,4 @@ bundle exec rubocop
|
|
|
208
208
|
|
|
209
209
|
## License
|
|
210
210
|
|
|
211
|
-
MIT
|
|
211
|
+
MIT
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require 'open3'
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module OmaGem
|
|
6
6
|
# Wraps the `omarchy` CLI. It shells out to the single `omarchy` binary and
|
|
7
7
|
# exposes the resulting output, whether the command succeeded, and the exit
|
|
8
8
|
# status. Errors raised by the command are captured rather than thrown.
|
|
9
9
|
#
|
|
10
10
|
# The class is designed to be subclassed or stubbed in tests (see
|
|
11
|
-
#
|
|
11
|
+
# OmaGem::Client::Fake) so the DSL can be exercised without a live system.
|
|
12
12
|
class Client
|
|
13
13
|
Result = Struct.new(:success, :stdout, :stderr, :status, keyword_init: true) do
|
|
14
14
|
def success?
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require_relative 'client'
|
|
4
4
|
require_relative 'errors'
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module OmaGem
|
|
7
7
|
# The DSL surface. A Config instance exposes all the management methods
|
|
8
8
|
# (theme, package, service, system, ...). The methods are defined in
|
|
9
9
|
# feature modules mixed in below, so the DSL is easy to extend and keep
|
|
@@ -14,7 +14,7 @@ module Omarchy
|
|
|
14
14
|
class Config
|
|
15
15
|
attr_reader :client
|
|
16
16
|
|
|
17
|
-
def initialize(client:
|
|
17
|
+
def initialize(client: OmaGem::Client.new, ignore_errors: false)
|
|
18
18
|
@client = client
|
|
19
19
|
@ignore_errors = ignore_errors
|
|
20
20
|
@executed = []
|
|
@@ -24,7 +24,7 @@ module Omarchy
|
|
|
24
24
|
# argument array.
|
|
25
25
|
attr_reader :executed
|
|
26
26
|
|
|
27
|
-
# Run an Omarchy command and return the
|
|
27
|
+
# Run an Omarchy command and return the OmaGem::Client::Result.
|
|
28
28
|
# Records the call and validates the exit status unless ignore_errors.
|
|
29
29
|
def run(*args)
|
|
30
30
|
@executed << args
|
|
@@ -67,7 +67,7 @@ module Omarchy
|
|
|
67
67
|
client.run('theme', 'list').stdout.lines.map(&:strip).reject(&:empty?)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
# Raise
|
|
70
|
+
# Raise OmaGem::ArgumentError unless value is in the allowed list.
|
|
71
71
|
def validate_in!(value, allowed, label)
|
|
72
72
|
return if allowed.include?(value.to_s)
|
|
73
73
|
|
|
@@ -86,12 +86,12 @@ require_relative 'dsl/toggle'
|
|
|
86
86
|
require_relative 'dsl/snapshot'
|
|
87
87
|
require_relative 'dsl/misc'
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
OmaGem::Config.include(OmaGem::DSL::Theme)
|
|
90
|
+
OmaGem::Config.include(OmaGem::DSL::Package)
|
|
91
|
+
OmaGem::Config.include(OmaGem::DSL::Service)
|
|
92
|
+
OmaGem::Config.include(OmaGem::DSL::System)
|
|
93
|
+
OmaGem::Config.include(OmaGem::DSL::Bar)
|
|
94
|
+
OmaGem::Config.include(OmaGem::DSL::Plugin)
|
|
95
|
+
OmaGem::Config.include(OmaGem::DSL::Toggle)
|
|
96
|
+
OmaGem::Config.include(OmaGem::DSL::Snapshot)
|
|
97
|
+
OmaGem::Config.include(OmaGem::DSL::Misc)
|
data/lib/omagem.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'omagem/version'
|
|
4
|
+
require_relative 'omagem/errors'
|
|
5
|
+
require_relative 'omagem/client'
|
|
6
|
+
require_relative 'omagem/config'
|
|
7
|
+
|
|
8
|
+
# OmaGem is a Ruby DSL for configuring and managing Omarchy Linux systems.
|
|
9
|
+
#
|
|
10
|
+
# require "omagem"
|
|
11
|
+
#
|
|
12
|
+
# OmaGem.run do
|
|
13
|
+
# theme "catppuccin"
|
|
14
|
+
# add_packages "docker", "git"
|
|
15
|
+
# install_service "tailscale"
|
|
16
|
+
# nightlight :on
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# The block is evaluated against an OmaGem::Config, which exposes every
|
|
20
|
+
# DSL method. See OmaGem::Config for the full list.
|
|
21
|
+
module OmaGem
|
|
22
|
+
class << self
|
|
23
|
+
# Execute a DSL block against a fresh OmaGem::Config. Returns the config
|
|
24
|
+
# so the caller can inspect what ran via config.executed / config.client.
|
|
25
|
+
#
|
|
26
|
+
# config = OmaGem.run { theme "catppuccin" }
|
|
27
|
+
def run(client: OmaGem::Client.new, ignore_errors: false, &block)
|
|
28
|
+
config = Config.new(client: client, ignore_errors: ignore_errors)
|
|
29
|
+
config.instance_eval(&block) if block
|
|
30
|
+
config
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omagem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- azzen
|
|
@@ -19,20 +19,20 @@ extra_rdoc_files: []
|
|
|
19
19
|
files:
|
|
20
20
|
- LICENSE
|
|
21
21
|
- README.md
|
|
22
|
-
- lib/
|
|
23
|
-
- lib/
|
|
24
|
-
- lib/
|
|
25
|
-
- lib/
|
|
26
|
-
- lib/
|
|
27
|
-
- lib/
|
|
28
|
-
- lib/
|
|
29
|
-
- lib/
|
|
30
|
-
- lib/
|
|
31
|
-
- lib/
|
|
32
|
-
- lib/
|
|
33
|
-
- lib/
|
|
34
|
-
- lib/
|
|
35
|
-
- lib/
|
|
22
|
+
- lib/omagem.rb
|
|
23
|
+
- lib/omagem/client.rb
|
|
24
|
+
- lib/omagem/config.rb
|
|
25
|
+
- lib/omagem/dsl/bar.rb
|
|
26
|
+
- lib/omagem/dsl/misc.rb
|
|
27
|
+
- lib/omagem/dsl/package.rb
|
|
28
|
+
- lib/omagem/dsl/plugin.rb
|
|
29
|
+
- lib/omagem/dsl/service.rb
|
|
30
|
+
- lib/omagem/dsl/snapshot.rb
|
|
31
|
+
- lib/omagem/dsl/system.rb
|
|
32
|
+
- lib/omagem/dsl/theme.rb
|
|
33
|
+
- lib/omagem/dsl/toggle.rb
|
|
34
|
+
- lib/omagem/errors.rb
|
|
35
|
+
- lib/omagem/version.rb
|
|
36
36
|
homepage: https://github.com/azzenabidi/OmaGem
|
|
37
37
|
licenses:
|
|
38
38
|
- MIT
|
data/lib/omarchy.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'omarchy/version'
|
|
4
|
-
require_relative 'omarchy/errors'
|
|
5
|
-
require_relative 'omarchy/client'
|
|
6
|
-
require_relative 'omarchy/config'
|
|
7
|
-
|
|
8
|
-
# Omarchy is a Ruby DSL for configuring and managing Omarchy Linux systems.
|
|
9
|
-
#
|
|
10
|
-
# require "omarchy"
|
|
11
|
-
#
|
|
12
|
-
# Omarchy.run do
|
|
13
|
-
# theme "catppuccin"
|
|
14
|
-
# add_packages "docker", "git"
|
|
15
|
-
# install_service "tailscale"
|
|
16
|
-
# nightlight :on
|
|
17
|
-
# end
|
|
18
|
-
#
|
|
19
|
-
# The block is evaluated against an Omarchy::Config, which exposes every
|
|
20
|
-
# DSL method. See Omarchy::Config for the full list.
|
|
21
|
-
module Omarchy
|
|
22
|
-
class << self
|
|
23
|
-
# Execute a DSL block against a fresh Omarchy::Config. Returns the config
|
|
24
|
-
# so the caller can inspect what ran via config.executed / config.client.
|
|
25
|
-
#
|
|
26
|
-
# config = Omarchy.run { theme "catppuccin" }
|
|
27
|
-
def run(client: Omarchy::Client.new, ignore_errors: false, &block)
|
|
28
|
-
config = Config.new(client: client, ignore_errors: ignore_errors)
|
|
29
|
-
config.instance_eval(&block) if block
|
|
30
|
-
config
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|