root

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package root implements the ctx why command.

It displays the philosophy and design rationale behind ctx, including the manifesto and project invariants.

Index

Constants

This section is empty.

Variables

View Source
var DocAliases = map[string]string{
	"manifesto":  "manifesto",
	"about":      "about",
	"invariants": "design-invariants",
}

DocAliases maps user-facing names to embedded asset names.

View Source
var DocOrder = []DocEntry{
	{"manifesto", "The ctx Manifesto"},
	{"about", "About ctx"},
	{"invariants", "Design Invariants"},
}

DocOrder defines the display order for the interactive menu.

Functions

func Cmd

func Cmd() *cobra.Command

Cmd returns the "ctx why" cobra command.

Returns:

  • *cobra.Command: Configured why command with document aliases

func ExtractAdmonitionTitle

func ExtractAdmonitionTitle(line string) string

ExtractAdmonitionTitle pulls the quoted title from an admonition line. e.g., `!!! note "Title"` -> "Title"

Parameters:

  • line: The admonition line to parse

Returns:

  • string: The extracted title, or empty string if no valid title found

func ExtractTabTitle

func ExtractTabTitle(line string) string

ExtractTabTitle pulls the quoted title from a tab marker line. e.g., `=== "Name"` -> "Name"

Parameters:

  • line: The tab marker line to parse

Returns:

  • string: The extracted title, or empty string if no valid title found

func Run

func Run(cmd *cobra.Command, args []string) error

Run dispatches to the interactive menu or direct document display.

Parameters:

  • cmd: Cobra command for output stream
  • args: Command arguments; optional args[0] is the document alias

Returns:

  • error: Non-nil if the document is not found or input is invalid

func ShowDoc

func ShowDoc(cmd *cobra.Command, alias string) error

ShowDoc loads an embedded document by alias, strips MkDocs syntax, and prints it.

Parameters:

  • cmd: Cobra command for output stream
  • alias: Document alias (manifesto, about, or invariants)

Returns:

  • error: Non-nil if the alias is unknown or the document fails to load

func StripMkDocs

func StripMkDocs(content string) string

StripMkDocs removes MkDocs-specific syntax from Markdown content so it reads cleanly in the terminal.

Handles:

  • YAML frontmatter (--- blocks): removed
  • Image refs (![alt](path)): line removed
  • Admonitions (!!! type "Title"): converted to blockquote with bold title
  • Tab markers (=== "Name"): converted to bold name; body dedented
  • Relative .md links (text(file.md)): kept as text only

Parameters:

  • content: Raw Markdown with MkDocs syntax

Returns:

  • string: Cleaned Markdown suitable for terminal display

Types

type DocEntry

type DocEntry struct {
	Alias string
	Label string
}

DocEntry pairs a document alias with its display label.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL