Skip to main content

CLI and Go API reference

Sunset has a local CLI and a public Go parsing package. The CLI has no network authentication or service endpoint.

For the product-specific guides, see CLI overview, parse and update, Go API overview, and node and tree operations.

CLI commands

CommandSyntaxBehavior
parsesunset parse <path> [flags]Parse a file or directory and generate Markdown. An omitted path means ..
updatesunset update [path] [flags]Re-parse changed files using the cache and summary output.
languagessunset languagesPrint supported language IDs and extensions.
versionsunset versionPrint sunset <version>.
cleansunset clean [path]Remove <path>/.sunset, including cache and output.
helpsunset helpPrint top-level help. --help and -h do the same.

The root flags --version and -v print the version. A missing or unknown command prints help; an unknown command exits non-zero.

Parse flags

FlagDefaultEffect
--output<path>/.sunset/outputSelect the Markdown output directory.
--detailsummaryUse summary or full; any value other than full selects summary mode.
--excludeemptyComma-separated filename or relative-path glob patterns.
--concurrencyNumCPUMaximum concurrent parser work when positive.
--no-cachefalseForce a full re-parse and do not load or save cache state.
--max-depth0Limit full-CST depth; zero means unlimited.
--quietfalseSuppress normal progress and result output.

update accepts --output, --exclude, --concurrency, and --quiet. It does not accept the parse-only detail, cache, or CST-depth flags.

Generated output

Each file document starts with YAML frontmatter containing file, language, optional Go package, lines, function/type/import counts, and tags. Summary sections include signatures and 1-based line ranges; imports include their source line. The project index records language statistics, totals, generated time, version, and directory modules.

Go API

Import the public package with the module path declared in go.mod:

import "github.com/enolalabs/sunset/pkg/sunset"

The main functions and types are:

  • ParseFile(path string, opts ...Option) (*FileResult, error) reads one file, detects its language from the extension, and returns source bytes plus a TreeWrapper.
  • WithLanguage(id string) Option forces a registered language ID such as go, javascript, typescript, or python.
  • Languages() []LanguageInfo returns the registered names, IDs, and extensions.
  • FileResult.Close() releases tree-sitter resources. Call it when finished.
  • FileResult.HasErrors() reports syntax errors while the result is open.
  • TreeWrapper.RootNode(), Walk, and Filter expose tree traversal.
  • Node.Type, Text, Position, EndPosition, Children, NamedChildren, ChildByFieldName, Parent, IsNamed, IsError, IsMissing, and ChildCount inspect nodes.

Node.Position and EndPosition use zero-based rows and columns. This differs from the generated summary's human-facing line numbers, which are one-based.