Module utils

Module utils 

Source
Expand description

Provides various utility functions and extension traits for common tasks.

This module contains general-purpose helpers that don’t fit neatly into other domain-specific modules. This includes functions for string manipulation, as well as potentially other reusable components or patterns.

Structs§

FuzzyTerm
Represents an individual search term and its associated matching semantics
ShellInfo
SplitCaptures
An iterator that splits a text string based on a regular expression, yielding both the substrings that don’t match the regex and the Captures objects for the parts that do match.

Enums§

FuzzyMatch
Represents a component of a fuzzy search query.
FuzzyTermKind
Defines the different kinds of matching strategies for a FuzzyTerm.
ShellType
SplitItem
Represents an item yielded by the SplitCaptures iterator.

Statics§

COMMAND_VARIABLE_REGEX
Regex to match variables from a command, with a capturing group for the name
COMMAND_VARIABLE_REGEX_ALT
Regex to match variables from a command, with two capturing groups for the name
COMMAND_VARIABLE_REGEX_QUOTES
Regex to match variables from a command, with a capturing group for the name.

Functions§

convert_alt_to_regular
Converts alternative variable syntax <var> to the regular {{var}} syntax
execute_shell_command_capture
Executes a shell command, capturing stdout and stderr.
execute_shell_command_inherit
Executes a shell command, inheriting the parent’s stdout and stderr
extract_tags_and_cleaned_text
Extracts hashtags from a string and returns them along with the cleaned text.
extract_tags_from_description
Extracts hashtags from a description string
extract_tags_with_editing_and_cleaned_text
Extracts hashtags from a string and returns the tag where the cursor is placed, other tags found on the text and the cleaned text.
flatten_str
Normalizes a string by performing ASCII transliteration and converting to lowercase.
flatten_variable
Normalizes a variable name string that may contain multiple segments separated by |.
format_env_var
Formats an env var name into its shell representation, based on the current shell
generate_working_dir_tree
Generates a string representation of the current working directory tree, respecting .gitignore files
get_executable_version
A helper function to get the version from an executable (e.g. git)
get_os_info
Retrieves the operating system information
get_shell_info
Retrieves information about the current shell, including its type and version
get_shell_type
Retrieves the current shell type
get_working_dir
Retrieves the working directory
parse_fuzzy_query
Parses a fuzzy search query string into a vector of FuzzyMatch items.
read_history
Reads command history from a specified shell or history manager.
remove_newlines
Removes newline sequences and any surrounding whitespace, replacing them with a single space.
truncate_spans
Truncates a slice of spans to fit within a maximum width
truncate_spans_with_ellipsis
Truncates a slice of spans and adds an ellipsis if truncation occurred
unify_newlines
Converts all types of newline sequences (\r, \n, \r\n) in a string to a single newline character (\n).