Class: OKF::CLI::Registry
Overview
The registry umbrella, split by what each verb keys on. set/del/list
act on entries — set keys on the bundle's path, so --as means one thing
("the slug this entry has") whether it adds or renames. default/rename
act on slugs, the names actually to hand once a bundle is registered. Every
positional stays unambiguous, and config is left free for real settings.
Constant Summary
collapse
- SUBCOMMANDS =
The registry umbrella's subcommands — the dispatch, and the words a
flag-first invocation is checked against.
%w[set del list default rename].freeze
Constants inherited
from Command
Command::DUCK_TYPE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
hidden?, #initialize
Class Method Details
.group ⇒ Object
19
20
21
|
# File 'lib/okf/cli/registry.rb', line 19
def self.group
:registry
end
|
.help_rows ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/okf/cli/registry.rb', line 23
def self.help_rows
[
[ "registry list [--json]", "list registered bundles (* marks the default)" ],
[ "registry set <dir|@slug> [--as SLUG] [--default]", "add or update a bundle (a bare `server` serves them)" ],
[ "registry del <dir|@slug>", "remove a bundle from the registry" ],
[ "registry default <@slug>", "move a bundle to the front (the default)" ],
[ "registry rename <@slug> <new>", "rename a registered bundle (<new> is a new name, not a ref)" ]
]
end
|
.id ⇒ Object
15
16
17
|
# File 'lib/okf/cli/registry.rb', line 15
def self.id
:registry
end
|
Instance Method Details
#call(argv) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/okf/cli/registry.rb', line 33
def call(argv)
require "okf/registry"
sub = argv.first
case sub
when "set" then registry_set(argv.drop(1))
when "del" then registry_del(argv.drop(1))
when "list" then registry_list(argv.drop(1))
when "default" then registry_default(argv.drop(1))
when "rename" then registry_rename(argv.drop(1))
else
return usage_error("unknown registry subcommand '#{sub}' (expected: #{SUBCOMMANDS.join(", ")})") if sub && !sub.start_with?("-")
stray = argv.find { |arg| SUBCOMMANDS.include?(arg) }
return usage_error("put the subcommand first: okf registry #{stray} … (flags follow it)") if stray
registry_list(argv)
end
end
|