Skip to content

v.util.diff #

fn available_tools #

fn available_tools() []DiffTool

Allows public checking for the available tools and prevents repeated searches when using compare functions with automatic diff tool detection.

fn color_compare_files #

deprecated: use `compare_files` instead
deprecated_after: 2024-06-30
fn color_compare_files(diff_cmd string, path1 string, path2 string) string

color_compare_files returns a colored diff between two files.

fn color_compare_strings #

deprecated: use `compare_text` instead
deprecated_after: 2024-06-30
fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string

color_compare_strings returns a colored diff between two strings.

fn compare_files #

fn compare_files(path1 string, path2 string, opts CompareOptions) !string

compare_files returns a string displaying the differences between two files.

fn compare_text #

fn compare_text(text1 string, text2 string, opts CompareOptions) !string

compare_text returns a string displaying the differences between two strings.

fn find_working_diff_command #

deprecated
deprecated_after: 2024-06-30
fn find_working_diff_command() !string

find_working_diff_command returns the first available command from a list of known diff cli tools.

enum DiffTool #

enum DiffTool {
	auto
	diff // core package on Unix-like systems.
	colordiff // `diff` wrapper.
	delta // viewer for git and diff output.
	// fc // built-in tool on windows. // TODO: enable when its command output can be read.
}

struct CompareOptions #

@[params]
struct CompareOptions {
pub:
	tool DiffTool
	// Custom args used with the diff command.
	args string
	// Sets the environment variable whose value can overwrite a diff command passed to a compare function.
	// It also enables the use of commands that are not in the list of known diff tools.
	// Set it to `none` to disable it.
	env_overwrite_var ?string = 'VDIFF_CMD'
}