Skip to content

Commit e192fdf

Browse files
committed
Auto merge of #6335 - Metaswitch:cli-in-library, r=dwijnand
Move command prelude into main library When writing cargo sub-commands, it would be really useful to have access to these pre-built command line argument creates/parsers. In a perfect world, I'd also move the contents of `src/bin/cargo/{cli.rs, main.rs, command/mod.rs}` that aren't specific to the built-in commands, but that's more complicated than this simple move of a module.
2 parents 9caf0ba + 077a31a commit e192fdf

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/bin/cargo/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ use std::path::{Path, PathBuf};
1919
use std::collections::BTreeSet;
2020

2121
use cargo::core::shell::Shell;
22-
use cargo::util::{self, lev_distance, CargoResult, CliResult, Config};
22+
use cargo::util::{self, command_prelude, lev_distance, CargoResult, CliResult, Config};
2323
use cargo::util::{CliError, ProcessError};
2424

2525
mod cli;
26-
mod command_prelude;
2726
mod commands;
2827

2928
use command_prelude::*;

src/bin/cargo/command_prelude.rs renamed to src/cargo/util/command_prelude.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ use std::path::PathBuf;
22
use std::fs;
33

44
use clap::{self, SubCommand};
5-
use cargo::CargoResult;
6-
use cargo::core::Workspace;
7-
use cargo::core::compiler::{BuildConfig, MessageFormat};
8-
use cargo::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl};
9-
use cargo::sources::CRATES_IO_REGISTRY;
10-
use cargo::util::paths;
11-
use cargo::util::important_paths::find_root_manifest_for_wd;
5+
use CargoResult;
6+
use core::Workspace;
7+
use core::compiler::{BuildConfig, MessageFormat};
8+
use ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl};
9+
use sources::CRATES_IO_REGISTRY;
10+
use util::paths;
11+
use util::important_paths::find_root_manifest_for_wd;
1212

1313
pub use clap::{AppSettings, Arg, ArgMatches};
14-
pub use cargo::{CliError, CliResult, Config};
15-
pub use cargo::core::compiler::CompileMode;
14+
pub use {CliError, CliResult, Config};
15+
pub use core::compiler::CompileMode;
1616

1717
pub type App = clap::App<'static, 'static>;
1818

src/cargo/util/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub mod profile;
3838
pub mod to_semver;
3939
pub mod to_url;
4040
pub mod toml;
41+
pub mod command_prelude;
4142
mod cfg;
4243
mod dependency_queue;
4344
mod rustc;

0 commit comments

Comments
 (0)