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 6, 2022
1 parent d2ea9af commit 1555595
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 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,9 +6,9 @@ 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::edit::manifest::DepTable;
use cargo::util::interning::InternedString;
use cargo::CargoResult;

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::edit::dependency::RegistrySource;
use crate::util::validate_package_name;
use crate::CargoResult;

Expand Down
20 changes: 8 additions & 12 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Core of cargo-add command

mod crate_spec;
mod dependency;
mod manifest;

use anyhow::Context;
use std::collections::BTreeSet;
use std::collections::VecDeque;
Expand All @@ -23,18 +20,17 @@ use crate::core::QueryKind;
use crate::core::Registry;
use crate::core::Shell;
use crate::core::Workspace;
use crate::util::edit::dependency::Dependency;
use crate::util::edit::dependency::GitSource;
use crate::util::edit::dependency::MaybeWorkspace;
use crate::util::edit::dependency::PathSource;
use crate::util::edit::dependency::Source;
use crate::util::edit::dependency::WorkspaceSource;
use crate::util::edit::manifest::DepTable;
use crate::util::edit::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
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ impl Display for WorkspaceSource {
mod tests {
use std::path::Path;

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

use super::*;
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/cargo/util/edit/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;
1 change: 1 addition & 0 deletions src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod counter;
pub mod cpu;
mod dependency_queue;
pub mod diagnostic_server;
pub mod edit;
pub mod errors;
mod flock;
pub mod graph;
Expand Down

0 comments on commit 1555595

Please sign in to comment.