graftfs 1.2.0

A Rust implementation of the GNU stow utility for managing dotfiles. It is a symlink farm manager that takes separate packages of software and/or data and makes them appear to be installed in the same place. Features include stow, delete, and restow operations, simulation mode, directory folding, and regex-based ignore/override patterns.
/*
 * graftfs
 * Copyright (C) 2026 Chris Tisdale
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

use snafu::Snafu;

#[derive(Debug, Snafu)]
#[non_exhaustive]
#[snafu(visibility(pub))]
pub enum CommandError {
    #[snafu(display("Invalid path {path}"))]
    InvalidPath {
        path: String,
        source: std::io::Error,
    },
    #[snafu(display("Failed to create symlink from {target} to {destination}"))]
    SymLinkError {
        target: String,
        destination: String,
        source: std::io::Error,
    },
    #[snafu(display("Failed to read next item in the directory"))]
    DirectoryReadError { source: std::io::Error },
    #[snafu(display("Failed to remove file {file}"))]
    FileRemoveError {
        file: String,
        source: std::io::Error,
    },
    #[snafu(display("Failed to remove directory {directory}"))]
    DirectoryRemoveError {
        directory: String,
        source: std::io::Error,
    },
    #[snafu(display("Failed to create directory {directory}"))]
    CreateDirectoryError {
        directory: String,
        source: std::io::Error,
    },
    #[snafu(display("Failed to read link {path}"))]
    ReadLinkError {
        path: String,
        source: std::io::Error,
    },
    #[snafu(display("Invalid target directory: {directory}.  The target directory must exist and be a directory."))]
    InvalidTargetDirectory { directory: String },
    #[snafu(display("Invalid stow directory: {directory}.  The stow directory must exist and be a directory."))]
    StowDirectoryNotFound { directory: String },
    #[snafu(display("Invalid stow directory: {directory}.  It must not be the same as the target directory."))]
    InvalidStowDirectory { directory: String },
    #[snafu(display("Directory Entry Already Exists: {directory}"))]
    DirectoryEntryAlreadyExists { directory: String },
    #[snafu(display(
        "The stow directory contains an invalid item: {item}.  It must be a file or directory and not a symbolic link."
    ))]
    InvalidStowItem { item: String },
    #[snafu(display("Failed to change directory to {directory}"))]
    ChangeDirectoryError {
        source: std::io::Error,
        directory: String,
    },
    #[snafu(display("Failed to get current working directory"))]
    WorkingDirectoryError { source: std::io::Error },
    #[snafu(display("Failed to get the absolute path of {path}"))]
    AbsolutePathError {
        path: String,
        source: std::io::Error,
    },
}