Expand description
§mcp-sync utilities
Common helper functions for file operations, JSON/TOML manipulation, and path resolution.
Functions§
- backup
- Creates a backup copy of a file with a timestamped extension.
- ensure_
parent - Ensures that the parent directory of
pathexists. - find_
git_ root - Finds the git repository root by traversing up from
start. Returnsstartif no.gitdirectory is found. - home
- Returns the user’s home directory.
- json_
get_ obj_ mut - Gets or creates a nested object at
key. - json_
obj_ mut - Returns a mutable reference to the JSON object, or an error if not an object.
- log_
verbose - Prints a message to stderr if
verboseis true. - now_
stamp - Generates a timestamp string in
YYYYMMDD-HHMMSSformat. - read_
json_ file - Reads a JSON file, returning an empty object if the file doesn’t exist.
- write_
json_ file - Writes a JSON value to a file with pretty-printing. Creates a backup before writing.