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 7, 2022
1 parent d2ea9af commit 5346159
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,7 +6,7 @@ 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::edit::manifest::DepTable;
use cargo::ops::resolve_ws;
use cargo::util::command_prelude::*;
use cargo::util::interning::InternedString;
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::ops::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::ops::edit::dependency::Dependency;
use crate::ops::edit::dependency::GitSource;
use crate::ops::edit::dependency::MaybeWorkspace;
use crate::ops::edit::dependency::PathSource;
use crate::ops::edit::dependency::Source;
use crate::ops::edit::dependency::WorkspaceSource;
use crate::ops::edit::manifest::DepTable;
use crate::ops::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::ops::edit::manifest::LocalManifest;
use cargo_util::paths;

use super::*;
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/cargo/ops/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/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mod cargo_run;
mod cargo_test;
mod cargo_uninstall;
mod common_for_install_and_uninstall;
pub mod edit;
mod fix;
mod lockfile;
mod registry;
Expand Down

0 comments on commit 5346159

Please sign in to comment.