def roff_view
cli@0.2.0.0 · cli.bend:7576
import cli@0.2.0.0/cli.bend as Cli
import Base
7576def roff_view(view: View, title: String) -> String:
7577 match view:
7578 case View{+path, +about, +items, +globals, root, stuck}:
7579 +words = String.split(path, ' ')
7580 +page = String.join(words, "-")
7581 +args = List.append(&2, Item, items, globals)
7582 text_lines(List.concat(&2, String, [
7583 [String.concat([".TH \"", roff_text(String.to_upper(page)),
7584 "\" \"1\" \"\" \"", roff_text(title), "\" \"User Commands\""]),
7585 ".SH NAME",
7586 Roff.esc(String.concat([page, " - ", one_line(about)])),
7587 ".SH SYNOPSIS",
7588 roff_synopsis(segment_texts(usage_elems(path, items, globals)))],
7589 roff_section("DESCRIPTION", roff_paras(about, ".PP")),
7590 roff_section("ARGUMENTS", roff_positionals(items)),
7591 [".SH OPTIONS"],
7592 roff_options(args, ""),
7593 roff_builtins(builtin_opts(items, globals, root)),
7594 roff_headings(heading_titles(args, []), args),
7595 roff_section("COMMANDS", roff_commands(items, page)),
7596 roff_section("ENVIRONMENT", roff_envs(args)),
7597 [".SH EXIT STATUS", ".TP", "\\fB0\\fR", "Success", ".TP", "\\fB1\\fR",
7598 "Failure", ".TP", "\\fB2\\fR", "Usage error", ".TP", "\\fB70\\fR",
7599 "Internal software error"],
7600 roff_section("EXAMPLES", roff_examples(items, [])),
7601 roff_section("NOTES",
7602 roff_paras(String.join(after_texts(items), "\n\n"), ".PP")),
7603 roff_section("SEE ALSO", roff_see(List.append(&2, String,
7604 parent_pages(words), sub_pages(items, page)))),
7605 ]))