Class: DevSystem::NotFoundCommand
Instance Attribute Summary
Attributes inherited from BaseCommand
#env
Instance Method Summary
collapse
#call, #log_simple_remember, #simple_arg, #simple_arg_ask, #simple_arg_ask_snakecase, #simple_args, #simple_boolean, #simple_boolean_no, #simple_boolean_yes, #simple_color, #simple_controller_placement, #simple_string
Methods inherited from BaseCommand
call, #call, get_command_signatures
Methods inherited from Command
call, #call, get_command_signatures
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Instance Method Details
#call_default ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 3
def call_default
h3 "Liza is a light application framework written in Ruby 3.3 ❤", color: DevSystem.color
h5 "We're optimizing for happiness. Come join us!", color: ColorShell.colors.keys.sample
puts
if App.global?
print_global
else
print_systems
print_app
end
end
|
#color(klass) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 18
def color klass
return klass unless klass < Liza::Unit
namespace, _sep, classname = klass.to_s.rpartition('::')
if namespace.empty?
return stick classname, Liza.const(classname).system.color
end
"#{
stick namespace, Liza.const(namespace).system.color
}::#{
stick classname, Liza.const(classname).color
}"
end
|
#h1(text) ⇒ Object
125
126
127
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 125
def h1 text
puts stick " #{ text } ".center(80, "="), :b
end
|
#h2(text, color: :white) ⇒ Object
129
130
131
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 129
def h2 text, color: :white
puts stick " #{ text } ".center(80, "-"), :b, color
end
|
#h3(text, color: :white) ⇒ Object
133
134
135
136
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 133
def h3 text, color: :white
puts
puts stick " #{ text } ".center(80, " "), :b, color
end
|
#h4(system) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 138
def h4 system
puts
s = system.to_s
s1 = s
s1 = "#{ color(system) }" if system < Liza::Unit
color = system.color rescue :white
t = s.rjust(80, " ")
t = "#{ stick t, :b, color }"
t = t.gsub(s, s1)
puts t
end
|
#h5(text, color: :white) ⇒ Object
150
151
152
153
154
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 150
def h5 text, color: :white
puts
puts stick text.ljust(80, " "), color
puts
end
|
#print_app ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 94
def print_app
h1 "TEAM CODE AT app/"
system_name = "dev"
tree_system = AppShell.consts[:app]["dev"]
system = Liza.const "#{system_name}_system"
tree_system["controllers"].each do |family, structure|
structure.each do |division, klasses|
klasses = klasses.select { _1 < Command }
if klasses.any?
h5 "app/#{system_name}/#{division.plural}/", color: system.color
klasses.each { print_class _1 }
end
end
end
end
|
#print_class(klass, description: nil) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 36
def print_class klass, description: nil
loc = klass.to_s
= 30
klass.get_command_signatures.each do |signature|
signature.name =
signature.name.empty? \
? klass.token.to_s
: "#{klass.token}:#{signature.name}"
end.sort_by(&:name).map do |signature|
puts [
"liza #{signature.name}".ljust(),
(description or signature.description)
].join ""
end
end
|
#print_global ⇒ Object
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 112
def print_global
klasses = {
NewCommand => "# Create a new project",
NotFoundCommand => "# This command",
}
klasses.each { print_class _1, description: _2 }
5.times { puts }
end
|
#print_system_sub(system, system_name, tree_system) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 75
def print_system_sub system, system_name, tree_system
tree_system["subsystems"].each do |subsystem, tree_subsystem|
klasses = tree_subsystem["controllers"].values.flatten.select { _1 < Command }
next if klasses.empty?
tree_subsystem["controllers"].each do |controller_class, klasses|
klasses = klasses.select { _1 < Command }
klasses = klasses.reject { _1 <= InputCommand } klasses = klasses.reject { _1 == BaseCommand }
klasses = klasses.reject { _1 == SimpleCommand }
klasses = klasses.reject { _1 == NewCommand }
next if klasses.empty?
h5 "lib/#{system_name}_system/sub/#{subsystem.singular}/#{controller_class.plural}/", color: system.color
klasses.each { print_class _1 }
end
end
end
|
#print_systems ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/dev_system/sub/command/commands/not_found_command.rb', line 56
def print_systems
h1 "SYSTEMS"
AppShell.consts[:systems].each do |system_name, tree_system|
system = tree_system["system"][0]
h4 system
tree_system["controllers"].each do |family, klasses|
klasses = tree_system["controllers"][family].to_a.select { _1 < Command }
next if klasses.empty?
h5 "lib/#{system_name}_system/#{family.plural}/", color: system.color
klasses.each { print_class _1 }
end
print_system_sub system, system_name, tree_system
end
puts
end
|