Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: resolve macros/derived-traits from crates w/ scopes rather than globally #2198

Merged
merged 8 commits into from
May 27, 2024
2 changes: 2 additions & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ static KEY: Lazy<String> = Lazy::new(|| {

#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;

use super::*;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/cli/alias/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;

use crate::test::reset;

#[test]
Expand Down
7 changes: 5 additions & 2 deletions src/cli/args/env_var_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ impl FromStr for EnvVarArg {

#[cfg(test)]
mod tests {
use super::EnvVarArg;
use crate::test::reset;
use pretty_assertions::assert_eq;
use test_log::test;

use crate::test::reset;

use super::EnvVarArg;

#[test]
fn valid_values() {
reset();
Expand Down
2 changes: 2 additions & 0 deletions src/cli/args/forge_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static FORGE_MAP: Lazy<HashMap<&'static str, ForgeArg>> = Lazy::new(|| {

#[cfg(test)]
mod tests {
use pretty_assertions::{assert_eq, assert_str_eq};

use super::*;

#[test]
Expand Down
3 changes: 3 additions & 0 deletions src/cli/args/tool_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use std::str::FromStr;

use console::style;
use eyre::bail;
use regex::Regex;

use crate::cli::args::ForgeArg;
Expand Down Expand Up @@ -162,6 +163,8 @@ fn parse_input(s: &str) -> (&str, Option<&str>) {

#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;

use super::*;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/cli/asdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ fn list_versions(config: &Config, args: &[String]) -> Result<()> {

#[cfg(test)]
mod tests {
use insta::assert_snapshot;

use crate::test::reset;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/cli/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ impl Cache {

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;

use crate::env;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/cli/completion.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::builder::PossibleValue;
use clap::ValueEnum;
use eyre::Result;
use strum::EnumString;

/// Generate shell completions
#[derive(Debug, clap::Args)]
Expand Down Expand Up @@ -73,7 +74,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
"#
);

#[derive(Debug, Clone, Copy, EnumString, Display)]
#[derive(Debug, Clone, Copy, EnumString, strum::Display)]
#[strum(serialize_all = "snake_case")]
enum Shell {
Bash,
Expand Down
6 changes: 3 additions & 3 deletions src/cli/current.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use console::style;
use eyre::Result;
use eyre::{bail, Result};

use crate::cli::args::ForgeArg;
use crate::config::Config;
Expand Down Expand Up @@ -102,10 +102,10 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
shfmt 3.6.0
shellcheck 0.9.0
node 20.0.0

$ <bold>mise current node</bold>
20.0.0

# can output multiple versions
$ <bold>mise current python</bold>
3.11.0 3.10.0
Expand Down
5 changes: 4 additions & 1 deletion src/cli/deactivate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use eyre::Result;
use eyre::{eyre, Result};
use indoc::formatdoc;

use crate::shell::get_shell;
use crate::ui::style;
Expand Down Expand Up @@ -49,6 +50,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;

use crate::config::Config;
use crate::env;
use crate::test::reset;
Expand Down
1 change: 1 addition & 0 deletions src/cli/direnv/activate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use eyre::Result;
use indoc::indoc;

/// Output direnv function to use mise inside direnv
///
Expand Down
3 changes: 3 additions & 0 deletions src/cli/direnv/envrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ impl Envrc {

#[cfg(test)]
mod tests {

use insta::assert_snapshot;

use crate::test::reset;
use crate::{dirs, file};

Expand Down
2 changes: 2 additions & 0 deletions src/cli/direnv/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ fn env_cmd() -> Expression {

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;

use crate::cli::tests::grep;
use crate::test::reset;

Expand Down
1 change: 1 addition & 0 deletions src/cli/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::process::exit;

use console::{pad_str, style, Alignment};
use indenter::indented;
use indoc::formatdoc;
use itertools::Itertools;
use rayon::prelude::*;

Expand Down
2 changes: 2 additions & 0 deletions src/cli/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
mod tests {
use std::env;

use pretty_assertions::assert_str_eq;

use crate::cli::tests::grep;
use crate::dirs;
use crate::test::reset;
Expand Down
10 changes: 8 additions & 2 deletions src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::ffi::{OsStr, OsString};

use clap::ValueHint;
use duct::IntoExecutablePath;
use eyre::Result;
#[cfg(not(any(test, windows)))]
use eyre::{bail, Result};
#[cfg(any(test, windows))]
use eyre::{eyre, Result};

use crate::cli::args::ToolArg;
#[cfg(any(test, windows))]
Expand Down Expand Up @@ -139,10 +142,13 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::reset;
use std::env;

use insta::assert_snapshot;
use test_log::test;

use crate::test::reset;

#[test]
fn test_exec_ok() {
reset();
Expand Down
1 change: 1 addition & 0 deletions src/cli/generate/git_pre_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::file;
Expand Down
1 change: 1 addition & 0 deletions src/cli/generate/github_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::file;
Expand Down
2 changes: 2 additions & 0 deletions src/cli/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;

use crate::test::reset;
use crate::{dirs, file};

Expand Down
2 changes: 2 additions & 0 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;

use crate::dirs;
use crate::test::reset;

Expand Down
7 changes: 5 additions & 2 deletions src/cli/latest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use color_eyre::eyre::Result;
use color_eyre::eyre::{bail, Result};

use crate::cli::args::ToolArg;
use crate::config::Config;
Expand Down Expand Up @@ -66,9 +66,12 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::reset;
use insta::assert_snapshot;
use pretty_assertions::assert_str_eq;
use test_log::test;

use crate::test::reset;

#[test]
fn test_latest() {
reset();
Expand Down
1 change: 1 addition & 0 deletions src/cli/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use clap::ValueHint;
use color_eyre::eyre::{eyre, Result};
use console::style;
use eyre::bail;
use path_absolutize::Absolutize;

use crate::cli::args::ToolArg;
Expand Down
3 changes: 3 additions & 0 deletions src/cli/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
mod tests {
use std::panic;

use insta::assert_snapshot;
use pretty_assertions::assert_str_eq;

use crate::cli::tests::grep;
use crate::test::{cleanup, reset};
use crate::{dirs, forge};
Expand Down
4 changes: 3 additions & 1 deletion src/cli/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;
use std::sync::Arc;

use console::style;
use eyre::Result;
use eyre::{ensure, Result};
use indexmap::IndexMap;
use itertools::Itertools;
use serde_derive::Serialize;
Expand Down Expand Up @@ -392,6 +392,8 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;

use crate::dirs;
use crate::file::remove_all;
use crate::test::reset;
Expand Down
1 change: 1 addition & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::{FromArgMatches, Subcommand};
use color_eyre::Result;
use indoc::indoc;

use crate::config::Settings;
use crate::{logger, migrate, shims};
Expand Down
5 changes: 3 additions & 2 deletions src/cli/plugins/install.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use color_eyre::eyre::{eyre, Result};
use color_eyre::eyre::{bail, eyre, Result};
use rayon::prelude::*;
use rayon::ThreadPoolBuilder;
use url::Url;
Expand Down Expand Up @@ -167,9 +167,10 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::reset;
use insta::assert_snapshot;
use test_log::test;

use crate::test::reset;
#[test]
fn test_plugin_install_invalid_url() {
reset();
Expand Down
4 changes: 3 additions & 1 deletion src/cli/plugins/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::cli::tests::grep;
use crate::test::reset;
use test_log::test;

#[test]
fn test_plugin_list() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/plugins/update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use console::style;
use eyre::{Report, Result};
use eyre::{eyre, Report, Result};
use rayon::prelude::*;

use crate::config::Settings;
Expand Down
1 change: 1 addition & 0 deletions src/cli/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::cli::tests::grep;
Expand Down
7 changes: 5 additions & 2 deletions src/cli/render_help.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::builder::StyledStr;
use console::strip_ansi_codes;
use eyre::Result;
use indoc::formatdoc;
use itertools::Itertools;

use crate::cli::Cli;
Expand Down Expand Up @@ -113,12 +114,14 @@ fn remove_trailing_spaces(s: &str) -> String {

#[cfg(test)]
mod tests {
use crate::test::reset;
use std::fs;

use crate::file;
use indoc::indoc;
use test_log::test;

use crate::file;
use crate::test::reset;

#[test]
fn test_render_help() {
reset();
Expand Down
6 changes: 4 additions & 2 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use console::Color;
use demand::{DemandOption, Select};
use duct::IntoExecutablePath;
use either::Either;
use eyre::Result;
use eyre::{bail, ensure, eyre, Result};
use globwalk::GlobWalkerBuilder;
use itertools::Itertools;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -557,7 +557,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
"#
);

#[derive(Debug, PartialEq, EnumString)]
#[derive(Debug, PartialEq, strum::EnumString)]
#[strum(serialize_all = "snake_case")]
enum TaskOutput {
Prefix,
Expand Down Expand Up @@ -589,6 +589,8 @@ fn format_duration(dur: std::time::Duration) -> String {

#[cfg(test)]
mod tests {
use insta::assert_snapshot;

use crate::file;
use crate::test::reset;

Expand Down
Loading
Loading