Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 1.72 KB

README.md

File metadata and controls

69 lines (53 loc) · 1.72 KB

task.nvim

Task manager for neovim.

More neovim plugins

Dependencies

Usage

  1. Register tasks
local split_win = require("task.output").use_split_win()

---@class task.Config
---@field cmd string
---@field args string[]
---@field options {env?: table<string, any>, cwd?: string, uid?: number, gid?: number, verbatim?: boolean, detached?: boolean, hide?: boolean} | nil

---@class task.Task
---@field name string
---@field config fun(): task.Config
---@field on_err fun(output: string, write: fun(str), task_name: string) | fun(output: string, write: fun(str), task_name: string)[] | nil
---@field on_output fun(output: string, write: fun(str), task_name: string) | fun(output: string, write: fun(str), task_name: string)[] | nil
---@field on_exit fun(output: string, task_name: string) | fun(output: string, task_name: string)[] | nil

---@param task task.Task
require("task").register({
	name = "restart conatiner",
	config = function()
		return {
			cmd = "sudo",
			args = { "-S", "podman", "restart", "openresty" },
		}
	end,
	on_err = function(output, write)
		if string.match(output, "%[sudo%] password for.*") then
			-- write to stdin
			write("password\n")
		end
	end,
	on_exit = {
		require("task.output").notify_done,
		split_win,
	},
})
  1. Launch task
---@param task_name string | nil
require("task").launch()
  1. Preview output
---@param task_name string | nil
---@param output_method fun(output: string, task_name: string) | nil
require("task").preview()

For builtin output methods, check lua/task/output.lua.