fn fmt()

in tools/hakari/src/cli_ops/workspace_ops.rs [535:620]


    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let workspace_root = self.ops.graph.workspace().root();
        let workspace_root_manifest = workspace_root.join("Cargo.toml");
        for op in &self.ops.ops {
            match op {
                WorkspaceOp::NewCrate {
                    crate_path,
                    files,
                    root_files,
                } => {
                    write!(
                        f,
                        "* {} at {}",
                        "create crate".style(self.styles.create_bold_style),
                        crate_path.style(self.styles.create_bold_style),
                    )?;
                    if !files.is_empty() {
                        writeln!(f, ", with files:")?;
                        for file in files.keys() {
                            writeln!(f, "   - {}", file.style(self.styles.create_style))?;
                        }
                    } else {
                        writeln!(f)?;
                    }
                    writeln!(
                        f,
                        "* {} at {} to {}",
                        "add crate".style(self.styles.add_bold_style),
                        crate_path.style(self.styles.add_style),
                        workspace_root_manifest.style(self.styles.add_to_style),
                    )?;
                    if !root_files.is_empty() {
                        writeln!(
                            f,
                            "* {} at workspace root:",
                            "create files".style(self.styles.create_bold_style)
                        )?;
                        for file in root_files.keys() {
                            writeln!(f, "   - {}", file.style(self.styles.create_style))?;
                        }
                    }
                }
                WorkspaceOp::AddDependency {
                    name,
                    version,
                    crate_path,
                    dep_format: _,
                    add_to,
                } => {
                    writeln!(
                        f,
                        "* {} {} v{} (at path {}) to packages:",
                        "add or update dependency".style(self.styles.add_bold_style),
                        name.style(self.styles.add_style),
                        version.style(self.styles.add_style),
                        crate_path.style(self.styles.add_style),
                    )?;
                    for (name, path) in package_names_paths(add_to) {
                        writeln!(
                            f,
                            "   - {} (at path {})",
                            name.style(self.styles.add_to_bold_style),
                            path.style(self.styles.add_to_style)
                        )?;
                    }
                }
                WorkspaceOp::RemoveDependency { name, remove_from } => {
                    writeln!(
                        f,
                        "* {} {} from packages:",
                        "remove dependency".style(self.styles.remove_bold_style),
                        name.style(self.styles.remove_style),
                    )?;
                    for (name, path) in package_names_paths(remove_from) {
                        writeln!(
                            f,
                            "   - {} (at path {})",
                            name.style(self.styles.remove_from_bold_style),
                            path.style(self.styles.remove_from_style)
                        )?;
                    }
                }
            }
        }
        Ok(())
    }