tasks

package
v0.0.126 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandVars

func ExpandVars(s string, workspaceRoot string) (string, error)

ExpandVars expands ${workspaceFolder}, ${workspaceFolderBasename}, ${env:NAME}. Unknown ${…} tokens return an error.

func Handle

func Handle(args []string) error

Handle is the entry for `kool vscode tasks …`.

func StripJSONC

func StripJSONC(src []byte) []byte

StripJSONC removes // line comments and trailing commas so data can be parsed as standard JSON (VS Code tasks.json style).

func UnmarshalJSONC

func UnmarshalJSONC(data []byte, v interface{}) error

UnmarshalJSONC parses JSONC into v.

Types

type File

type File struct {
	Version string `json:"version"`
	Tasks   []Task `json:"tasks"`
}

File is the top-level tasks.json structure.

func LoadTasks

func LoadTasks(ws *Workspace) (*File, error)

LoadTasks reads and parses tasks.json from the workspace.

func ParseTasksJSON

func ParseTasksJSON(data []byte) (*File, error)

ParseTasksJSON parses JSONC tasks content.

func (*File) ByLabel

func (f *File) ByLabel() map[string]*Task

ByLabel returns a map label -> *Task (first wins).

func (*File) FindSubstring

func (f *File) FindSubstring(query string) []*Task

FindSubstring returns tasks whose labels contain query (case-insensitive).

func (*File) MatchOne

func (f *File) MatchOne(query string) (*Task, error)

MatchOne resolves exact label first, else unique CI substring. Returns error if not found or ambiguous.

type PlanStep

type PlanStep struct {
	Label   string
	Kind    string
	Command string
	Cwd     string
	BG      bool
}

PlanStep is one step in a dry-run plan.

func BuildPlan

func BuildPlan(root *Task, byLabel map[string]*Task, workspaceRoot string) ([]PlanStep, error)

BuildPlan expands dependsOn DAG (deps first, then root) and expands vars. Detects cycles and missing dependencies.

type Task

type Task struct {
	Label        string          `json:"label"`
	Type         string          `json:"type"`
	Command      string          `json:"command"`
	Args         []string        `json:"args"`
	IsBackground bool            `json:"isBackground"`
	Options      *TaskOptions    `json:"options"`
	DependsOnRaw json.RawMessage `json:"dependsOn"`
	DependsOn    []string        `json:"-"`
	Group        json.RawMessage `json:"group"`
}

Task is a VS Code task entry.

func (*Task) CommandPreview

func (t *Task) CommandPreview() string

CommandPreview builds a short command line for list/show.

func (*Task) Kind

func (t *Task) Kind() string

Kind returns shell | process | composite for display.

type TaskOptions

type TaskOptions struct {
	Cwd string `json:"cwd"`
}

TaskOptions holds options.cwd etc.

type Workspace

type Workspace struct {
	Root      string // directory containing .vscode
	TasksPath string
}

Workspace holds the resolved root and tasks.json path.

func FindWorkspace

func FindWorkspace(startDir string) (*Workspace, error)

FindWorkspace walks up from startDir (or cwd) until .vscode/tasks.json exists.

Jump to

Keyboard shortcuts

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