Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,73 @@ set-version = ["cli"]
cli = ["color", "clap"]
color = ["concolor-control/auto"]
test-external-apis = []

[lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
unnameable_types = "warn"
unreachable_pub = "warn"
unsafe_op_in_unsafe_fn = "warn"
unused_lifetimes = "warn"
unused_macro_rules = "warn"
unused_qualifications = "warn"

[lints.clippy]
bool_assert_comparison = "allow"
branches_sharing_code = "allow"
checked_conversions = "warn"
collapsible_else_if = "allow"
create_dir = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
doc_markdown = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
fallible_impl_from = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
from_iter_instead_of_collect = "warn"
if_same_then_else = "allow"
implicit_clone = "warn"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
invalid_upcast_comparisons = "warn"
large_digit_groups = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
let_and_return = "allow" # sometimes good to name what you are returning
linkedlist = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
mem_forget = "warn"
mutex_integer = "warn"
needless_continue = "allow"
needless_for_each = "warn"
negative_feature_names = "warn"
path_buf_push_overwrite = "warn"
ptr_as_ptr = "warn"
rc_mutex = "warn"
redundant_feature_names = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
result_large_err = "allow"
same_functions_in_if_condition = "warn"
self_named_module_files = "allow" # false positive
semicolon_if_nothing_returned = "warn"
str_to_string = "warn"
string_add = "warn"
string_add_assign = "warn"
string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
uninlined_format_args = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
4 changes: 2 additions & 2 deletions src/bin/add/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Examples:
#[command(override_usage = "\
cargo add [OPTIONS] <DEP>[@<VERSION>] [+<FEATURE>,...] ...
cargo add [OPTIONS] <DEP_PATH> [+<FEATURE>,...] ...")]
pub struct AddArgs {
pub(crate) struct AddArgs {
/// Reference to a package to add as a dependency
///
/// You can reference a packages by:{n}
Expand Down Expand Up @@ -146,7 +146,7 @@ pub struct AddArgs {
}

impl AddArgs {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
anyhow::bail!(
"`cargo add` has been merged into cargo 1.62+ as of cargo-edit 0.10, either
- Upgrade cargo, like with `rustup update`
Expand Down
6 changes: 3 additions & 3 deletions src/bin/add/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use clap::Parser;

#[derive(Debug, Parser)]
#[command(bin_name = "cargo")]
pub enum Command {
pub(crate) enum Command {
Add(crate::add::AddArgs),
}

impl Command {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
match self {
Self::Add(add) => add.exec(),
}
Expand All @@ -18,5 +18,5 @@ impl Command {
#[test]
fn verify_app() {
use clap::CommandFactory;
Command::command().debug_assert()
Command::command().debug_assert();
}
6 changes: 3 additions & 3 deletions src/bin/rm/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use clap::Parser;

#[derive(Debug, Parser)]
#[command(bin_name = "cargo")]
pub enum Command {
pub(crate) enum Command {
Rm(crate::rm::RmArgs),
}

impl Command {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
match self {
Self::Rm(add) => add.exec(),
}
Expand All @@ -18,5 +18,5 @@ impl Command {
#[test]
fn verify_app() {
use clap::CommandFactory;
Command::command().debug_assert()
Command::command().debug_assert();
}
4 changes: 2 additions & 2 deletions src/bin/rm/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::PathBuf;
/// Remove a dependency from a Cargo.toml manifest file.
#[derive(Debug, Args)]
#[command(version)]
pub struct RmArgs {
pub(crate) struct RmArgs {
/// Dependencies to be removed
#[arg(value_name = "DEP_ID", required = true)]
crates: Vec<String>,
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct RmArgs {
}

impl RmArgs {
pub fn exec(&self) -> CargoResult<()> {
pub(crate) fn exec(&self) -> CargoResult<()> {
anyhow::bail!(
"`cargo rm` has been merged into cargo 1.66+ as of cargo-edit 0.12, either
- Upgrade cargo, like with `rustup update`
Expand Down
6 changes: 3 additions & 3 deletions src/bin/set-version/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use clap::Parser;
#[derive(Debug, Parser)]
#[command(bin_name = "cargo")]
#[command(styles = clap_cargo::style::CLAP_STYLING)]
pub enum Command {
pub(crate) enum Command {
SetVersion(crate::set_version::VersionArgs),
}

impl Command {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
match self {
Self::SetVersion(add) => add.exec(),
}
Expand All @@ -19,5 +19,5 @@ impl Command {
#[test]
fn verify_app() {
use clap::CommandFactory;
Command::command().debug_assert()
Command::command().debug_assert();
}
4 changes: 2 additions & 2 deletions src/bin/set-version/errors.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt::Display;

pub use cargo_edit::CargoResult;
pub(crate) use cargo_edit::CargoResult;

pub use cargo_edit::Error;
pub(crate) use cargo_edit::Error;

/// User requested to downgrade a crate
pub(crate) fn version_downgrade_err(current: impl Display, requested: impl Display) -> Error {
Expand Down
34 changes: 17 additions & 17 deletions src/bin/set-version/set_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use std::path::PathBuf;
use cargo_edit::{LocalManifest, shell_status, shell_warn, upgrade_requirement};
use clap::Args;

use crate::errors::*;
use crate::errors::CargoResult;
use crate::version::BumpLevel;
use crate::version::TargetVersion;

/// Change a package's version in the local manifest file (i.e. Cargo.toml).
#[derive(Debug, Args)]
#[command(version)]
#[command(group = clap::ArgGroup::new("ver").multiple(false))]
pub struct VersionArgs {
pub(crate) struct VersionArgs {
/// Version to change manifests to
#[arg(group = "ver")]
target: Option<semver::Version>,
Expand Down Expand Up @@ -77,7 +77,7 @@ pub struct VersionArgs {
}

impl VersionArgs {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
exec(self)
}
}
Expand Down Expand Up @@ -179,20 +179,20 @@ fn exec(args: VersionArgs) -> CargoResult<()> {

if update_workspace_version {
let mut ws_manifest = LocalManifest::try_new(&root_manifest_path)?;
if let Some(current) = ws_manifest.get_workspace_version() {
if let Some(next) = target.bump(&current, metadata.as_deref())? {
shell_status(
"Upgrading",
&format!("workspace version from {current} to {next}"),
)?;
ws_manifest.set_workspace_version(&next);
changed = true;
if !dry_run {
ws_manifest.write()?;
}

// Deferring `update_dependents` to the per-package logic
if let Some(current) = ws_manifest.get_workspace_version()
&& let Some(next) = target.bump(&current, metadata.as_deref())?
{
shell_status(
"Upgrading",
&format!("workspace version from {current} to {next}"),
)?;
ws_manifest.set_workspace_version(&next);
changed = true;
if !dry_run {
ws_manifest.write()?;
}

// Deferring `update_dependents` to the per-package logic
}
}

Expand Down Expand Up @@ -229,7 +229,7 @@ fn exec(args: VersionArgs) -> CargoResult<()> {
&root_manifest_path,
&workspace_members,
dry_run,
)?
)?;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/bin/set-version/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use std::str::FromStr;

use cargo_edit::VersionExt;

use crate::errors::*;
use crate::errors::{CargoResult, version_downgrade_err};

#[derive(Clone, Debug)]
pub enum TargetVersion {
pub(crate) enum TargetVersion {
Relative(BumpLevel),
Absolute(semver::Version),
}

impl TargetVersion {
pub fn bump(
pub(crate) fn bump(
&self,
current: &semver::Version,
metadata: Option<&str>,
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Default for TargetVersion {
}

#[derive(Debug, Clone, Copy)]
pub enum BumpLevel {
pub(crate) enum BumpLevel {
Major,
Minor,
Patch,
Expand Down Expand Up @@ -87,7 +87,7 @@ impl FromStr for BumpLevel {
}

impl BumpLevel {
pub fn bump_version(
pub(crate) fn bump_version(
self,
version: &mut semver::Version,
metadata: Option<&str>,
Expand Down
6 changes: 3 additions & 3 deletions src/bin/upgrade/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use clap::Parser;
#[derive(Debug, Parser)]
#[command(bin_name = "cargo")]
#[command(styles = clap_cargo::style::CLAP_STYLING)]
pub enum Command {
pub(crate) enum Command {
Upgrade(crate::upgrade::UpgradeArgs),
}

impl Command {
pub fn exec(self) -> CargoResult<()> {
pub(crate) fn exec(self) -> CargoResult<()> {
match self {
Self::Upgrade(add) => add.exec(),
}
Expand All @@ -19,5 +19,5 @@ impl Command {
#[test]
fn verify_app() {
use clap::CommandFactory;
Command::command().debug_assert()
Command::command().debug_assert();
}
Loading
Loading