pub fn new(
        package_graph: &'g PackageGraph,
        package_name: &'a str,
        crate_path: &'a Utf8Path,
    ) -> Result<Self, InitError> {
        let workspace = package_graph.workspace();
        let workspace_root = workspace.root();

        // The package name can't already be present in the package graph.
        if let Ok(existing) = workspace.member_by_name(package_name) {
            return Err(InitError::PackageNameExists {
                package_name: package_name.to_owned(),
                workspace_path: existing
                    .source()
                    .workspace_path()
                    .expect("package returned by workspace")
                    .to_owned(),
            });
        }

        let abs_path = workspace_root.join(crate_path);
        if !abs_path.starts_with(workspace.root()) {
            return Err(InitError::WorkspacePathNotInRoot {
                abs_path,
                workspace_root: workspace.root().to_owned(),
            });
        }

        // The workspace path can't already exist (don't follow symlinks for this because even a
        // broken symlink is an error).
        match std::fs::symlink_metadata(&abs_path) {
            Ok(_) => {
                // The path exists.
                return Err(InitError::WorkspacePathExists { abs_path });
            }
            Err(err) => match err.kind() {
                io::ErrorKind::NotFound => {}
                _ => {
                    return Err(InitError::Io {
                        path: abs_path,
                        error: err,
                    });
                }
            },
        }

        // TODO: check package name validity.

        Ok(Self {
            package_graph,
            package_name,
            crate_path,
            config: None,
            cargo_toml_comment: "",
        })
    }
Creates a new `HakariInit` with the given options. Writes out a stub config to the path if
specified.

`crate_path` and `config_path` are relative to the root of the workspace.
tools/hakari/src/cli_ops/initialize.rs