3 description "Display this help message."
6 set _topic [Commands::Args]
7 if {[llength $_topic] == 0} {
10 Help::RenderPath $_topic
17 description "Flow help. Usage: HELP FLOWS \[<tool>\] \[<flow>\]"
20 set _tool_arg [Commands::Arg 0]
21 set _flow_arg [Commands::Arg 1]
23 if {$_tool_arg eq ""} {
24 puts "TODO: dedicated flows overview page"
28 # Resolve tool alias to namespace.
30 foreach ns [namespace children ::Tools] {
31 if {[string tolower [namespace tail $ns]] eq [string tolower $_tool_arg]} {
36 if {$_tool_ns eq ""} {
38 foreach ns [lsort [namespace children ::Tools]] { lappend _avail_list [string tolower [namespace tail $ns]] }
39 puts "Unknown tool '$_tool_arg'. Available tools: [join $_avail_list {, }]"
43 # GetChildren is a raw prefix-scan over real canons, never alias-aware, so
44 # resolve the tool's real canon via GetCommand first, not a guessed
45 # string (same pattern as Help::_tool_group_rows).
46 set _tnode [Commands::GetCommand [string toupper [namespace tail $_tool_ns]]]
47 set _flow_root "[tdict getval $_tnode canon].FLOW"
49 if {$_flow_arg eq ""} {
50 set _kids [Commands::GetChildren $_flow_root]
51 if {[llength $_kids] == 0} {
52 puts "\nTool [namespace tail $_tool_ns] declares no flows.\n"
55 puts "\nFlows for [namespace tail $_tool_ns]:"
56 foreach _c $_kids { puts [Help::_child_row [Commands::GetCommand $_c] 2] }
61 set _fnode [Commands::GetCommand "$_flow_root.$_flow_arg"]
63 puts "Tool [namespace tail $_tool_ns] has no flow '$_flow_arg'."
66 # A flow renders through the ordinary command page - it is an ordinary node.
67 Help::RenderCommand $_fnode [list [string tolower [namespace tail $_tool_ns]] \
68 FLOW [tdict getval $_fnode name]]
74 description "Overview of registered tools (built-in vs custom). Usage: HELP TOOLS \[<tool>\]"
77 set _which [Commands::Arg 0]
78 if {$_which eq ""} { Help::RenderToolList } else { Help::RenderTool $_which }
87 proc _aliases {obj name} {
89 if {[tobj isobj $obj] && [tobj type $obj] eq "List"} {
90 foreach a [tobj value $obj] {
91 set al [
string tolower [tobj value $a]]
92 if {$al ne [
string tolower $name]} {
lappend als $al}
96 set al [
string tolower $a]
97 if {$al ne [
string tolower $name]} {
lappend als $al}
100 return [
expr {[llength $als] > 0 ? "([join $als {, }])" : ""}]
104 proc _options_string {obj_list {indent 0}} {
105 set pad [
string repeat " " $indent]
107 foreach _option $obj_list {
108 set n [
llength $_option]
110 lassign $_option opt help
111 append out [
format "%s%-20s %s\n" $pad "-$opt" $help]
113 lassign $_option opt def help
114 set suffix [
expr {$def ne "" ? " (default: $def)" : ""}]
115 append out [
format "%s%-20s %s%s\n" $pad "-$opt <arg>" $help $suffix]
117 Msg Warning "Custom option spec has invalid arity (expected 2 or 3): $_option"
124 puts "[
string repeat "=" 80]\nHog Launcher - Help\n[
string repeat "=" 80]"
128 proc _tool_groups {} {
131 foreach ns [lsort [
namespace children ::Tools]] {
132 if {[
catch {
set m [${ns}::GetManifest]}]} continue
133 if {[dict exists $m custom] && [dict get $m custom]} {
139 return [list $_builtin $_custom]
144 proc _child_row {node indent} {
145 if {$node eq {}} {
return ""}
146 set name [tdict getval $node name]
150 return [
format "%s%-17s %-12s %s" \
151 [
string repeat " " $indent] \
153 [
_aliases [tdict getobjor $node aliases [tlist create]] [tdict getval $node name]] \
154 [tdict getor $node description ""]]
157 proc RenderPath {path} {
161 if {[
llength $_resolved] > 0 && [
llength [dict get $_resolved remaining]] == 0} {
163 set _node [dict get $_resolved node]
165 RenderTool [
string tolower [tdict getval $_node name]]
173 set _first [
string toupper [
lindex $path 0]]
179 puts "Unknown help topic: [
join $path { }]"
184 proc RenderTopLevel {} {
187 puts "usage: ./Hog/Do <directive> \[project\] \[OPTIONS\]"
190 set _fmt_tool_row {{ns} {
191 if {[catch {set m [${ns}::GetManifest]} err]} { return "" }
192 set vendor [expr {[dict exists $m vendor] ? " ([dict get $m vendor])" : ""}]
193 return [format " %-12s %s%s" [string tolower [namespace tail $ns]] [dict get $m name] $vendor]
196 puts "Built-in tools:"
197 foreach ns $_builtin_tools {
198 set _row [
apply $_fmt_tool_row $ns]
199 if {$_row ne ""} {
puts $_row}
201 if {[
llength $_custom_tools] > 0} {
202 puts "\nCustom tools:"
203 foreach ns $_custom_tools {
204 set _row [
apply $_fmt_tool_row $ns]
205 if {$_row ne ""} {
puts $_row}
210 set _fmt_cmd_row {{cmd} {
211 return [format " %-10s %s" [tdict getval $cmd name] [tdict getor $cmd description ""]]
214 puts "General directives:"
216 if {[Commands::Node::IsTool $cmd]} { continue }
217 if {[tdict getor $cmd custom 0]} { continue }
218 puts [apply $_fmt_cmd_row $cmd]
223 if {[Commands::Node::IsTool $cmd]} { continue }
224 if {![tdict getor $cmd custom 0]} { continue }
225 if {!$_has_custom} { puts "\nCustom commands:"; set _has_custom 1 }
226 puts [apply $_fmt_cmd_row $cmd]
232 CREATE "Create the project, replace it if already existing."
233 SYNTH "Run synthesis only, create the project if not existing."
234 IMPLEMENTATION "Run implementation only, project must already exist and be synthesised."
235 SIMULATION "Simulate the project, creating it if not existing."
236 WORKFLOW "Run the full workflow, creates the project if not existing."
237 CREATEWORKFLOW "Create the project (even if existing) and run the complete workflow."
239 puts "Common project flows (require a project):"
240 dict for {_fn _desc} $_common_flows {
241 puts [format " %-16s %s" $_fn $_desc]
245 puts "Additional information:"
246 puts " Help for a specific directive: ./Hog/Do HELP <directive> or ./Hog/Do <directive> --help"
247 puts " List every tool: ./Hog/Do HELP TOOLS"
248 puts " Help for a tool: ./Hog/Do HELP <tool> or ./Hog/Do HELP TOOLS <tool>"
249 puts " Help for a flow across tools: ./Hog/Do HELP <flow>"
250 puts " Help for a tool's flow: ./Hog/Do HELP FLOWS <tool> <flow>"
255 proc _tool_group_rows {label tools} {
256 if {[
llength $tools] == 0} {
return}
259 set _m [${ns}::GetManifest]
260 set _short [
string tolower [
namespace tail $ns]]
265 set _als [
_aliases [tdict getobjor $_node aliases [tlist create]] \
266 [tdict getval $_node name]]
270 set _real_canon [
expr {$_node ne {} ? [tdict getval $_node canon] : ""}]
281 if {$_nflow > 0} {
lappend _offers "$_nflow flow[
expr {$_nflow == 1 ? {} : {s}}]"}
282 if {$_nstage > 0} {
lappend _offers "$_nstage stage[
expr {$_nstage == 1 ? {} : {s}}]"}
283 if {$_ncmd > 0} {
lappend _offers "$_ncmd command[
expr {$_ncmd == 1 ? {} : {s}}]"}
284 if {[
llength $_offers] == 0} {
set _offers [list "nothing registered"]}
287 set _line2 [
join $_offers {, }]
288 if {$_als ne ""} {
append _line2 " aka [
string trim $_als {()}]"}
289 puts [
format " %-12s %s" $_short [dict get $_m name]]
290 puts [
format " %-12s %s" "" $_line2]
296 proc RenderToolList {} {
302 puts " A tool's own page: ./Hog/Do HELP TOOLS <tool> (or HELP <tool>)"
303 puts " Run a tool's command: ./Hog/Do <tool> <command> \[OPTIONS\]"
304 puts " Run a tool's flow: ./Hog/Do <tool> FLOW <flow> <project>"
309 proc RenderTool {alias} {
311 if {$_tns eq "" || [
catch {${_tns}::GetManifest} _m]} {
313 foreach ns [lsort [
namespace children ::Tools]] {
lappend _avail_list [
string tolower [
namespace tail $ns]]}
314 puts "Unknown tool '$alias'. Available tools: [
join $_avail_list {, }]"
317 set _canon [
string tolower [
namespace tail $_tns]]
322 set _tnode [
expr {[llength $_r] > 0 ? [dict get $_r node] : {}}]
324 set _tname [dict get $_m name]
327 set _alias_str [
_aliases [tdict getobjor $_tnode aliases [tlist create]] \
328 [tdict getval $_tnode name]]
330 puts "Tool: $_tname $_alias_str"
331 if {[dict get $_m vendor] ne ""} {
puts " Vendor: [dict get $_m vendor]"}
332 if {[dict get $_m description] ne ""} {
puts " Description: [dict get $_m description]"}
333 if {[dict get $_m version] ne ""} {
puts " Version: [dict get $_m version]"}
334 if {[dict get $_m custom]} {
puts " Origin: custom (user-defined)"}
335 if {[dict get $_m _source_path] ne ""} {
puts " Source: [dict get $_m _source_path]"}
336 puts " Version Info:"
337 set _git [dict get $_m _git]
338 if {[dict size $_git] > 0} {
339 dict for {_gk _gv} $_git {
340 if {$_gv ne ""} { puts [format " %-10s %s" $_gk $_gv] }
343 if {[
llength [dict get $_m features]] > 0} {
344 puts " Features: [
join [dict get $_m features] {, }]"
352 if {$_snode eq {}} { continue}
354 lappend _groups $_child_canon
357 if {!$_cmd_hdr} {
puts "Usage: ./Hog/Do $_canon <command> \[OPTIONS\]\n\nCommands: (* - requires project)"
set _cmd_hdr 1}
361 foreach _g $_groups {
363 puts "\n[
string totitle $_gname]s (run via 'tool $_canon $_gname <$_gname> <project>'):"
373 proc RenderFlows {flow_name} {
374 puts "Flows matching '$flow_name':"
377 if {[
llength $_r] == 0 || [
llength [dict get $_r remaining]] > 0} { continue}
378 set _fnode [dict get $_r node]
379 if {$_fnode eq {}} { continue}
380 set _short [
string tolower $_tool_key]
381 set _fname [tdict getval $_fnode name]
383 puts " $_short: $_fname [
_aliases [tdict getobjor $_fnode aliases [tlist create]] $_fname]"
384 if {[tdict getor $_fnode custom 0]} {
puts " (custom flow — user-defined)"}
385 if {[tdict getor $_fnode description ""] ne ""} {
386 puts " [tdict getor $_fnode description ""]"
389 if {[
llength $_stages] > 0} {
puts " Stages: [
join $_stages { -> }]"}
390 puts " Run './Hog/Do HELP FLOWS $_short [
string tolower $_fname]' for full options."
396 proc RenderCommand {_node _path} {
398 set _custom_help [tdict getor $_node help ""]
399 if {$_custom_help ne ""} { uplevel #0 $_custom_help
return}
401 set _pretty [
join $_path { }]
402 set _has_subs [
expr {[llength [Commands::GetChildren [tdict getval $_node canon]]] > 0}]
404 set _req_proj [tdict getor $_node requires_proj 0]
405 set _proj_arg [
expr {$_req_proj ? {<project> } : {}}]
407 if {$_has_subs && $_run} {
408 puts "Usage: ./Hog/Do $_pretty ${_proj_arg}\[<subcommand>\] \[OPTIONS\]"
409 }
elseif {$_has_subs} {
410 puts "Usage: ./Hog/Do $_pretty ${_proj_arg}<subcommand> \[OPTIONS\]"
412 puts "Usage: ./Hog/Do $_pretty ${_proj_arg}\[OPTIONS\]"
414 if {$_req_proj} {
puts " Requires: project"}
416 puts "$_pretty [
_aliases [tdict getobjor $_node aliases [tlist create]] [tdict getval $_node name]]:"
417 puts " [tdict getor $_node description ""]"
418 if {[tdict getor $_node custom 0]} {
puts " (custom — user-defined)"}
423 if {[
llength $_stages] > 0} {
425 puts " [
join $_stages { -> }]"
429 if {$_run && [
llength $_opts] > 0} {
435 puts "\n Subcommands: (* - requires project)"