Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #11059 - cassaundra:edit-refactor, r=epage
Expose cargo add internals as edit API Move the manifest editing utilities from cargo add to a new `cargo::util::edit` module as part of prep work for `cargo remove` (#10520). No other substantive changes have been made, as this PR is intended only to reduce the refactoring surface area of the implementation of the feature itself. ## Background In cargo edit, there are a number of top-level modules which enable editing of Cargo manifest files (including `src/dependency.rs` and `src/manifest.rs`). In #10472, these files were added instead as a submodule of the cargo add command, with the stated intention of breaking them out later for subsequent `cargo-edit` subcommands. This PR follows through on that expectation. ## Decisions Concerns raised in #10472 regarding this change: - Where should the editing API should live? - Proposal: `cargo::ops::edit` - Justification: precedent has been set by `cargo::ops::resolve` and others to have utils shared by multiple ops live in `cargo::ops`. This is also serves to be a rather conservative API change. - Concerns: the name `edit` could be overly general for those unfamiliar with the cargo edit project (see alternatives) - Alternatives: - `cargo::edit`: this seems to me to be too top level, and would confuse users trying to discover the cargo API - `cargo::util::edit`: if we want to expose this at a higher level, perhaps renaming to act as a counterpart to `crate::util::toml` - For each of these, replace `edit` with `toml_edit`, `toml_mut`, `manifest_edit`, `manifest_mut`, `edit_toml`, `edit_manifest` etc. for a more specific module name - Any more specific naming of types reduce clashes (e.g. `Dependency` or `Manifest` being fairly generic) - Currently the only thing distinguishing these similarly named types is their path, which the `edit` module makes more clear - Alternatives: rename to `EditDependency`/`EditManifest`, `TomlDependency`/`TomlManifest`, etc.
- Loading branch information