Module util

Module util 

Source
Expand description

§Common utilities

This module contains common functions and data structures used to build the ACORN command line interface as well support open science endeavors.

Modules§

citeas
Module for communicating with CiteAs API

Structs§

Constant
Struct for using and sharing constants
Label
Struct for using and sharing colorized logging labels
LinkCheck
Data structure for holding the result of a link check
LinkCheckBuilder
Use builder syntax to set the inputs and finish with build().
SchemaCheck
Data structure for holding the result of a schema validation check
SchemaCheckBuilder
Use builder syntax to set the inputs and finish with build().
SemanticVersion
Semantic version
SemanticVersionBuilder
Use builder syntax to set the inputs and finish with build().

Enums§

License
SPDX compliant license identifier
MimeType
MIME types
ProgrammingLanguage
Programming languages

Functions§

checksum
Get SHA256 hash of a file
command_exists
Checks if a given command exists in current terminal context.
download_binary
Downloads a binary file from the given URL to the destination path.
extension
Get file extension
files_all
Returns a vector of PathBuf containing all files in a directory that match at least one of the given extensions.
files_from_git_branch
Returns a vector of PathBuf containing all files changed in the given Git branch relative to the default branch.
files_from_git_commit
Returns a vector of PathBuf containing all files changed in the given Git commit.
filter_ignored
Return file paths in a vector that don’t match the ignore pattern
find_first
Return fisrt key/value pair with key that matches pattern
generate_guid
Generates a random GUID using a custom alphabet.
git_branch_name
Returns the current Git branch name if the git command is available and executed successfully.
git_default_branch_name
Returns the default Git branch name if the git command is available and executed successfully.
image_paths
Returns a vector of PathBuf representing paths to all images found in the given directory and all of its subdirectories.
make_executable
Makes the given file executable.
parent
Returns the absolute path of the parent directory for the given path.
path_to_string
Converts a PathBuf into a String representation of the absolute path.
pretty_print
Prints text to stdout using syntax highlighting for the specified syntax.
print_changes
Prints a diff of changes between two strings.
print_values_as_table
Prints the given values as a table.
read_file
Reads the given file and returns its contents as a string.
standard_project_folder
Returns path to a folder in the operating system’s cache directory that is unique to the given namespace with a random UUID as the name of the final folder.
suffix
Returns “s” if the given value is not 1, otherwise returns an empty string.
text_diff_changes
Computes the differences between two strings line by line and returns a vector of changes.
to_string
Convert a vector of string slices to a vector of strings
tokio_runtime
Create a new Tokio runtime
write_file
Writes the given content to a file at the given path.