okf-tui 1.0.1 → 1.1.0
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/.okf/decisions/registry-write-boundary.md +28 -1
- data/.okf/interaction/which-registry.md +25 -4
- data/.okf/log.md +34 -0
- data/CHANGELOG.md +38 -0
- data/README.md +5 -1
- data/lib/okf/tui/app.rb +28 -7
- data/lib/okf/tui/cli.rb +2 -2
- data/lib/okf/tui/refs.rb +1 -1
- data/lib/okf/tui/version.rb +1 -1
- data/lib/okf/tui/views.rb +15 -0
- data/lib/okf/tui/workspace.rb +34 -9
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b9c76ae8e2518d6c115a26a21a4edae22c3be73a7a6bd106879a85586127b29
|
|
4
|
+
data.tar.gz: d69fa699c20acfa5032f6016a2ad9ab24ad6be57f5c6e97681a07021e40aa3b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7a02cb3069109567ed1cd224ec3983f0c420e302547db1f62024da33de118f334d08801507b8384f64c97f2f17cf64924ef3a1b978458029219d2a4b2374f2c
|
|
7
|
+
data.tar.gz: a95161b1c57329060964bb37c969c54fa9b3e435f69fd94c11221491713bc428db9403f760edaf9dd70433ac699a45ab34a11f80379b95d99c6110d44ad58413
|
|
@@ -65,6 +65,33 @@ slug and cascade through every member list that names it. None of that is
|
|
|
65
65
|
reimplemented; `groups_test.rb` asserts the *effects* — that renaming `@docs`
|
|
66
66
|
leaves `@everything` naming `@papers` — precisely so the cascades stay okf's.
|
|
67
67
|
|
|
68
|
+
# A linked bundle is inside the boundary and still read-only
|
|
69
|
+
|
|
70
|
+
okf's global registry can `link` another registry file, and that file's bundles
|
|
71
|
+
and groups resolve into this view. They are configuration in exactly the sense
|
|
72
|
+
above — but configuration this session does not own, since the file that holds
|
|
73
|
+
them is somewhere else and okf refuses every write against one.
|
|
74
|
+
|
|
75
|
+
So the four keys that act on the selected row — `d`, `n`, `x`, `+` — **refuse
|
|
76
|
+
before the prompt**, naming the link. Letting the ask through would work: okf
|
|
77
|
+
raises, `Workspace` rescues, and the status line carries the message. It would
|
|
78
|
+
also make a user type a new name, or answer `y` to a removal, before learning it
|
|
79
|
+
could never land. The refusal is worth a key's own line for the same reason the
|
|
80
|
+
removal key below got one: a key that stops working has to say so, and *when* it
|
|
81
|
+
says so is part of saying it.
|
|
82
|
+
|
|
83
|
+
Where the fact lives is a layout decision. The registry pane is 42 columns and
|
|
84
|
+
already carries slug, count and `default`, so a marker there would clip on a
|
|
85
|
+
narrow terminal — which this gem [refuses to do](/rendering/fit-or-say-so.md).
|
|
86
|
+
The bundle detail says `read-only — linked from @onm` and names the owning file
|
|
87
|
+
on the line under it, beside the other "what can I do with this one" lines.
|
|
88
|
+
|
|
89
|
+
`Entry#link` and `Group#link` come straight off okf's `listing` and
|
|
90
|
+
`groups_listing` rows, and `test/integration/links_registry_test.rb` asserts that
|
|
91
|
+
agreement directly rather than through a fixture — a rename of that field in okf
|
|
92
|
+
would otherwise leave every refusal here quietly not firing, which is the drift
|
|
93
|
+
[okf-capability-drift](/decisions/okf-capability-drift.md) exists to catch.
|
|
94
|
+
|
|
68
95
|
# What it excludes
|
|
69
96
|
|
|
70
97
|
Nothing in `lib/` writes a bundle. There is no `OKF::Bundle::Writer` reference in
|
|
@@ -80,7 +107,7 @@ poor place to make an irreversible edit to it by muscle memory.
|
|
|
80
107
|
# `registry init` is excluded, for a different reason
|
|
81
108
|
|
|
82
109
|
okf 1.12.0 added `okf registry init`, which creates a project-local
|
|
83
|
-
`.okf
|
|
110
|
+
`.okf.json`. It is registry configuration, so the line above admits it —
|
|
84
111
|
and it is still not offered, on mechanics rather than principle.
|
|
85
112
|
|
|
86
113
|
The registry is resolved **once, at boot**: `Workspace#load_entries` opens it, and
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
type: Constraint
|
|
3
3
|
title: Which Registry a Session Is On
|
|
4
|
-
description: okf resolves a project-local .okf
|
|
4
|
+
description: okf resolves a project-local .okf.json before the global $OKF_HOME one; the TUI did not, and being the single verb that disagreed was a silent wrong answer rather than an error.
|
|
5
5
|
tags: [registry, okf-coupling, discovery]
|
|
6
6
|
generated:
|
|
7
7
|
by: human:maintainer
|
|
@@ -22,10 +22,12 @@ sources:
|
|
|
22
22
|
# Overview
|
|
23
23
|
|
|
24
24
|
"Which bundles can I see?" has one right answer per directory, and okf decides it:
|
|
25
|
-
`OKF_NO_DISCOVERY` forces the global registry; otherwise a `.okf
|
|
25
|
+
`OKF_NO_DISCOVERY` forces the global registry; otherwise a `.okf.json` — or the
|
|
26
|
+
older `.okf-registry.json`, still discovered so no committed registry breaks —
|
|
26
27
|
found by walking up from the working directory wins; otherwise `$OKF_HOME`
|
|
27
|
-
(default `~/.okf`).
|
|
28
|
-
|
|
28
|
+
(default `~/.okf`). Both names are checked in each directory before climbing, so
|
|
29
|
+
"nearest local file wins" keeps meaning what it says, and a local registry stores
|
|
30
|
+
paths *relative* to itself so it can be committed and travel with the repo.
|
|
29
31
|
|
|
30
32
|
The TUI ignored all of that for a release. `Workspace` called
|
|
31
33
|
`OKF::Registry.load(home: home)` with no `cwd:`, and okf only discovers when it is
|
|
@@ -45,6 +47,25 @@ This is the shape [okf-capability-drift](/decisions/okf-capability-drift.md)
|
|
|
45
47
|
describes: okf added a resolution rule, the old call kept working, and "kept
|
|
46
48
|
working" meant "kept answering the wrong question".
|
|
47
49
|
|
|
50
|
+
# A third input arrived, and the answer stayed one method
|
|
51
|
+
|
|
52
|
+
okf later gained `okf registry link`: the global registry can point at another
|
|
53
|
+
registry file, and that file's bundles and groups resolve into the set. The TUI
|
|
54
|
+
needed no change to show them — `registry_entries` reads `listing` and
|
|
55
|
+
`registry_groups` reads `groups_listing`, and okf folds the linked half into
|
|
56
|
+
both. That is the point. The rule this concept states is that one question has
|
|
57
|
+
one answer per directory; a linked group listed by a *second* method would have
|
|
58
|
+
put the TUI back where it started, showing a smaller set than its own `@ref`
|
|
59
|
+
resolution could open, with nothing failing to say so.
|
|
60
|
+
|
|
61
|
+
What the TUI had to add for itself is that a linked bundle is **read-only**. The
|
|
62
|
+
config keys reached okf, which refused, and the message arrived on the status
|
|
63
|
+
line — correct, and too late: the user had already typed a new name or confirmed
|
|
64
|
+
a removal. `d`, `n`, `x` and `+` now refuse before the prompt, and the detail
|
|
65
|
+
pane says where the bundle comes from. That is
|
|
66
|
+
[registry-write-boundary](/decisions/registry-write-boundary.md)'s, not this
|
|
67
|
+
file's — what belongs here is only that the *set* stayed one answer.
|
|
68
|
+
|
|
48
69
|
# The library keeps okf's own line
|
|
49
70
|
|
|
50
71
|
`cwd:` is a parameter, not a default of `Dir.pwd`, and that mirrors okf exactly:
|
data/.okf/log.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Update Log
|
|
2
2
|
|
|
3
|
+
## 2026-08-22
|
|
4
|
+
|
|
5
|
+
* **The project-local registry is `.okf.json`, and the TUI inherits that for
|
|
6
|
+
free** — [which-registry](interaction/which-registry.md),
|
|
7
|
+
[registry-write-boundary](decisions/registry-write-boundary.md). okf renamed the
|
|
8
|
+
file and kept discovering the old `.okf-registry.json`, checking both names in
|
|
9
|
+
each directory on the way up. `Workspace` needed no change, which is the point
|
|
10
|
+
of asking okf rather than recomputing: the one method that answers "which
|
|
11
|
+
registry am I on" answered the new question the moment the kernel did. What the
|
|
12
|
+
two concepts owed was accuracy — one stated the discovery rule and would have
|
|
13
|
+
stated half of it, and the other named the file it writes.
|
|
14
|
+
|
|
15
|
+
## 2026-08-21
|
|
16
|
+
|
|
17
|
+
* **A linked bundle is read-only, and the four config keys say so before they
|
|
18
|
+
ask** — [registry-write-boundary](decisions/registry-write-boundary.md),
|
|
19
|
+
[which-registry](interaction/which-registry.md). okf's registry can now `link`
|
|
20
|
+
another registry file, whose bundles and groups resolve into the bundles view.
|
|
21
|
+
They list, load, scope and search like any other — but the file that owns them
|
|
22
|
+
is elsewhere, so okf refuses every write. `d`, `n`, `x` and `+` reached okf,
|
|
23
|
+
okf raised, and the message landed on the status line *after* the user had
|
|
24
|
+
typed a new name or confirmed a removal. They now refuse first, naming the
|
|
25
|
+
link; the bundle detail carries `read-only — linked from @onm` and the owning
|
|
26
|
+
file underneath. The registry pane is left alone, because 42 columns cannot
|
|
27
|
+
take another marker without clipping.
|
|
28
|
+
|
|
29
|
+
* **Nothing was needed to *show* linked bundles at all.** The entries come from
|
|
30
|
+
okf's `listing` and the groups from its `groups_listing`, and okf folds the
|
|
31
|
+
linked half into both rather than into a second method — which is the whole
|
|
32
|
+
point of [which-registry](interaction/which-registry.md)'s rule, arriving from
|
|
33
|
+
the kernel's side this time. `Entry#link` and `Group#link` are read off those
|
|
34
|
+
rows, and an agreement test asserts the field against okf itself, since a
|
|
35
|
+
rename there would leave every refusal above quietly not firing.
|
|
36
|
+
|
|
3
37
|
## 2026-08-19
|
|
4
38
|
|
|
5
39
|
* **This bundle moved to OKF v0.2.** `timestamp:` became
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,44 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.0] - 2026-08-22
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Linked bundles are marked read-only, and the config keys refuse before the
|
|
13
|
+
prompt.** okf's global registry can now `link` another registry file, and that
|
|
14
|
+
file's bundles and groups resolve into the bundles view. Browsing one is
|
|
15
|
+
browsing a bundle, so they list, load, scope and search like any other — but
|
|
16
|
+
the file that owns them is elsewhere and okf refuses every write against one.
|
|
17
|
+
|
|
18
|
+
`d`, `n`, `x` and `+` now say so *before* asking. Without this the ask went
|
|
19
|
+
through, okf raised, and the message reached the status line only after the
|
|
20
|
+
user had typed a new name or confirmed a removal. The bundle detail carries
|
|
21
|
+
`read-only — linked from @onm` and the owning file underneath; the registry
|
|
22
|
+
pane is left alone, because 42 columns cannot take another marker without
|
|
23
|
+
clipping.
|
|
24
|
+
|
|
25
|
+
Nothing else changed to show linked bundles at all: the entries come from
|
|
26
|
+
okf's `listing` and the groups from its `groups_listing`, both of which fold
|
|
27
|
+
the linked half in. `Entry#link` and `Group#link` are read straight off those
|
|
28
|
+
rows, and the suite asserts that agreement against okf rather than a fixture.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- **The project-local registry is now `.okf.json`.** The TUI reads whichever file
|
|
33
|
+
okf resolves, so this needed no code change — but it is what the header prints
|
|
34
|
+
and what the "nothing to show" message names, so the file you see identified
|
|
35
|
+
there has a new name. The older `.okf-registry.json` is still discovered, both
|
|
36
|
+
names checked in each directory on the way up, so a repository carrying one
|
|
37
|
+
keeps working untouched. `okf registry init` writes the short name.
|
|
38
|
+
|
|
39
|
+
- **The `okf` floor moves to 2.2.0**, the kernel that ships `registry link`
|
|
40
|
+
(`Registry#links_listing`, and the `link` key on listing and group rows).
|
|
41
|
+
Against 2.1.1 those read as *nil* rather than raising, so a linked bundle would
|
|
42
|
+
simply never be marked read-only and the four config keys would stop refusing —
|
|
43
|
+
silent, which is the drift this gem's floor exists to turn into a resolution
|
|
44
|
+
failure.
|
|
45
|
+
|
|
8
46
|
## [1.0.1] - 2026-08-20
|
|
9
47
|
|
|
10
48
|
### Fixed
|
data/README.md
CHANGED
|
@@ -124,6 +124,10 @@ In the bundles view: `d` default, `a` add, `n` rename, `x` remove (asks first),
|
|
|
124
124
|
shows what the file now says. Removing a bundle never touches the bundle on
|
|
125
125
|
disk — the registry is a list of references.
|
|
126
126
|
|
|
127
|
+
A bundle that arrived through an `okf registry link` is read-only — the registry
|
|
128
|
+
that owns it is another file — so those keys say so instead of asking, and the
|
|
129
|
+
detail pane names the link and the file to edit.
|
|
130
|
+
|
|
127
131
|
It edits your *configuration*, never your knowledge: there is no bundle writing
|
|
128
132
|
anywhere in this gem. Authoring belongs to `okf` and its companion skill.
|
|
129
133
|
|
|
@@ -151,7 +155,7 @@ Anything that can lose configuration asks first and names what it is about to do
|
|
|
151
155
|
group goes with it. `+`, `c` and `d` add or reorder, and do not ask.
|
|
152
156
|
|
|
153
157
|
**Which registry.** The same one every other `okf` verb run from the same
|
|
154
|
-
directory resolves: a project-local `.okf
|
|
158
|
+
directory resolves: a project-local `.okf.json` when one is on the path
|
|
155
159
|
up from here, and `$OKF_HOME` (default `~/.okf`) otherwise. `OKF_NO_DISCOVERY=1`
|
|
156
160
|
forces the global one. The header names the file it read, so there is never a
|
|
157
161
|
question which is in force. A workspace of directories named on the command line
|
data/lib/okf/tui/app.rb
CHANGED
|
@@ -996,6 +996,10 @@ module OKF::TUI
|
|
|
996
996
|
return (@message = "no bundle here to add") if entry.nil?
|
|
997
997
|
return (@message = "no group to add it to — c names the bundles in scope as one") if group.nil?
|
|
998
998
|
return (@message = "@#{group.slug} already names @#{entry.slug}") if group.members.include?(entry.slug)
|
|
999
|
+
# Both halves: a linked bundle cannot be stored as a member (its name lives
|
|
1000
|
+
# only while its link resolves), and a linked group cannot be written to.
|
|
1001
|
+
return if refused_linked?(entry, "grouping")
|
|
1002
|
+
return if refused_linked?(group, "adding to")
|
|
999
1003
|
|
|
1000
1004
|
apply_group_edit_keeping_focus do
|
|
1001
1005
|
keeping_group_scoped(group.slug) { workspace.add_to_group(group.slug, [ entry.slug ]) }
|
|
@@ -1434,19 +1438,35 @@ module OKF::TUI
|
|
|
1434
1438
|
# cascades across every member list, and one `del` cascade-drops the slug and
|
|
1435
1439
|
# deletes any group it empties. Nothing here has to know that — it just has to
|
|
1436
1440
|
# pass the slug the cursor is on rather than assuming it is a bundle's.
|
|
1441
|
+
# A bundle or group an okf registry *link* brought in is read-only: the file
|
|
1442
|
+
# that owns it is another registry, and okf refuses every config write against
|
|
1443
|
+
# one. The refusal belongs here, before the prompt — letting the ask through
|
|
1444
|
+
# makes a user type a new name and confirm it before learning it could never
|
|
1445
|
+
# land, and this view's own rule is that a key which stops working says so.
|
|
1446
|
+
# True when it refused, so a caller reads as `return if refused_linked?(…)`.
|
|
1447
|
+
def refused_linked?(subject, action)
|
|
1448
|
+
return false if subject.nil? || !subject.linked?
|
|
1449
|
+
|
|
1450
|
+
@message = "#{action} @#{subject.slug} is read-only — it comes from the linked registry " \
|
|
1451
|
+
"@#{subject.link}, so edit it there"
|
|
1452
|
+
true
|
|
1453
|
+
end
|
|
1454
|
+
|
|
1437
1455
|
def ask_rename
|
|
1438
|
-
|
|
1439
|
-
return if
|
|
1456
|
+
subject = detailing_group? ? selected_group : selected_entry
|
|
1457
|
+
return if subject.nil?
|
|
1458
|
+
return if refused_linked?(subject, "renaming")
|
|
1440
1459
|
|
|
1441
|
-
ask(:rename, "rename @#{slug} to:", free_text: true, subject: slug)
|
|
1460
|
+
ask(:rename, "rename @#{subject.slug} to:", free_text: true, subject: subject.slug)
|
|
1442
1461
|
end
|
|
1443
1462
|
|
|
1444
1463
|
def ask_remove
|
|
1445
|
-
|
|
1446
|
-
return if
|
|
1464
|
+
subject = detailing_group? ? selected_group : selected_entry
|
|
1465
|
+
return if subject.nil?
|
|
1466
|
+
return if refused_linked?(subject, "removing")
|
|
1447
1467
|
|
|
1448
|
-
what = detailing_group? ? "group @#{slug}" : "@#{slug}"
|
|
1449
|
-
ask(:remove, "remove #{what} from the registry? (y/n)", free_text: false, subject: slug)
|
|
1468
|
+
what = detailing_group? ? "group @#{subject.slug}" : "@#{subject.slug}"
|
|
1469
|
+
ask(:remove, "remove #{what} from the registry? (y/n)", free_text: false, subject: subject.slug)
|
|
1450
1470
|
end
|
|
1451
1471
|
|
|
1452
1472
|
# The slug the focused pane has selected — a group's when the groups or member
|
|
@@ -1458,6 +1478,7 @@ module OKF::TUI
|
|
|
1458
1478
|
def set_default
|
|
1459
1479
|
entry = selected_entry
|
|
1460
1480
|
return if entry.nil?
|
|
1481
|
+
return if refused_linked?(entry, "defaulting to")
|
|
1461
1482
|
|
|
1462
1483
|
@message = workspace.make_default(entry.slug)
|
|
1463
1484
|
# Making a bundle the default moves it to the front, so the list reorders
|
data/lib/okf/tui/cli.rb
CHANGED
|
@@ -32,7 +32,7 @@ module OKF
|
|
|
32
32
|
-v, --version print the version
|
|
33
33
|
-h, --help print this message
|
|
34
34
|
|
|
35
|
-
The registry is the project-local .okf
|
|
35
|
+
The registry is the project-local .okf.json when one is on the
|
|
36
36
|
path up from here, and $OKF_HOME (default ~/.okf) otherwise — whichever
|
|
37
37
|
one every other `okf` verb run from here resolves to. OKF_NO_DISCOVERY=1
|
|
38
38
|
forces the global one.
|
|
@@ -87,7 +87,7 @@ module OKF
|
|
|
87
87
|
# `cwd: Dir.pwd` is the other half of that: it is what opts this run into
|
|
88
88
|
# registry discovery, mirroring okf's own rule that only its CLI passes a
|
|
89
89
|
# cwd while a library caller stays global-only. Without it the TUI would be
|
|
90
|
-
# the one okf verb that ignores a project-local `.okf
|
|
90
|
+
# the one okf verb that ignores a project-local `.okf.json` sitting
|
|
91
91
|
# right beside the bundles it is being asked about.
|
|
92
92
|
def start(refs)
|
|
93
93
|
return incompatible_okf("cannot answer a search — OKF::Bundle::Search is missing across/prepare/with") unless
|
data/lib/okf/tui/refs.rb
CHANGED
|
@@ -28,7 +28,7 @@ module OKF
|
|
|
28
28
|
# Resolution is also what opts the TUI into registry discovery: Command's
|
|
29
29
|
# `open_registry` is `OKF::Registry.load(cwd: Dir.pwd)`, so a `@slug` here
|
|
30
30
|
# means the same bundle it means to every other okf verb run from the same
|
|
31
|
-
# directory — the project-local `.okf
|
|
31
|
+
# directory — the project-local `.okf.json` when there is one on the
|
|
32
32
|
# path up, the global `$OKF_HOME` registry otherwise.
|
|
33
33
|
class Refs < OKF::CLI::Command
|
|
34
34
|
def self.id
|
data/lib/okf/tui/version.rb
CHANGED
data/lib/okf/tui/views.rb
CHANGED
|
@@ -439,6 +439,7 @@ module OKF::TUI
|
|
|
439
439
|
r.add(" default", :magenta) if entry.default?
|
|
440
440
|
end
|
|
441
441
|
rows << Ui.line(width) { |r| r.add(entry.dir.to_s, :bright_black) }
|
|
442
|
+
rows.concat(linked_rows(app, entry, width))
|
|
442
443
|
rows.concat(membership_rows(app, entry, width))
|
|
443
444
|
rows << Ui.blank_line(width)
|
|
444
445
|
|
|
@@ -500,6 +501,20 @@ module OKF::TUI
|
|
|
500
501
|
# can show one membership, and a bundle can have several. This is the line that
|
|
501
502
|
# answers "did that + land" when the group being edited is scrolled out of the
|
|
502
503
|
# groups pane.
|
|
504
|
+
# Where a linked bundle comes from, and that the config keys will not touch
|
|
505
|
+
# it. On the detail rather than the registry row: that pane is 42 columns and
|
|
506
|
+
# already carries slug, count and `default`, so a marker there would clip on a
|
|
507
|
+
# narrow terminal — and this is the pane where the other "what can I do with
|
|
508
|
+
# this one" lines already live.
|
|
509
|
+
def linked_rows(app, entry, width)
|
|
510
|
+
return [] unless entry.linked?
|
|
511
|
+
|
|
512
|
+
target = app.workspace.link_target(entry.link)
|
|
513
|
+
rows = [ Ui.line(width) { |r| r.add("read-only — linked from @#{entry.link}", :yellow) } ]
|
|
514
|
+
rows << Ui.line(width) { |r| r.add(target.to_s, :bright_black) } if target
|
|
515
|
+
rows
|
|
516
|
+
end
|
|
517
|
+
|
|
503
518
|
def membership_rows(app, entry, width)
|
|
504
519
|
groups = app.workspace.groups.select { |group| group.members.include?(entry.slug) }
|
|
505
520
|
return [] if groups.empty?
|
data/lib/okf/tui/workspace.rb
CHANGED
|
@@ -16,14 +16,22 @@ module OKF::TUI
|
|
|
16
16
|
# or unreadable, and `error` says which — so a row explains itself instead of
|
|
17
17
|
# silently vanishing from the list.
|
|
18
18
|
class Entry
|
|
19
|
-
attr_reader :slug, :dir
|
|
19
|
+
attr_reader :slug, :dir, :link
|
|
20
20
|
attr_accessor :model, :error
|
|
21
21
|
|
|
22
|
-
def initialize(slug:, dir:, default:, registered:)
|
|
22
|
+
def initialize(slug:, dir:, default:, registered:, link: nil)
|
|
23
23
|
@slug = slug
|
|
24
24
|
@dir = dir
|
|
25
25
|
@default = default
|
|
26
26
|
@registered = registered
|
|
27
|
+
@link = link
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Did this bundle arrive through an okf registry link? Browsing one is
|
|
31
|
+
# browsing a bundle, so it reads like any other — but the registry that
|
|
32
|
+
# owns it is another file, and okf refuses every config write against it.
|
|
33
|
+
def linked?
|
|
34
|
+
!@link.nil?
|
|
27
35
|
end
|
|
28
36
|
|
|
29
37
|
def default?
|
|
@@ -52,13 +60,21 @@ module OKF::TUI
|
|
|
52
60
|
# the members are what an edit would change, the leaves are what a search
|
|
53
61
|
# would cover, and for a nested group those are not the same list.
|
|
54
62
|
class Group
|
|
55
|
-
attr_reader :slug, :members, :bundles
|
|
63
|
+
attr_reader :slug, :members, :bundles, :link
|
|
56
64
|
|
|
57
|
-
def initialize(slug:, members:, bundles:, cyclic:)
|
|
65
|
+
def initialize(slug:, members:, bundles:, cyclic:, link: nil)
|
|
58
66
|
@slug = slug
|
|
59
67
|
@members = members
|
|
60
68
|
@bundles = bundles
|
|
61
69
|
@cyclic = cyclic
|
|
70
|
+
@link = link
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# A group an okf registry link brought in — the link's own set, or one the
|
|
74
|
+
# linked file curates. Scopable and searchable like any other; writable by
|
|
75
|
+
# nobody here, since okf persists only the groups this registry owns.
|
|
76
|
+
def linked?
|
|
77
|
+
!@link.nil?
|
|
62
78
|
end
|
|
63
79
|
|
|
64
80
|
# A hand-edited registry can name a cycle, which okf reports by declining to
|
|
@@ -81,7 +97,7 @@ module OKF::TUI
|
|
|
81
97
|
# its CLI passes a cwd and a library caller stays on the global registry. A
|
|
82
98
|
# default here would make the registry an embedding app reads depend on the
|
|
83
99
|
# directory its process happens to be in, and would let the suite discover a
|
|
84
|
-
# `.okf
|
|
100
|
+
# `.okf.json` from wherever `rake` was run.
|
|
85
101
|
#
|
|
86
102
|
# +ref_slugs+ maps a resolved directory to the slug the @ref named it by, so a
|
|
87
103
|
# session built from refs keeps the names the user typed. See Refs#slugs.
|
|
@@ -108,6 +124,15 @@ module OKF::TUI
|
|
|
108
124
|
(registry || open_registry).path
|
|
109
125
|
end
|
|
110
126
|
|
|
127
|
+
# The registry file a link points at — what a refusal has to name, since
|
|
128
|
+
# "edit it there" is useless without saying where there is. nil when nothing
|
|
129
|
+
# is linked under that name.
|
|
130
|
+
def link_target(name)
|
|
131
|
+
return nil unless registry_backed?
|
|
132
|
+
|
|
133
|
+
registry.links_listing.find { |row| row[:slug] == name }&.fetch(:registry)
|
|
134
|
+
end
|
|
135
|
+
|
|
111
136
|
def empty?
|
|
112
137
|
entries.empty?
|
|
113
138
|
end
|
|
@@ -465,7 +490,7 @@ module OKF::TUI
|
|
|
465
490
|
def registry_entries
|
|
466
491
|
registry.listing.map do |row|
|
|
467
492
|
build_entry(slug: row[:slug], dir: row[:dir], default: row[:default],
|
|
468
|
-
registered: true, missing: row[:missing])
|
|
493
|
+
registered: true, missing: row[:missing], link: row[:link])
|
|
469
494
|
end
|
|
470
495
|
end
|
|
471
496
|
|
|
@@ -482,7 +507,7 @@ module OKF::TUI
|
|
|
482
507
|
end
|
|
483
508
|
|
|
484
509
|
Group.new(slug: row[:slug], members: row[:members], bundles: bundles || [],
|
|
485
|
-
cyclic: bundles.nil
|
|
510
|
+
cyclic: bundles.nil?, link: row[:link])
|
|
486
511
|
end
|
|
487
512
|
end
|
|
488
513
|
|
|
@@ -508,8 +533,8 @@ module OKF::TUI
|
|
|
508
533
|
end
|
|
509
534
|
end
|
|
510
535
|
|
|
511
|
-
def build_entry(slug:, dir:, default:, registered:, missing:)
|
|
512
|
-
entry = Entry.new(slug: slug, dir: dir, default: default, registered: registered)
|
|
536
|
+
def build_entry(slug:, dir:, default:, registered:, missing:, link: nil)
|
|
537
|
+
entry = Entry.new(slug: slug, dir: dir, default: default, registered: registered, link: link)
|
|
513
538
|
|
|
514
539
|
if missing
|
|
515
540
|
entry.error = "directory is gone"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: okf-tui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo Serradura
|
|
@@ -15,7 +15,7 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: 2.2.0
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '3'
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 2.
|
|
28
|
+
version: 2.2.0
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '3'
|