Skip to content

Commit

Permalink
Expose cargo add internals as utils
Browse files Browse the repository at this point in the history
Move cargo add utils out for future use by other subcommands (namely cargo
remove, per rust-lang#10520).
  • Loading branch information
cassaundra committed Sep 13, 2022
1 parent 0825039 commit dd5d61c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use cargo::core::FeatureValue;
use cargo::ops::cargo_add::add;
use cargo::ops::cargo_add::AddOptions;
use cargo::ops::cargo_add::DepOp;
use cargo::ops::cargo_add::DepTable;
use cargo::ops::resolve_ws;
use cargo::util::command_prelude::*;
use cargo::util::interning::InternedString;
use cargo::util::toml_mut::manifest::DepTable;
use cargo::CargoResult;

pub fn cli() -> clap::Command<'static> {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_add/crate_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use anyhow::Context as _;

use super::Dependency;
use super::RegistrySource;
use crate::util::toml_mut::dependency::RegistrySource;
use crate::util::validate_package_name;
use crate::CargoResult;

Expand Down
19 changes: 8 additions & 11 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Core of cargo-add command
mod crate_spec;
mod dependency;
mod manifest;

use std::collections::BTreeMap;
use std::collections::BTreeSet;
Expand All @@ -26,18 +24,17 @@ use crate::core::Registry;
use crate::core::Shell;
use crate::core::Summary;
use crate::core::Workspace;
use crate::util::toml_mut::dependency::Dependency;
use crate::util::toml_mut::dependency::GitSource;
use crate::util::toml_mut::dependency::MaybeWorkspace;
use crate::util::toml_mut::dependency::PathSource;
use crate::util::toml_mut::dependency::Source;
use crate::util::toml_mut::dependency::WorkspaceSource;
use crate::util::toml_mut::manifest::DepTable;
use crate::util::toml_mut::manifest::LocalManifest;
use crate::CargoResult;
use crate::Config;
use crate_spec::CrateSpec;
use dependency::Dependency;
use dependency::GitSource;
use dependency::PathSource;
use dependency::RegistrySource;
use dependency::Source;
use manifest::LocalManifest;

use crate::ops::cargo_add::dependency::{MaybeWorkspace, WorkspaceSource};
pub use manifest::DepTable;

/// Information on what dependencies should be added
#[derive(Clone, Debug)]
Expand Down
1 change: 1 addition & 0 deletions src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub mod rustc;
mod semver_ext;
pub mod to_semver;
pub mod toml;
pub mod toml_mut;
mod vcs;
mod workspace;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ impl Display for WorkspaceSource {
mod tests {
use std::path::Path;

use crate::ops::cargo_add::manifest::LocalManifest;
use crate::util::toml_mut::manifest::LocalManifest;
use cargo_util::paths;

use super::*;
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/cargo/util/toml_mut/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Utilities for editing Cargo.toml manifests
pub mod dependency;
pub mod manifest;

0 comments on commit dd5d61c

Please sign in to comment.