Documentation
¶
Overview ¶
Package example provides the Bonzai command branch of the same name.
Copyright 2022 AutoPDF Pedro Branquinho SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BarCmd = &Z.Cmd{ Name: `bar`, Aliases: []string{"B", "notbar"}, Commands: []*Z.Cmd{help.Cmd, fileCmd}, Call: func(_ *Z.Cmd, _ ...string) error { log.Printf("would bar stuff") return nil }, }
exported branch
View Source
var BazCmd = &Z.Cmd{ Name: `baz`, Aliases: []string{"Bz", "notbaz"}, Commands: []*Z.Cmd{help.Cmd, fileCmd}, Call: func(caller *Z.Cmd, none ...string) error { log.Print("Baz, suncreen song") return nil }, }
exported leaf
View Source
var CleanCmd = &Z.Cmd{ Name: `clean`, Call: func(caller *Z.Cmd, none ...string) error { cmd := exec.Command("/bin/bash", "-c", "rm -rf pdfs/*.log pdfs/*.aux pdfs/*.synctex.gz pdfs/*.out pdfs/*.toc pdfs/*.fls pdfs/*.fdb_latexmk") err := cmd.Run() if err != nil { log.Fatal(err) } return nil }, }
exported leaf
View Source
var Cmd = &Z.Cmd{ Name: `example`, Summary: `an example of Bonzai composite command tree, for generating PDFs using LaTeX`, Version: `v0.1.1`, Copyright: `Copyright 2023 Pedro G. Branquinho`, License: `Apache-2.0`, Site: `buddhilw.com`, Source: `git@github.com:BuddhiLW/AutoPDF.git`, Issues: `github.com/BuddhiLW/AutoPDF/issues`, Commands: []*Z.Cmd{ help.Cmd, conf.Cmd, vars.Cmd, BarCmd, ownCmd, pkgexampleCmd, CompileCmd, CleanCmd, BazCmd, }, Dynamic: template.FuncMap{ "uname": func(_ *Z.Cmd) string { return Z.Out("uname", "-a") }, "dir": func() string { return Z.Out("dir") }, }, Description: ` The {{aka}} command is a well-documented example to get you started. You can start the description here and wrap it to look nice and it will just work. Descriptions are written in BonzaiMark, a simplified combination of CommonMark, "go doc", and text/template that uses the Cmd itself as a data source and has a rich set of builtin template functions ({{pre "pre"}}, {{pre "exename"}}, {{pre "indent"}}, etc.). There are four block types and four span types in BonzaiMark: Spans Plain *Italic* **Bold** ***BoldItalic*** <Under> (brackets remain) Note that on most terminals italic is rendered as underlining and depending on how old the terminal, other formatting might not appear as expected. If you know how to set LESS_TERMCAP_* variables they will be observed when output is to the terminal. Blocks 1. Paragraph 2. Verbatim (block begins with ' ', never first) 3. Numbered (block begins with '* ') 4. Bulleted (block begins with '1. ') Currently, a verbatim block must never be first because of the stripping of initial white space. Templates Anything from Cmd that fulfills the requirement to be included in a Go text/template may be used. This includes {{ "{{ cmd .Name }}" }} and the rest. A number of builtin template functions have also been added (such as {{ "indent" }}) which can receive piped input. You can add your own functions (or overwrite existing ones) by adding your own Dynamic template.FuncMap (see text/template for more about Go templates). Note that verbatim blocks will need to indented to work: {{ "{{ dir | indent 4 }}" }} Produces a nice verbatim block: {{ dir | indent 4 }} Note this is different for every user and their specific system. The ability to incorporate dynamic data into any help documentation is a game-changer not only for creating very consumable tools, but creating intelligent, interactive training and education materials as well. Templates Within Templates Sometimes you will need more text than can easily fit within a single action. (Actions may not span new lines.) For such things defining a template with that text is required and they you can include it with the {{pre "template" }} tag. {{define "long" -}} Here is something that spans multiple lines that would otherwise be too long for a single action. {{- end}} Something `, Other: []Z.Section{ {`Custom Sections`, ` Additional sections can be added to the Other field. A Z.Section is just a Title and Body and can be assigned using composite notation (without the key names) for cleaner, in-code documentation. The Title will be capitalized for terminal output if using the common help.Cmd, but should use a suitable case for appearing in a book for other output renderers later (HTML, PDF, etc.)`, }, }, }
Cmd provides a Bonzai branch command that can be composed into Bonzai trees or used as a standalone with light wrapper (see cmd/).
View Source
var CompileCmd = &Z.Cmd{ Name: `compile`, Call: func(caller *Z.Cmd, none ...string) error { log.Print("Baz, suncreen song") cmd := exec.Command("/bin/bash", "-c", "pdflatex -synctex=1 -interaction=nonstopmode -output-directory=pdfs tex-models/main.tex") err := cmd.Run() if err != nil { log.Fatal(err) } return nil }, }
exported leaf
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.