-- lx format

--- Generic command-line syntax for examples and documentation
-- @module format.cli

local format = require("core.format")

format.register({
	name = "Command Line",
	shortname = "CLI",

	patterns = {
		-- Pattern breakdown:
		-- A Windows drive prompt ends at '>', optional spacing follows, then the command begins
		{
			pattern = "(%s*%a:[^>\n]*>)(%s*)([^%s\n]+)",
			type = { "comment", "normal", "function" },
			line_start = true,
		},
		-- Pattern breakdown:
		-- A simple '>', '$', or '#' prompt may be followed by spacing and the command
		{
			pattern = "(%s*[>%$#])(%s*)([^%s\n]+)",
			type = { "comment", "normal", "function" },
			line_start = true,
		},
		-- The first unquoted word is the command when no prompt is present
		{
			pattern = "(%s*)([^%s\n]+)",
			type = { "normal", "function" },
			line_start = true,
		},
		-- Keep quoted arguments together
		{ pattern = { '"', '"', "\\" }, type = "string", delim_type = "operator" },
		{ pattern = { "'", "'", "\\" }, type = "string", delim_type = "operator" },

		-- Long and short dash options share one clear style
		{ pattern = "%-%-[%w][%w_%-]*", type = "keyword" },
		{ pattern = "%-[%w%?][%w_%-]*", type = "keyword" },
	},

	symbols = {},
})
