// CLI documentation viewer using markdown_ansi() and markdown_text() builtins // Called by: duso -doc // Get the topic from sys datastore (set by CLI) sys_ds = datastore("sys") topic = sys_ds.get("doc_topic") if not topic then // kind of a hack, we're pulling main readme // not sure i love this here. raw_doc = load("/EMBED/README.md") else raw_doc = doc(topic) end if raw_doc == nil then raw_doc = """ **Can't find a doc for: `{{topic}}`** # Usage ``` duso -doc TOPIC ``` ## Some Examples ``` duso -doc print duso -doc split duso -doc require ``` ## Function Index ``` duso -doc index ``` """ end print() // Check -no-color flag or NO_COLOR environment variable if sys("-no-color") or env("NO_COLOR") then // Render to plain text (no colors, no HTML, just text) print(markdown_text(raw_doc)) else // Render to ANSI with colors print(markdown_ansi(raw_doc)) end