Documentation
¶
Overview ¶
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Copyright © 2026 Nikolas Pikall <nikolas.pikall@gmail.com>
SPDX-License-Identifier: MIT License See the LICENSE file in the repository root for full license text.
Index ¶
- Variables
- func BuildIgnoreMatcher(dir string) *ignore.GitIgnore
- func BumpRunner(cmd *cobra.Command, args []string) error
- func CheckFileExists(path string) error
- func CheckImportStatement(imp string, result *CheckResult, index map[string]string, indexErr error) error
- func CheckImports(linesCh <-chan string, resultCh chan<- *CheckResult)
- func CheckPackageExists(imp string, result *CheckResult, index map[string]string, indexErr error) error
- func CheckPackageExistsLocally(namespace, pkg, version string) error
- func CheckPackageInTypstUniverse(pkg, version string, result *CheckResult, index map[string]string, ...) error
- func CheckRunner(cmd *cobra.Command, args []string) error
- func CopyFile(src, dest string) error
- func CopyPackageFiles(src, dest string) error
- func Execute()
- func ExtractImportStatements(targetFile []byte) [][]byte
- func InitRunner(cmd *cobra.Command, args []string) error
- func InstallRunner(cmd *cobra.Command, args []string) error
- func IsDirPath(path string) bool
- func LookupVersion(ctx context.Context, index map[string]string, pkgName string) (string, string, error)
- func ParsePackageRef(importStatement []byte) (string, string)
- func PrintMissingf(format string, a ...any)
- func ReadIgnoreLines(path string) []string
- func RemoveTarget(target string) error
- func ResolvePackageIdentity(args []string, flags UninstallFlags) (string, string, error)
- func ResolvePackageIdentityFromWorkingDir(args []string, version string, deleteAll bool, dir string) (string, string, error)
- func ResolveProvidedPath(rawPath string) (string, error)
- func ResolveSourceDir(args []string) (string, error)
- func ResolveUninstallTarget(pkgDir, namespace, name, version string, deleteAll bool) string
- func RunTransferJobs(jobs []TransferJob) error
- func ScanFileForImports(path string, importCh chan<- string) error
- func ScanPackages(root string) ([]packageNamespace, error)
- func ShouldIgnore(rel string, matcher *ignore.GitIgnore) bool
- func SymlinkPackage(src, dest string) error
- func UpdateFileContent(content *[]byte, versions map[string]Result)
- func ValidateDestinationConflict(path string) error
- func ValidateIsDirectory(path string) error
- func ValidateNamespace(namespace string) error
- func ValidateTargetExists(target string) error
- func WriteOutputContent(content []byte, inputFilePath string, outputPath string) error
- type CheckResult
- type Destination
- func BuildDestination(dataDir string, manifest internal.Manifest, namespace string) Destination
- func ResolveDefaultDestination(dataDir string, manifest internal.Manifest, opts InstallOptions) (Destination, error)
- func ResolveOverriddenDestination(dataDir string, manifest internal.Manifest, opts InstallOptions) (Destination, error)
- type ImportIssue
- type InstallOptions
- type Result
- type ResultItem
- type TransferJob
- type UninstallFlags
- type VersionWarning
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingFile = errors.New("expected file argument") ErrBadImport = errors.New("not a valid import statement") ErrPackageNotFound = errors.New("package not found locally") ErrPackageNotInIndex = errors.New("package not found in typst universe") ErrFileNotFound = errors.New("file not found") )
var ( ErrTooManyArguments = errors.New("too many arguments: expected one directory path") ErrEmptyNamespace = errors.New("namespace must not be empty") ErrPackageAlreadyInstalled = errors.New("package already installed at destination") ErrNotADirectory = errors.New("path is not a directory") )
var ( ErrUpdateDevelopmentBuild = errors.New("cannot self-update a development build; install a tagged release first") ErrUpdateBrewBuild = errors.New("gotpm was installed via Homebrew; update with: brew upgrade gotpm") )
var ( ErrMissingInput = errors.New("no input: provide a file argument or pipe content via stdin") ErrInvalidOutputOption = errors.New("option '--output' cannot be used with multiple files or a directory") )
var ErrInsufficientPackage = errors.New("both package and version must be specified")
var ErrMissingArgument = errors.New("argument must be provided, can be one of [major|minor|patch] or a valid semver")
var ErrNoPackages = errors.New("no packages installed")
var IgnoredFileNames = map[string]struct{}{
".git": {},
".gitignore": {},
".typstignore": {},
}
var LibFile = []byte("#let greet(name) = [Hello #name]")
Functions ¶
func BuildIgnoreMatcher ¶ added in v0.3.13
func CheckFileExists ¶ added in v0.3.13
func CheckImportStatement ¶ added in v0.3.13
func CheckImports ¶ added in v0.3.13
func CheckImports(linesCh <-chan string, resultCh chan<- *CheckResult)
func CheckPackageExists ¶ added in v0.3.13
func CheckPackageExistsLocally ¶ added in v0.3.13
func CheckPackageInTypstUniverse ¶ added in v0.3.13
func CopyPackageFiles ¶ added in v0.3.13
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func ExtractImportStatements ¶ added in v0.3.13
func IsDirPath ¶ added in v0.3.13
IsDirPath reports whether path is a directory, following symlinks.
func LookupVersion ¶ added in v0.3.13
func LookupVersion(ctx context.Context, index map[string]string, pkgName string) (string, string, error)
LookupVersion queries the Typst package index first and falls back to the GitHub API for missing packages or when the index is unavailable. Returns the version, its source ("index" or "github"), and any error.
func ParsePackageRef ¶ added in v0.3.13
func PrintMissingf ¶ added in v0.3.13
func ReadIgnoreLines ¶ added in v0.3.13
func RemoveTarget ¶ added in v0.3.13
RemoveTarget removes target from disk. When target is a symlink, only the link is removed, not the directory it points to. When target is a regular file or directory, it is removed with all its contents.
func ResolvePackageIdentity ¶ added in v0.3.13
func ResolvePackageIdentity(args []string, flags UninstallFlags) (string, string, error)
func ResolvePackageIdentityFromWorkingDir ¶ added in v0.3.13
func ResolvePackageIdentityFromWorkingDir(args []string, version string, deleteAll bool, dir string) (string, string, error)
ResolvePackageIdentityFromWorkingDir returns the package name and version to uninstall. When a name is provided as an argument it is taken from CLI args; otherwise both are read from the typst.toml in dir.
func ResolveProvidedPath ¶ added in v0.3.13
func ResolveSourceDir ¶ added in v0.3.13
func ResolveUninstallTarget ¶ added in v0.3.13
ResolveUninstallTarget builds the path of the directory to remove. When deleteAll is true and no version is given, the package directory (all versions) is targeted; otherwise a specific version directory is used.
func RunTransferJobs ¶ added in v0.3.13
func RunTransferJobs(jobs []TransferJob) error
func ScanFileForImports ¶ added in v0.3.13
func ScanPackages ¶ added in v0.3.13
ScanPackages walks root (namespace/package/version layout) and returns all installed packages, including editable (symlinked) versions.
func SymlinkPackage ¶ added in v0.3.13
SymlinkPackage creates a symlink at dest pointing to the absolute path of src. The parent directory of dest is created if it does not exist.
func UpdateFileContent ¶ added in v0.3.2
UpdateFileContent updates all typst package import statements in content with the versions provided by the name→version mapping.
func ValidateDestinationConflict ¶ added in v0.3.13
func ValidateIsDirectory ¶ added in v0.3.13
func ValidateNamespace ¶ added in v0.3.13
func ValidateTargetExists ¶ added in v0.3.13
ValidateTargetExists returns an error when there is nothing at target to remove. Uses Lstat so a dangling symlink still counts as "present".
Types ¶
type CheckResult ¶ added in v0.3.13
type CheckResult struct {
Items []ResultItem
}
func (*CheckResult) Add ¶ added in v0.3.13
func (r *CheckResult) Add(item ResultItem)
func (*CheckResult) HasIssues ¶ added in v0.3.13
func (r *CheckResult) HasIssues() bool
func (*CheckResult) Print ¶ added in v0.3.13
func (r *CheckResult) Print()
type Destination ¶ added in v0.3.5
func BuildDestination ¶ added in v0.3.13
func BuildDestination(dataDir string, manifest internal.Manifest, namespace string) Destination
func ResolveDefaultDestination ¶ added in v0.3.13
func ResolveDefaultDestination(dataDir string, manifest internal.Manifest, opts InstallOptions) (Destination, error)
ResolveDefaultDestination is used for the standard install path. It appends namespace/name/version sub-directories to dataDir.
func ResolveOverriddenDestination ¶ added in v0.3.13
func ResolveOverriddenDestination(dataDir string, manifest internal.Manifest, opts InstallOptions) (Destination, error)
ResolveOverriddenDestination is used when --install-dir or $GOTPM_INSTALL_DIR is set. dataDir is used as the final install path without appending namespace/name/version.
type ImportIssue ¶ added in v0.3.13
ImportIssue is a hard error — a dependency that could not be found.
func (ImportIssue) IsError ¶ added in v0.3.13
func (i ImportIssue) IsError() bool
func (ImportIssue) Print ¶ added in v0.3.13
func (i ImportIssue) Print()
type InstallOptions ¶ added in v0.3.12
InstallOptions holds the resolved install flags.
func ReadInstallOptions ¶ added in v0.3.13
func ReadInstallOptions(cmd *cobra.Command) (InstallOptions, error)
type ResultItem ¶ added in v0.3.13
type ResultItem interface {
Print()
IsError() bool
}
ResultItem is implemented by any diagnostic that can be collected in a CheckResult.
type TransferJob ¶ added in v0.3.13
func CollectJobs ¶ added in v0.3.13
func CollectJobs(src, dest string, matcher *ignore.GitIgnore) ([]TransferJob, error)
type UninstallFlags ¶ added in v0.3.13
func ReadUninstallFlags ¶ added in v0.3.13
func ReadUninstallFlags(cmd *cobra.Command) (UninstallFlags, error)
type VersionWarning ¶ added in v0.3.13
VersionWarning is a soft warning — import found but a newer version exists.
func (VersionWarning) IsError ¶ added in v0.3.13
func (w VersionWarning) IsError() bool
func (VersionWarning) Print ¶ added in v0.3.13
func (w VersionWarning) Print()