From c5eeae74b73bed34a25b33b3465181a5173b3d63 Mon Sep 17 00:00:00 2001 From: veeso Date: Tue, 9 May 2023 15:40:21 +0200 Subject: [PATCH] fmt --- src/activity_manager.rs | 19 +++++------ src/cli_opts.rs | 6 ++-- src/config/bookmarks.rs | 13 +++++--- src/config/params.rs | 10 +++--- src/config/serialization.rs | 18 +++++----- src/config/themes.rs | 9 ++--- src/explorer/builder.rs | 9 ++--- src/explorer/formatter.rs | 19 ++++++----- src/explorer/mod.rs | 16 +++++---- src/filetransfer/builder.rs | 16 +++++---- src/filetransfer/mod.rs | 7 ++-- src/filetransfer/params.rs | 7 ++-- src/host/mod.rs | 33 ++++++++++--------- src/support.rs | 13 ++++---- src/system/auto_update.rs | 15 ++++----- src/system/bookmarks_client.rs | 25 +++++++------- src/system/config_client.rs | 20 +++++------ src/system/environment.rs | 7 ++-- src/system/keys/filestorage.rs | 7 ++-- src/system/keys/keyringstorage.rs | 7 ++-- src/system/keys/mod.rs | 7 ++-- src/system/logging.rs | 5 +-- src/system/sshkey_storage.rs | 15 +++++---- src/system/theme_provider.rs | 11 +++---- src/system/watcher/change.rs | 8 ++--- src/system/watcher/mod.rs | 23 +++++++------ .../activities/auth/components/bookmarks.rs | 4 +-- src/ui/activities/auth/components/form.rs | 4 +-- src/ui/activities/auth/components/mod.rs | 1 - src/ui/activities/auth/components/popup.rs | 4 +-- src/ui/activities/auth/components/text.rs | 4 +-- src/ui/activities/auth/mod.rs | 12 ++++--- src/ui/activities/auth/update.rs | 4 +-- src/ui/activities/auth/view.rs | 13 ++++---- .../filetransfer/actions/change_dir.rs | 5 +-- .../activities/filetransfer/actions/copy.rs | 5 +-- .../activities/filetransfer/actions/delete.rs | 4 +-- .../activities/filetransfer/actions/edit.rs | 9 ++--- .../activities/filetransfer/actions/find.rs | 4 +-- .../activities/filetransfer/actions/mkdir.rs | 6 ++-- src/ui/activities/filetransfer/actions/mod.rs | 10 +++--- .../filetransfer/actions/newfile.rs | 3 +- .../activities/filetransfer/actions/open.rs | 3 +- .../filetransfer/actions/pending.rs | 4 +-- .../activities/filetransfer/actions/rename.rs | 5 +-- .../activities/filetransfer/actions/save.rs | 3 +- .../filetransfer/actions/symlink.rs | 4 +-- .../filetransfer/actions/watcher.rs | 4 +-- .../activities/filetransfer/components/log.rs | 4 +-- .../filetransfer/components/misc.rs | 4 +-- .../activities/filetransfer/components/mod.rs | 13 ++++---- .../filetransfer/components/popups.rs | 12 +++---- .../filetransfer/components/transfer/mod.rs | 1 - src/ui/activities/filetransfer/fswatcher.rs | 4 +-- src/ui/activities/filetransfer/lib/browser.rs | 8 +++-- .../activities/filetransfer/lib/transfer.rs | 8 +++-- src/ui/activities/filetransfer/misc.rs | 22 ++++++------- src/ui/activities/filetransfer/mod.rs | 25 +++++++------- src/ui/activities/filetransfer/session.rs | 15 +++++---- src/ui/activities/filetransfer/update.rs | 15 ++++----- src/ui/activities/filetransfer/view.rs | 11 +++---- src/ui/activities/setup/actions.rs | 8 +++-- src/ui/activities/setup/components/commons.rs | 4 +-- src/ui/activities/setup/components/config.rs | 10 +++--- src/ui/activities/setup/components/mod.rs | 1 - src/ui/activities/setup/components/ssh.rs | 4 +-- src/ui/activities/setup/components/theme.rs | 6 ++-- src/ui/activities/setup/config.rs | 3 +- src/ui/activities/setup/mod.rs | 13 +++++--- src/ui/activities/setup/update.rs | 6 ++-- src/ui/activities/setup/view/mod.rs | 12 +++---- src/ui/activities/setup/view/setup.rs | 11 ++++--- src/ui/activities/setup/view/ssh_keys.rs | 6 ++-- src/ui/activities/setup/view/theme.rs | 4 +-- src/ui/context.rs | 4 +-- src/ui/store.rs | 4 +-- src/utils/crypto.rs | 4 +-- src/utils/file.rs | 3 +- src/utils/fmt.rs | 10 +++--- src/utils/parser.rs | 23 +++++++------ src/utils/random.rs | 7 ++-- src/utils/test_helpers.rs | 7 ++-- src/utils/ui.rs | 4 +-- 83 files changed, 398 insertions(+), 358 deletions(-) diff --git a/src/activity_manager.rs b/src/activity_manager.rs index 01491da..2e7c1e5 100644 --- a/src/activity_manager.rs +++ b/src/activity_manager.rs @@ -3,23 +3,22 @@ //! `activity_manager` is the module which provides run methods and handling for activities // Deps +// Namespaces +use std::path::{Path, PathBuf}; +use std::time::Duration; + use crate::filetransfer::FileTransferParams; use crate::host::{HostError, Localhost}; use crate::system::bookmarks_client::BookmarksClient; use crate::system::config_client::ConfigClient; use crate::system::environment; use crate::system::theme_provider::ThemeProvider; -use crate::ui::activities::{ - auth::AuthActivity, filetransfer::FileTransferActivity, setup::SetupActivity, Activity, - ExitReason, -}; +use crate::ui::activities::auth::AuthActivity; +use crate::ui::activities::filetransfer::FileTransferActivity; +use crate::ui::activities::setup::SetupActivity; +use crate::ui::activities::{Activity, ExitReason}; use crate::ui::context::Context; -use crate::utils::fmt; -use crate::utils::tty; - -// Namespaces -use std::path::{Path, PathBuf}; -use std::time::Duration; +use crate::utils::{fmt, tty}; /// NextActivity identifies the next identity to run once the current has ended pub enum NextActivity { diff --git a/src/cli_opts.rs b/src/cli_opts.rs index 86238ac..1ee60dd 100644 --- a/src/cli_opts.rs +++ b/src/cli_opts.rs @@ -2,15 +2,15 @@ //! //! defines the types for main.rs types +use std::path::PathBuf; +use std::time::Duration; + use argh::FromArgs; use crate::activity_manager::NextActivity; use crate::filetransfer::FileTransferParams; use crate::system::logging::LogLevel; -use std::path::PathBuf; -use std::time::Duration; - pub enum Task { Activity(NextActivity), ImportTheme(PathBuf), diff --git a/src/config/bookmarks.rs b/src/config/bookmarks.rs index a4badce..204432a 100644 --- a/src/config/bookmarks.rs +++ b/src/config/bookmarks.rs @@ -2,14 +2,16 @@ //! //! `bookmarks` is the module which provides data types and de/serializer for bookmarks -use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams}; -use crate::filetransfer::{FileTransferParams, FileTransferProtocol}; - -use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer}; use std::collections::HashMap; use std::path::PathBuf; use std::str::FromStr; +use serde::de::Error as DeError; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams}; +use crate::filetransfer::{FileTransferParams, FileTransferProtocol}; + /// UserHosts contains all the hosts saved by the user in the data storage /// It contains both `Bookmark` #[derive(Deserialize, Serialize, Debug, Default)] @@ -155,9 +157,10 @@ where #[cfg(test)] mod tests { - use super::*; use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_bookmarks_default() { let bookmarks: UserHosts = UserHosts::default(); diff --git a/src/config/params.rs b/src/config/params.rs index 9052598..3e916a4 100644 --- a/src/config/params.rs +++ b/src/config/params.rs @@ -3,12 +3,13 @@ //! `config` is the module which provides access to termscp configuration // Locals -use crate::filetransfer::FileTransferProtocol; +use std::collections::HashMap; +use std::path::PathBuf; // Ext use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::path::PathBuf; + +use crate::filetransfer::FileTransferProtocol; pub const DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD: u64 = 536870912; // 512MB @@ -91,9 +92,10 @@ impl Default for UserInterfaceConfig { #[cfg(test)] mod tests { - use super::*; use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_config_mod_new() { let mut keys: HashMap = HashMap::with_capacity(1); diff --git a/src/config/serialization.rs b/src/config/serialization.rs index 5fc8f9e..7d02cfa 100644 --- a/src/config/serialization.rs +++ b/src/config/serialization.rs @@ -2,8 +2,10 @@ //! //! `serialization` provides serialization and deserialization for configurations -use serde::{de::DeserializeOwned, Serialize}; use std::io::{Read, Write}; + +use serde::de::DeserializeOwned; +use serde::Serialize; use thiserror::Error; /// Contains the error for serializer/deserializer @@ -105,20 +107,20 @@ where #[cfg(test)] mod tests { - use super::*; + use std::collections::HashMap; + use std::io::Seek; + use std::path::PathBuf; + use pretty_assertions::assert_eq; + use tuirealm::tui::style::Color; + + use super::*; use crate::config::bookmarks::{Bookmark, S3Params, UserHosts}; use crate::config::params::UserConfig; use crate::config::themes::Theme; use crate::filetransfer::FileTransferProtocol; use crate::utils::test_helpers::create_file_ioers; - use pretty_assertions::assert_eq; - use std::collections::HashMap; - use std::io::Seek; - use std::path::PathBuf; - use tuirealm::tui::style::Color; - #[test] fn test_config_serialization_errors() { let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax); diff --git a/src/config/themes.rs b/src/config/themes.rs index 451c55d..7101f9e 100644 --- a/src/config/themes.rs +++ b/src/config/themes.rs @@ -3,12 +3,13 @@ //! `themes` is the module which provides the themes configurations and the serializers // locals -use crate::utils::fmt::fmt_color; -use crate::utils::parser::parse_color; // ext use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer}; use tuirealm::tui::style::Color; +use crate::utils::fmt::fmt_color; +use crate::utils::parser::parse_color; + /// Theme contains all the colors lookup table for termscp #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] pub struct Theme { @@ -211,10 +212,10 @@ where #[cfg(test)] mod test { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_config_themes_default() { let theme: Theme = Theme::default(); diff --git a/src/explorer/builder.rs b/src/explorer/builder.rs index f818616..d571d80 100644 --- a/src/explorer/builder.rs +++ b/src/explorer/builder.rs @@ -3,11 +3,12 @@ //! `builder` is the module which provides a builder for FileExplorer // Locals -use super::formatter::Formatter; -use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs}; // Ext use std::collections::VecDeque; +use super::formatter::Formatter; +use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs}; + /// Struct used to create a `FileExplorer` pub struct FileExplorerBuilder { explorer: Option, @@ -76,10 +77,10 @@ impl FileExplorerBuilder { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_fs_explorer_builder_new_default() { let explorer: FileExplorer = FileExplorerBuilder::new().build(); diff --git a/src/explorer/formatter.rs b/src/explorer/formatter.rs index d5236a9..f6534fb 100644 --- a/src/explorer/formatter.rs +++ b/src/explorer/formatter.rs @@ -3,18 +3,20 @@ //! `formatter` is the module which provides formatting utilities for `FileExplorer` // Locals -use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time}; -use crate::utils::path::diff_paths; -use crate::utils::string::secure_substring; +use std::path::PathBuf; +use std::time::UNIX_EPOCH; + // Ext use bytesize::ByteSize; use lazy_regex::{Lazy, Regex}; use remotefs::File; -use std::path::PathBuf; -use std::time::UNIX_EPOCH; use unicode_width::UnicodeWidthStr; #[cfg(target_family = "unix")] use users::{get_group_by_gid, get_user_by_uid}; + +use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time}; +use crate::utils::path::diff_paths; +use crate::utils::string::secure_substring; // Types // FmtCallback: Formatter, fsentry: &File, cur_str, prefix, length, extra type FmtCallback = fn(&Formatter, &File, &str, &str, Option<&usize>, Option<&String>) -> String; @@ -521,12 +523,13 @@ impl Formatter { #[cfg(test)] mod tests { - use super::*; + use std::path::PathBuf; + use std::time::SystemTime; use pretty_assertions::assert_eq; use remotefs::fs::{File, FileType, Metadata, UnixPex}; - use std::path::PathBuf; - use std::time::SystemTime; + + use super::*; #[test] fn test_fs_explorer_formatter_callchain() { diff --git a/src/explorer/mod.rs b/src/explorer/mod.rs index bf0be0a..28b3ac9 100644 --- a/src/explorer/mod.rs +++ b/src/explorer/mod.rs @@ -6,15 +6,16 @@ pub(crate) mod builder; mod formatter; // Locals -use formatter::Formatter; -// Ext -use remotefs::fs::File; use std::cmp::Reverse; use std::collections::VecDeque; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::string::ToString; +use formatter::Formatter; +// Ext +use remotefs::fs::File; + bitflags! { /// ExplorerOpts are bit options which provides different behaviours to `FileExplorer` #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -289,13 +290,14 @@ impl FromStr for GroupDirs { #[cfg(test)] mod tests { - use super::*; - use crate::utils::fmt::fmt_time; + use std::thread::sleep; + use std::time::{Duration, SystemTime}; use pretty_assertions::assert_eq; use remotefs::fs::{File, FileType, Metadata, UnixPex}; - use std::thread::sleep; - use std::time::{Duration, SystemTime}; + + use super::*; + use crate::utils::fmt::fmt_time; #[test] fn test_fs_explorer_new() { diff --git a/src/filetransfer/builder.rs b/src/filetransfer/builder.rs index 5d89516..532d72d 100644 --- a/src/filetransfer/builder.rs +++ b/src/filetransfer/builder.rs @@ -2,16 +2,17 @@ //! //! Remotefs client builder -use super::params::{AwsS3Params, GenericProtocolParams}; -use super::{FileTransferProtocol, ProtocolParams}; -use crate::system::config_client::ConfigClient; -use crate::system::sshkey_storage::SshKeyStorage; +use std::path::PathBuf; use remotefs::RemoteFs; use remotefs_aws_s3::AwsS3Fs; use remotefs_ftp::FtpFs; use remotefs_ssh::{ScpFs, SftpFs, SshOpts}; -use std::path::PathBuf; + +use super::params::{AwsS3Params, GenericProtocolParams}; +use super::{FileTransferProtocol, ProtocolParams}; +use crate::system::config_client::ConfigClient; +use crate::system::sshkey_storage::SshKeyStorage; /// Remotefs builder pub struct Builder; @@ -123,11 +124,12 @@ impl Builder { #[cfg(test)] mod test { - use super::*; - use std::path::{Path, PathBuf}; + use tempfile::TempDir; + use super::*; + #[test] fn should_build_aws_s3_fs() { let params = ProtocolParams::AwsS3( diff --git a/src/filetransfer/mod.rs b/src/filetransfer/mod.rs index a5c9501..52a998f 100644 --- a/src/filetransfer/mod.rs +++ b/src/filetransfer/mod.rs @@ -54,12 +54,13 @@ impl std::str::FromStr for FileTransferProtocol { #[cfg(test)] mod tests { - use super::*; - - use pretty_assertions::assert_eq; use std::str::FromStr; use std::string::ToString; + use pretty_assertions::assert_eq; + + use super::*; + #[test] fn test_filetransfer_mod_protocol() { assert_eq!( diff --git a/src/filetransfer/params.rs b/src/filetransfer/params.rs index dec9dce..75b502b 100644 --- a/src/filetransfer/params.rs +++ b/src/filetransfer/params.rs @@ -2,10 +2,10 @@ //! //! file transfer parameters -use super::FileTransferProtocol; - use std::path::{Path, PathBuf}; +use super::FileTransferProtocol; + /// Holds connection parameters for file transfers #[derive(Debug, Clone)] pub struct FileTransferParams { @@ -238,9 +238,10 @@ impl AwsS3Params { #[cfg(test)] mod test { - use super::*; use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_filetransfer_params() { let params: FileTransferParams = diff --git a/src/host/mod.rs b/src/host/mod.rs index 6d32b68..9d552f5 100644 --- a/src/host/mod.rs +++ b/src/host/mod.rs @@ -3,19 +3,20 @@ //! `host` is the module which provides functionalities to host file system // ext +// Metadata ext +#[cfg(target_family = "unix")] +use std::fs::set_permissions; +use std::fs::{self, File as StdFile, OpenOptions}; +#[cfg(target_family = "unix")] +use std::os::unix::fs::PermissionsExt; +use std::path::{Path, PathBuf}; + use filetime::{self, FileTime}; #[cfg(target_family = "unix")] use remotefs::fs::UnixPex; use remotefs::fs::{File, FileType, Metadata}; -use std::fs::{self, File as StdFile, OpenOptions}; -use std::path::{Path, PathBuf}; use thiserror::Error; use wildmatch::WildMatch; -// Metadata ext -#[cfg(target_family = "unix")] -use std::fs::set_permissions; -#[cfg(target_family = "unix")] -use std::os::unix::fs::PermissionsExt; // Locals use crate::utils::path; @@ -643,21 +644,21 @@ impl Localhost { #[cfg(test)] mod tests { - use super::*; - #[cfg(target_family = "unix")] - use crate::utils::test_helpers::make_fsentry; - use crate::utils::test_helpers::{create_sample_file, make_dir_at, make_file_at}; - - use pretty_assertions::assert_eq; #[cfg(target_family = "unix")] use std::fs::File as StdFile; #[cfg(target_family = "unix")] use std::io::Write; - + use std::ops::AddAssign; #[cfg(target_family = "unix")] use std::os::unix::fs::{symlink, PermissionsExt}; - use std::time::SystemTime; - use std::{ops::AddAssign, time::Duration}; + use std::time::{Duration, SystemTime}; + + use pretty_assertions::assert_eq; + + use super::*; + #[cfg(target_family = "unix")] + use crate::utils::test_helpers::make_fsentry; + use crate::utils::test_helpers::{create_sample_file, make_dir_at, make_file_at}; #[test] fn test_host_error_new() { diff --git a/src/support.rs b/src/support.rs index 4a094bd..e6cd1b8 100644 --- a/src/support.rs +++ b/src/support.rs @@ -3,16 +3,15 @@ //! this module exposes some extra run modes for termscp, meant to be used for "support", such as installing themes // mod -use crate::system::{ - auto_update::{Update, UpdateStatus}, - config_client::ConfigClient, - environment, - notifications::Notification, - theme_provider::ThemeProvider, -}; use std::fs; use std::path::{Path, PathBuf}; +use crate::system::auto_update::{Update, UpdateStatus}; +use crate::system::config_client::ConfigClient; +use crate::system::environment; +use crate::system::notifications::Notification; +use crate::system::theme_provider::ThemeProvider; + /// Import theme at provided path into termscp pub fn import_theme(p: &Path) -> Result<(), String> { if !p.exists() { diff --git a/src/system/auto_update.rs b/src/system/auto_update.rs index bca48d8..d33ecfc 100644 --- a/src/system/auto_update.rs +++ b/src/system/auto_update.rs @@ -2,13 +2,12 @@ //! //! Automatic update module. This module is used to upgrade the current version of termscp to the latest available on Github -use crate::utils::parser::parse_semver; - +use self_update::backends::github::Update as GithubUpdater; pub use self_update::errors::Error as UpdateError; -use self_update::{ - backends::github::Update as GithubUpdater, cargo_crate_version, update::Release as UpdRelease, - Status, -}; +use self_update::update::Release as UpdRelease; +use self_update::{cargo_crate_version, Status}; + +use crate::utils::parser::parse_semver; /// The status of the update in case of success #[derive(Debug, Eq, PartialEq)] @@ -131,10 +130,10 @@ impl From for Release { #[cfg(test)] mod test { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn auto_update_default() { let upd: Update = Update::default(); diff --git a/src/system/bookmarks_client.rs b/src/system/bookmarks_client.rs index b133bde..17ed4c0 100644 --- a/src/system/bookmarks_client.rs +++ b/src/system/bookmarks_client.rs @@ -3,9 +3,16 @@ //! `bookmarks_client` is the module which provides an API between the Bookmarks module and the system // Crate +// Ext +use std::fs::OpenOptions; +use std::path::{Path, PathBuf}; +use std::string::ToString; +use std::time::SystemTime; + +use super::keys::filestorage::FileStorage; #[cfg(feature = "with-keyring")] use super::keys::keyringstorage::KeyringStorage; -use super::keys::{filestorage::FileStorage, KeyStorage, KeyStorageError}; +use super::keys::{KeyStorage, KeyStorageError}; // Local use crate::config::{ bookmarks::{Bookmark, UserHosts}, @@ -15,11 +22,6 @@ use crate::filetransfer::FileTransferParams; use crate::utils::crypto; use crate::utils::fmt::fmt_time; use crate::utils::random::random_alphanumeric_with_len; -// Ext -use std::fs::OpenOptions; -use std::path::{Path, PathBuf}; -use std::string::ToString; -use std::time::SystemTime; /// BookmarksClient provides a layer between the host system and the bookmarks module pub struct BookmarksClient { @@ -370,15 +372,16 @@ impl BookmarksClient { #[cfg(not(target_os = "macos"))] // CI/CD blocks mod tests { + use std::thread::sleep; + use std::time::Duration; + + use pretty_assertions::assert_eq; + use tempfile::TempDir; + use super::*; use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams}; use crate::filetransfer::{FileTransferProtocol, ProtocolParams}; - use pretty_assertions::assert_eq; - use std::thread::sleep; - use std::time::Duration; - use tempfile::TempDir; - #[test] fn test_system_bookmarks_new() { diff --git a/src/system/config_client.rs b/src/system/config_client.rs index fdfa93d..716f91f 100644 --- a/src/system/config_client.rs +++ b/src/system/config_client.rs @@ -3,12 +3,6 @@ //! `config_client` is the module which provides an API between the Config module and the system // Locals -use crate::config::{ - params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD}, - serialization::{deserialize, serialize, SerializerError, SerializerErrorKind}, -}; -use crate::explorer::GroupDirs; -use crate::filetransfer::FileTransferProtocol; // Ext use std::fs::{create_dir, remove_file, File, OpenOptions}; use std::io::Write; @@ -16,6 +10,11 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::string::ToString; +use crate::config::params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD}; +use crate::config::serialization::{deserialize, serialize, SerializerError, SerializerErrorKind}; +use crate::explorer::GroupDirs; +use crate::filetransfer::FileTransferProtocol; + // Types pub type SshHost = (String, String, PathBuf); // 0: host, 1: username, 2: RSA key path @@ -414,14 +413,15 @@ impl ConfigClient { #[cfg(test)] mod tests { + use std::io::Read; + + use pretty_assertions::assert_eq; + use tempfile::TempDir; + use super::*; use crate::config::UserConfig; use crate::utils::random::random_alphanumeric_with_len; - use pretty_assertions::assert_eq; - use std::io::Read; - use tempfile::TempDir; - #[test] fn test_system_config_new() { let tmp_dir: TempDir = TempDir::new().ok().unwrap(); diff --git a/src/system/environment.rs b/src/system/environment.rs index f3090a7..6d865ea 100644 --- a/src/system/environment.rs +++ b/src/system/environment.rs @@ -101,12 +101,13 @@ pub fn get_theme_path(config_dir: &Path) -> PathBuf { #[cfg(test)] mod tests { - use super::*; + use std::fs::{File, OpenOptions}; + use std::io::Write; use pretty_assertions::assert_eq; use serial_test::serial; - use std::fs::{File, OpenOptions}; - use std::io::Write; + + use super::*; #[test] #[serial] diff --git a/src/system/keys/filestorage.rs b/src/system/keys/filestorage.rs index bb9da64..cf99445 100644 --- a/src/system/keys/filestorage.rs +++ b/src/system/keys/filestorage.rs @@ -3,12 +3,13 @@ //! `filestorage` provides an implementation of the `KeyStorage` trait using a file // Local -use super::{KeyStorage, KeyStorageError}; // Ext use std::fs::{OpenOptions, Permissions}; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; +use super::{KeyStorage, KeyStorageError}; + /// File storage is an implementation o the `KeyStorage` which uses a file to store the key pub struct FileStorage { dir_path: PathBuf, @@ -90,10 +91,10 @@ impl KeyStorage for FileStorage { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_system_keys_filestorage_make_dir() { let storage: FileStorage = FileStorage::new(Path::new("/tmp/")); diff --git a/src/system/keys/keyringstorage.rs b/src/system/keys/keyringstorage.rs index 6a3a018..ec37f0d 100644 --- a/src/system/keys/keyringstorage.rs +++ b/src/system/keys/keyringstorage.rs @@ -3,10 +3,11 @@ //! `keyringstorage` provides an implementation of the `KeyStorage` trait using the OS keyring // Local -use super::{KeyStorage, KeyStorageError}; // Ext use keyring::{Entry as Keyring, Error as KeyringError}; +use super::{KeyStorage, KeyStorageError}; + /// provides a `KeyStorage` implementation using the keyring crate pub struct KeyringStorage { username: String, @@ -75,11 +76,11 @@ impl KeyStorage for KeyringStorage { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; use whoami::username; + use super::*; + #[test] fn test_system_keys_keyringstorage() { let username: String = username(); diff --git a/src/system/keys/mod.rs b/src/system/keys/mod.rs index c1155e1..77e0686 100644 --- a/src/system/keys/mod.rs +++ b/src/system/keys/mod.rs @@ -7,10 +7,9 @@ pub mod filestorage; #[cfg(feature = "with-keyring")] pub mod keyringstorage; // ext -use thiserror::Error; - #[cfg(feature = "with-keyring")] use keyring::Error as KeyringError; +use thiserror::Error; /// defines the error type for the `KeyStorage` #[derive(Debug, Error)] @@ -53,10 +52,10 @@ pub trait KeyStorage { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_system_keys_mod_errors() { #[cfg(feature = "with-keyring")] diff --git a/src/system/logging.rs b/src/system/logging.rs index 44e740b..00641fe 100644 --- a/src/system/logging.rs +++ b/src/system/logging.rs @@ -2,11 +2,12 @@ //! //! `logging` is the module which initializes the logging system for termscp -use super::environment::{get_log_paths, init_cache_dir}; -use crate::utils::file::open_file; pub use simplelog::LevelFilter as LogLevel; use simplelog::{ConfigBuilder, WriteLogger}; +use super::environment::{get_log_paths, init_cache_dir}; +use crate::utils::file::open_file; + /// Initialize logger pub fn init(level: LogLevel) -> Result<(), String> { // Init cache dir diff --git a/src/system/sshkey_storage.rs b/src/system/sshkey_storage.rs index 59bb305..bcd5111 100644 --- a/src/system/sshkey_storage.rs +++ b/src/system/sshkey_storage.rs @@ -3,12 +3,14 @@ //! `SshKeyStorage` is the module which behaves a storage for ssh keys // Locals -use super::config_client::ConfigClient; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; + // Ext use remotefs_ssh::SshKeyStorage as SshKeyStorageTrait; use ssh2_config::SshConfig; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; + +use super::config_client::ConfigClient; #[derive(Default)] pub struct SshKeyStorage { @@ -117,13 +119,14 @@ impl From<&ConfigClient> for SshKeyStorage { #[cfg(test)] mod tests { + use std::path::Path; + + use pretty_assertions::assert_eq; + use super::*; use crate::system::config_client::ConfigClient; use crate::utils::test_helpers; - use pretty_assertions::assert_eq; - use std::path::Path; - #[test] fn test_system_sshkey_storage_new() { let tmp_dir: tempfile::TempDir = tempfile::TempDir::new().ok().unwrap(); diff --git a/src/system/theme_provider.rs b/src/system/theme_provider.rs index bef095d..6dcbbec 100644 --- a/src/system/theme_provider.rs +++ b/src/system/theme_provider.rs @@ -3,15 +3,14 @@ //! `theme_provider` is the module which provides an API between the theme configuration and the system // Locals -use crate::config::{ - serialization::{deserialize, serialize, SerializerError, SerializerErrorKind}, - themes::Theme, -}; // Ext use std::fs::OpenOptions; use std::path::{Path, PathBuf}; use std::string::ToString; +use crate::config::serialization::{deserialize, serialize, SerializerError, SerializerErrorKind}; +use crate::config::themes::Theme; + /// ThemeProvider provides a high level API to communicate with the termscp theme pub struct ThemeProvider { theme: Theme, // Theme loaded @@ -142,12 +141,12 @@ impl ThemeProvider { #[cfg(test)] mod test { - use super::*; - use pretty_assertions::assert_eq; use tempfile::TempDir; use tuirealm::tui::style::Color; + use super::*; + #[test] fn test_system_theme_provider_new() { let tmp_dir: tempfile::TempDir = TempDir::new().ok().unwrap(); diff --git a/src/system/watcher/change.rs b/src/system/watcher/change.rs index edb9fc4..9a9dc9a 100644 --- a/src/system/watcher/change.rs +++ b/src/system/watcher/change.rs @@ -2,10 +2,10 @@ //! //! this module exposes the types to describe a change to sync on the remote file system -use crate::utils::path as path_utils; - use std::path::{Path, PathBuf}; +use crate::utils::path as path_utils; + /// Describes an operation on the remote file system to sync #[derive(Debug, PartialEq, Eq, Clone)] pub enum FsChange { @@ -190,10 +190,10 @@ fn remote_relative_path( #[cfg(test)] mod test { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn should_get_remote_relative_path_from_subdir() { assert_eq!( diff --git a/src/system/watcher/mod.rs b/src/system/watcher/mod.rs index 3779d25..8c78ccb 100644 --- a/src/system/watcher/mod.rs +++ b/src/system/watcher/mod.rs @@ -5,19 +5,19 @@ mod change; // -- export -pub use change::FsChange; - -use crate::utils::path as path_utils; - -use notify::{ - watcher, DebouncedEvent, Error as WatcherError, RecommendedWatcher, RecursiveMode, Watcher, -}; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::mpsc::{channel, Receiver, RecvTimeoutError}; use std::time::Duration; + +pub use change::FsChange; +use notify::{ + watcher, DebouncedEvent, Error as WatcherError, RecommendedWatcher, RecursiveMode, Watcher, +}; use thiserror::Error; +use crate::utils::path as path_utils; + type FsWatcherResult = Result; /// Describes an error returned by the `FsWatcher` @@ -172,14 +172,13 @@ impl FsWatcher { #[cfg(test)] mod test { - use super::*; - - #[cfg(target_os = "macos")] - use crate::utils::test_helpers; - use pretty_assertions::assert_eq; use tempfile::TempDir; + use super::*; + #[cfg(target_os = "macos")] + use crate::utils::test_helpers; + #[test] fn should_init_fswatcher() { let watcher = FsWatcher::init(Duration::from_secs(5)).unwrap(); diff --git a/src/ui/activities/auth/components/bookmarks.rs b/src/ui/activities/auth/components/bookmarks.rs index a854694..00bbaf0 100644 --- a/src/ui/activities/auth/components/bookmarks.rs +++ b/src/ui/activities/auth/components/bookmarks.rs @@ -2,14 +2,14 @@ //! //! auth activity bookmarks components -use super::{FormMsg, Msg, UiMsg}; - use tui_realm_stdlib::{Input, List, Radio}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, InputType, TextSpan}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; +use super::{FormMsg, Msg, UiMsg}; + // -- bookmark list #[derive(MockComponent)] diff --git a/src/ui/activities/auth/components/form.rs b/src/ui/activities/auth/components/form.rs index 34f28e5..db0555f 100644 --- a/src/ui/activities/auth/components/form.rs +++ b/src/ui/activities/auth/components/form.rs @@ -2,14 +2,14 @@ //! //! auth activity components for file transfer params form -use super::{FileTransferProtocol, FormMsg, Msg, UiMsg}; - use tui_realm_stdlib::{Input, Radio}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; +use super::{FileTransferProtocol, FormMsg, Msg, UiMsg}; + // -- protocol #[derive(MockComponent)] diff --git a/src/ui/activities/auth/components/mod.rs b/src/ui/activities/auth/components/mod.rs index 08574b8..f61b5e8 100644 --- a/src/ui/activities/auth/components/mod.rs +++ b/src/ui/activities/auth/components/mod.rs @@ -23,7 +23,6 @@ pub use popup::{ WindowSizeError, }; pub use text::{HelpFooter, NewVersionDisclaimer, Subtitle, Title}; - use tui_realm_stdlib::Phantom; use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent}; use tuirealm::{Component, MockComponent}; diff --git a/src/ui/activities/auth/components/popup.rs b/src/ui/activities/auth/components/popup.rs index b5e282b..340c0d2 100644 --- a/src/ui/activities/auth/components/popup.rs +++ b/src/ui/activities/auth/components/popup.rs @@ -2,14 +2,14 @@ //! //! auth activity popups -use super::{FormMsg, Msg, UiMsg}; - use tui_realm_stdlib::{List, Paragraph, Radio, Textarea}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, BorderType, Borders, Color, TableBuilder, TextSpan}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; +use super::{FormMsg, Msg, UiMsg}; + // -- error popup #[derive(MockComponent)] diff --git a/src/ui/activities/auth/components/text.rs b/src/ui/activities/auth/components/text.rs index f2af0a0..4a47645 100644 --- a/src/ui/activities/auth/components/text.rs +++ b/src/ui/activities/auth/components/text.rs @@ -2,12 +2,12 @@ //! //! auth activity texts -use super::Msg; - use tui_realm_stdlib::{Label, Span}; use tuirealm::props::{Color, TextModifiers, TextSpan}; use tuirealm::{Component, Event, MockComponent, NoUserEvent}; +use super::Msg; + // -- Title #[derive(MockComponent)] diff --git a/src/ui/activities/auth/mod.rs b/src/ui/activities/auth/mod.rs index 21702af..7dacf8f 100644 --- a/src/ui/activities/auth/mod.rs +++ b/src/ui/activities/auth/mod.rs @@ -10,17 +10,19 @@ mod update; mod view; // locals +// Includes +use std::time::Duration; + +use tuirealm::application::PollStrategy; +use tuirealm::listener::EventListenerCfg; +use tuirealm::{Application, NoUserEvent, Update}; + use super::{Activity, Context, ExitReason}; use crate::config::themes::Theme; use crate::filetransfer::{FileTransferParams, FileTransferProtocol}; use crate::system::bookmarks_client::BookmarksClient; use crate::system::config_client::ConfigClient; -// Includes -use std::time::Duration; -use tuirealm::listener::EventListenerCfg; -use tuirealm::{application::PollStrategy, Application, NoUserEvent, Update}; - // -- components #[derive(Debug, Eq, PartialEq, Clone, Hash)] pub enum Id { diff --git a/src/ui/activities/auth/update.rs b/src/ui/activities/auth/update.rs index 317d1a3..303f758 100644 --- a/src/ui/activities/auth/update.rs +++ b/src/ui/activities/auth/update.rs @@ -2,10 +2,10 @@ //! //! Update impl -use super::{AuthActivity, ExitReason, FormMsg, Id, InputMask, Msg, UiMsg, Update}; - use tuirealm::{State, StateValue}; +use super::{AuthActivity, ExitReason, FormMsg, Id, InputMask, Msg, UiMsg, Update}; + impl Update for AuthActivity { fn update(&mut self, msg: Option) -> Option { self.redraw = true; diff --git a/src/ui/activities/auth/view.rs b/src/ui/activities/auth/view.rs index 0f8c638..0ca5df6 100644 --- a/src/ui/activities/auth/view.rs +++ b/src/ui/activities/auth/view.rs @@ -3,17 +3,18 @@ //! `auth_activity` is the module which implements the authentication activity // Locals +use std::path::PathBuf; +use std::str::FromStr; + +use tuirealm::tui::layout::{Constraint, Direction, Layout}; +use tuirealm::tui::widgets::Clear; +use tuirealm::{State, StateValue, Sub, SubClause, SubEventClause}; + use super::{components, AuthActivity, Context, FileTransferProtocol, Id, InputMask}; use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams}; use crate::filetransfer::FileTransferParams; use crate::utils::ui::{Popup, Size}; -use std::path::PathBuf; -use std::str::FromStr; -use tuirealm::tui::layout::{Constraint, Direction, Layout}; -use tuirealm::tui::widgets::Clear; -use tuirealm::{State, StateValue, Sub, SubClause, SubEventClause}; - impl AuthActivity { /// Initialize view, mounting all startup components inside the view pub(super) fn init(&mut self) { diff --git a/src/ui/activities/filetransfer/actions/change_dir.rs b/src/ui/activities/filetransfer/actions/change_dir.rs index 98b9b67..975b0cf 100644 --- a/src/ui/activities/filetransfer/actions/change_dir.rs +++ b/src/ui/activities/filetransfer/actions/change_dir.rs @@ -3,10 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileExplorerTab, FileTransferActivity, LogLevel, Msg, PendingActionMsg}; +use std::path::PathBuf; use remotefs::File; -use std::path::PathBuf; + +use super::{FileExplorerTab, FileTransferActivity, LogLevel, Msg, PendingActionMsg}; /// Describes destination for sync browsing enum SyncBrowsingDestination { diff --git a/src/ui/activities/filetransfer/actions/copy.rs b/src/ui/activities/filetransfer/actions/copy.rs index 7e7c09d..dd020d9 100644 --- a/src/ui/activities/filetransfer/actions/copy.rs +++ b/src/ui/activities/filetransfer/actions/copy.rs @@ -3,10 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; +use std::path::{Path, PathBuf}; use remotefs::{File, RemoteErrorType}; -use std::path::{Path, PathBuf}; + +use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; impl FileTransferActivity { /// Copy file on local diff --git a/src/ui/activities/filetransfer/actions/delete.rs b/src/ui/activities/filetransfer/actions/delete.rs index c26f5cc..65bd494 100644 --- a/src/ui/activities/filetransfer/actions/delete.rs +++ b/src/ui/activities/filetransfer/actions/delete.rs @@ -3,10 +3,10 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileTransferActivity, LogLevel, SelectedFile}; - use remotefs::File; +use super::{FileTransferActivity, LogLevel, SelectedFile}; + impl FileTransferActivity { pub(crate) fn action_local_delete(&mut self) { match self.get_local_selected_entries() { diff --git a/src/ui/activities/filetransfer/actions/edit.rs b/src/ui/activities/filetransfer/actions/edit.rs index a6b9af2..cd4302b 100644 --- a/src/ui/activities/filetransfer/actions/edit.rs +++ b/src/ui/activities/filetransfer/actions/edit.rs @@ -3,15 +3,16 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; - -// ext -use remotefs::File; use std::fs::OpenOptions; use std::io::Read; use std::path::{Path, PathBuf}; use std::time::SystemTime; +// ext +use remotefs::File; + +use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; + impl FileTransferActivity { pub(crate) fn action_edit_local_file(&mut self) { let entries: Vec = match self.get_local_selected_entries() { diff --git a/src/ui/activities/filetransfer/actions/find.rs b/src/ui/activities/filetransfer/actions/find.rs index 04c877a..a0f65be 100644 --- a/src/ui/activities/filetransfer/actions/find.rs +++ b/src/ui/activities/filetransfer/actions/find.rs @@ -3,11 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals +use std::path::PathBuf; + use super::super::browser::FileExplorerTab; use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferOpts, TransferPayload}; -use std::path::PathBuf; - impl FileTransferActivity { pub(crate) fn action_local_find(&mut self, input: String) -> Result, String> { match self.host.find(input.as_str()) { diff --git a/src/ui/activities/filetransfer/actions/mkdir.rs b/src/ui/activities/filetransfer/actions/mkdir.rs index 53d2d0f..85bc15f 100644 --- a/src/ui/activities/filetransfer/actions/mkdir.rs +++ b/src/ui/activities/filetransfer/actions/mkdir.rs @@ -3,10 +3,12 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileTransferActivity, LogLevel}; -use remotefs::fs::UnixPex; use std::path::PathBuf; +use remotefs::fs::UnixPex; + +use super::{FileTransferActivity, LogLevel}; + impl FileTransferActivity { pub(crate) fn action_local_mkdir(&mut self, input: String) { match self.host.mkdir(PathBuf::from(input.as_str()).as_path()) { diff --git a/src/ui/activities/filetransfer/actions/mod.rs b/src/ui/activities/filetransfer/actions/mod.rs index 8e4fd06..c2cc9b2 100644 --- a/src/ui/activities/filetransfer/actions/mod.rs +++ b/src/ui/activities/filetransfer/actions/mod.rs @@ -2,13 +2,15 @@ //! //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall -pub(self) use super::{ - browser::FileExplorerTab, FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, - TransferMsg, TransferOpts, TransferPayload, UiMsg, -}; pub(self) use remotefs::File; use tuirealm::{State, StateValue}; +pub(self) use super::browser::FileExplorerTab; +pub(self) use super::{ + FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts, + TransferPayload, UiMsg, +}; + // actions pub(crate) mod change_dir; pub(crate) mod copy; diff --git a/src/ui/activities/filetransfer/actions/newfile.rs b/src/ui/activities/filetransfer/actions/newfile.rs index a38cdc6..bc43f14 100644 --- a/src/ui/activities/filetransfer/actions/newfile.rs +++ b/src/ui/activities/filetransfer/actions/newfile.rs @@ -3,10 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{File, FileTransferActivity, LogLevel}; use std::fs::File as StdFile; use std::path::PathBuf; +use super::{File, FileTransferActivity, LogLevel}; + impl FileTransferActivity { pub(crate) fn action_local_newfile(&mut self, input: String) { // Check if file exists diff --git a/src/ui/activities/filetransfer/actions/open.rs b/src/ui/activities/filetransfer/actions/open.rs index 67876a8..6e699a7 100644 --- a/src/ui/activities/filetransfer/actions/open.rs +++ b/src/ui/activities/filetransfer/actions/open.rs @@ -3,10 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; // ext use std::path::{Path, PathBuf}; +use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; + impl FileTransferActivity { /// Open local file pub(crate) fn action_open_local(&mut self) { diff --git a/src/ui/activities/filetransfer/actions/pending.rs b/src/ui/activities/filetransfer/actions/pending.rs index b50f3a5..1dc1bdb 100644 --- a/src/ui/activities/filetransfer/actions/pending.rs +++ b/src/ui/activities/filetransfer/actions/pending.rs @@ -3,10 +3,10 @@ //! this little module exposes the routine to create a pending action on the file transfer activity. //! A pending action is an action which blocks the execution of the application in await of a certain `Msg`. -use super::{FileTransferActivity, Msg}; - use tuirealm::{PollStrategy, Update}; +use super::{FileTransferActivity, Msg}; + impl FileTransferActivity { /// Block execution of activity, preventing ANY kind of message not specified in the `wait_for` argument. /// Once `wait_for` clause is satisfied, the function returns. diff --git a/src/ui/activities/filetransfer/actions/rename.rs b/src/ui/activities/filetransfer/actions/rename.rs index 51fe5f4..a80dffd 100644 --- a/src/ui/activities/filetransfer/actions/rename.rs +++ b/src/ui/activities/filetransfer/actions/rename.rs @@ -3,10 +3,11 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{File, FileTransferActivity, LogLevel, SelectedFile}; +use std::path::{Path, PathBuf}; use remotefs::RemoteErrorType; -use std::path::{Path, PathBuf}; + +use super::{File, FileTransferActivity, LogLevel, SelectedFile}; impl FileTransferActivity { pub(crate) fn action_local_rename(&mut self, input: String) { diff --git a/src/ui/activities/filetransfer/actions/save.rs b/src/ui/activities/filetransfer/actions/save.rs index a285c35..e0c4024 100644 --- a/src/ui/activities/filetransfer/actions/save.rs +++ b/src/ui/activities/filetransfer/actions/save.rs @@ -3,11 +3,12 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals +use std::path::{Path, PathBuf}; + use super::{ File, FileTransferActivity, LogLevel, Msg, PendingActionMsg, SelectedFile, TransferOpts, TransferPayload, }; -use std::path::{Path, PathBuf}; impl FileTransferActivity { pub(crate) fn action_local_saveas(&mut self, input: String) { diff --git a/src/ui/activities/filetransfer/actions/symlink.rs b/src/ui/activities/filetransfer/actions/symlink.rs index 5a85184..a7b72b1 100644 --- a/src/ui/activities/filetransfer/actions/symlink.rs +++ b/src/ui/activities/filetransfer/actions/symlink.rs @@ -3,10 +3,10 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{FileTransferActivity, LogLevel, SelectedFile}; - use std::path::PathBuf; +use super::{FileTransferActivity, LogLevel, SelectedFile}; + impl FileTransferActivity { /// Create symlink on localhost #[cfg(target_family = "unix")] diff --git a/src/ui/activities/filetransfer/actions/watcher.rs b/src/ui/activities/filetransfer/actions/watcher.rs index 8e22d45..33b6399 100644 --- a/src/ui/activities/filetransfer/actions/watcher.rs +++ b/src/ui/activities/filetransfer/actions/watcher.rs @@ -2,10 +2,10 @@ //! //! actions associated to the file watcher -use super::{FileTransferActivity, LogLevel, Msg, SelectedFile, TransferMsg, UiMsg}; - use std::path::{Path, PathBuf}; +use super::{FileTransferActivity, LogLevel, Msg, SelectedFile, TransferMsg, UiMsg}; + impl FileTransferActivity { pub fn action_show_radio_watch(&mut self) { // return if fswatcher is not working diff --git a/src/ui/activities/filetransfer/components/log.rs b/src/ui/activities/filetransfer/components/log.rs index 4bf1b33..958c23c 100644 --- a/src/ui/activities/filetransfer/components/log.rs +++ b/src/ui/activities/filetransfer/components/log.rs @@ -2,8 +2,6 @@ //! //! log tab component -use super::{Msg, UiMsg}; - use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent}; use tuirealm::props::{Alignment, AttrValue, Attribute, Borders, Color, Style, Table}; @@ -11,6 +9,8 @@ use tuirealm::tui::layout::Corner; use tuirealm::tui::widgets::{List as TuiList, ListItem, ListState}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, Props, State, StateValue}; +use super::{Msg, UiMsg}; + pub struct Log { props: Props, states: OwnStates, diff --git a/src/ui/activities/filetransfer/components/misc.rs b/src/ui/activities/filetransfer/components/misc.rs index f6652f7..5ff8965 100644 --- a/src/ui/activities/filetransfer/components/misc.rs +++ b/src/ui/activities/filetransfer/components/misc.rs @@ -2,12 +2,12 @@ //! //! file transfer activity components -use super::Msg; - use tui_realm_stdlib::Span; use tuirealm::props::{Color, TextSpan}; use tuirealm::{Component, Event, MockComponent, NoUserEvent}; +use super::Msg; + #[derive(MockComponent)] pub struct FooterBar { component: Span, diff --git a/src/ui/activities/filetransfer/components/mod.rs b/src/ui/activities/filetransfer/components/mod.rs index 8e0d538..6ec0681 100644 --- a/src/ui/activities/filetransfer/components/mod.rs +++ b/src/ui/activities/filetransfer/components/mod.rs @@ -2,13 +2,11 @@ //! //! file transfer activity components -use super::{Msg, PendingActionMsg, TransferMsg, UiMsg}; - use tui_realm_stdlib::Phantom; -use tuirealm::{ - event::{Event, Key, KeyEvent, KeyModifiers}, - Component, MockComponent, NoUserEvent, -}; +use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers}; +use tuirealm::{Component, MockComponent, NoUserEvent}; + +use super::{Msg, PendingActionMsg, TransferMsg, UiMsg}; // -- export mod log; @@ -16,7 +14,6 @@ mod misc; mod popups; mod transfer; -pub use self::log::Log; pub use misc::FooterBar; pub use popups::{ CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, ExecPopup, FatalPopup, FileInfoPopup, @@ -27,6 +24,8 @@ pub use popups::{ }; pub use transfer::{ExplorerFind, ExplorerLocal, ExplorerRemote}; +pub use self::log::Log; + #[derive(Default, MockComponent)] pub struct GlobalListener { component: Phantom, diff --git a/src/ui/activities/filetransfer/components/popups.rs b/src/ui/activities/filetransfer/components/popups.rs index e7fee6c..bb13da9 100644 --- a/src/ui/activities/filetransfer/components/popups.rs +++ b/src/ui/activities/filetransfer/components/popups.rs @@ -2,15 +2,10 @@ //! //! popups components -use super::super::Browser; -use super::{Msg, PendingActionMsg, TransferMsg, UiMsg}; -use crate::explorer::FileSorting; -use crate::utils::fmt::fmt_time; +use std::time::UNIX_EPOCH; use bytesize::ByteSize; use remotefs::File; -use std::time::UNIX_EPOCH; - use tui_realm_stdlib::{Input, List, Paragraph, ProgressBar, Radio, Span}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; @@ -21,6 +16,11 @@ use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; #[cfg(target_family = "unix")] use users::{get_group_by_gid, get_user_by_uid}; +use super::super::Browser; +use super::{Msg, PendingActionMsg, TransferMsg, UiMsg}; +use crate::explorer::FileSorting; +use crate::utils::fmt::fmt_time; + #[derive(MockComponent)] pub struct CopyPopup { component: Input, diff --git a/src/ui/activities/filetransfer/components/transfer/mod.rs b/src/ui/activities/filetransfer/components/transfer/mod.rs index 3231084..f8981b6 100644 --- a/src/ui/activities/filetransfer/components/transfer/mod.rs +++ b/src/ui/activities/filetransfer/components/transfer/mod.rs @@ -6,7 +6,6 @@ use super::{Msg, TransferMsg, UiMsg}; mod file_list; use file_list::FileList; - use tuirealm::command::{Cmd, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, Borders, Color, TextSpan}; diff --git a/src/ui/activities/filetransfer/fswatcher.rs b/src/ui/activities/filetransfer/fswatcher.rs index ffdb547..472304d 100644 --- a/src/ui/activities/filetransfer/fswatcher.rs +++ b/src/ui/activities/filetransfer/fswatcher.rs @@ -1,8 +1,8 @@ +use std::path::Path; + use super::{FileTransferActivity, LogLevel, TransferPayload}; use crate::system::watcher::FsChange; -use std::path::Path; - impl FileTransferActivity { /// poll file watcher pub(super) fn poll_watcher(&mut self) { diff --git a/src/ui/activities/filetransfer/lib/browser.rs b/src/ui/activities/filetransfer/lib/browser.rs index 7627142..8e3f530 100644 --- a/src/ui/activities/filetransfer/lib/browser.rs +++ b/src/ui/activities/filetransfer/lib/browser.rs @@ -2,11 +2,13 @@ //! //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall -use crate::explorer::{builder::FileExplorerBuilder, FileExplorer, FileSorting, GroupDirs}; -use crate::system::config_client::ConfigClient; +use std::path::Path; use remotefs::File; -use std::path::Path; + +use crate::explorer::builder::FileExplorerBuilder; +use crate::explorer::{FileExplorer, FileSorting, GroupDirs}; +use crate::system::config_client::ConfigClient; /// File explorer tab #[derive(Clone, Copy, PartialEq, Eq)] diff --git a/src/ui/activities/filetransfer/lib/transfer.rs b/src/ui/activities/filetransfer/lib/transfer.rs index 8a9d0a7..165e18e 100644 --- a/src/ui/activities/filetransfer/lib/transfer.rs +++ b/src/ui/activities/filetransfer/lib/transfer.rs @@ -2,10 +2,11 @@ //! //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall -use bytesize::ByteSize; use std::fmt; use std::time::Instant; +use bytesize::ByteSize; + // -- States and progress /// TransferStates contains the states related to the transfer process @@ -173,10 +174,11 @@ impl TransferOpts { #[cfg(test)] mod test { - use super::*; + use std::time::Duration; use pretty_assertions::assert_eq; - use std::time::Duration; + + use super::*; #[test] fn test_ui_activities_filetransfer_lib_transfer_progress_states() { diff --git a/src/ui/activities/filetransfer/misc.rs b/src/ui/activities/filetransfer/misc.rs index 1736173..d1ae3d5 100644 --- a/src/ui/activities/filetransfer/misc.rs +++ b/src/ui/activities/filetransfer/misc.rs @@ -1,21 +1,21 @@ // Locals -use super::{ - browser::FileExplorerTab, ConfigClient, FileTransferActivity, Id, LogLevel, LogRecord, - TransferPayload, +use std::env; +use std::path::{Path, PathBuf}; + +// Ext +use bytesize::ByteSize; +use tuirealm::props::{ + Alignment, AttrValue, Attribute, Color, PropPayload, PropValue, TableBuilder, TextSpan, }; +use tuirealm::{PollStrategy, Update}; + +use super::browser::FileExplorerTab; +use super::{ConfigClient, FileTransferActivity, Id, LogLevel, LogRecord, TransferPayload}; use crate::filetransfer::ProtocolParams; use crate::system::environment; use crate::system::notifications::Notification; use crate::utils::fmt::{fmt_millis, fmt_path_elide_ex}; use crate::utils::path; -// Ext -use bytesize::ByteSize; -use std::env; -use std::path::{Path, PathBuf}; -use tuirealm::props::{ - Alignment, AttrValue, Attribute, Color, PropPayload, PropValue, TableBuilder, TextSpan, -}; -use tuirealm::{PollStrategy, Update}; const LOG_CAPACITY: usize = 256; diff --git a/src/ui/activities/filetransfer/mod.rs b/src/ui/activities/filetransfer/mod.rs index ebd738e..d0ab6a4 100644 --- a/src/ui/activities/filetransfer/mod.rs +++ b/src/ui/activities/filetransfer/mod.rs @@ -13,6 +13,19 @@ mod update; mod view; // locals +use std::collections::VecDeque; +use std::time::Duration; + +// Includes +use chrono::{DateTime, Local}; +pub(self) use lib::browser; +use lib::browser::Browser; +use lib::transfer::{TransferOpts, TransferStates}; +use remotefs::RemoteFs; +pub(self) use session::TransferPayload; +use tempfile::TempDir; +use tuirealm::{Application, EventListenerCfg, NoUserEvent}; + use super::{Activity, Context, ExitReason}; use crate::config::themes::Theme; use crate::explorer::{FileExplorer, FileSorting}; @@ -20,18 +33,6 @@ use crate::filetransfer::{Builder, FileTransferParams}; use crate::host::Localhost; use crate::system::config_client::ConfigClient; use crate::system::watcher::FsWatcher; -pub(self) use lib::browser; -use lib::browser::Browser; -use lib::transfer::{TransferOpts, TransferStates}; -pub(self) use session::TransferPayload; - -// Includes -use chrono::{DateTime, Local}; -use remotefs::RemoteFs; -use std::collections::VecDeque; -use std::time::Duration; -use tempfile::TempDir; -use tuirealm::{Application, EventListenerCfg, NoUserEvent}; // -- components diff --git a/src/ui/activities/filetransfer/session.rs b/src/ui/activities/filetransfer/session.rs index efedda2..3548f44 100644 --- a/src/ui/activities/filetransfer/session.rs +++ b/src/ui/activities/filetransfer/session.rs @@ -3,20 +3,21 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // Locals -use super::{FileTransferActivity, LogLevel}; -use crate::host::HostError; -use crate::utils::fmt::fmt_millis; +use std::fs::File as StdFile; +use std::io::{Read, Seek, Write}; +use std::path::{Path, PathBuf}; +use std::time::Instant; // Ext use bytesize::ByteSize; use remotefs::fs::{File, Metadata, ReadStream, UnixPex, Welcome, WriteStream}; use remotefs::{RemoteError, RemoteErrorType}; -use std::fs::File as StdFile; -use std::io::{Read, Seek, Write}; -use std::path::{Path, PathBuf}; -use std::time::Instant; use thiserror::Error; +use super::{FileTransferActivity, LogLevel}; +use crate::host::HostError; +use crate::utils::fmt::fmt_millis; + /// Buffer size for remote I/O const BUFSIZE: usize = 65535; diff --git a/src/ui/activities/filetransfer/update.rs b/src/ui/activities/filetransfer/update.rs index a6e5c4f..e5915ea 100644 --- a/src/ui/activities/filetransfer/update.rs +++ b/src/ui/activities/filetransfer/update.rs @@ -3,17 +3,14 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{ - actions::SelectedFile, - browser::{FileExplorerTab, FoundExplorerTab}, - ExitReason, FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg, -}; // externals use remotefs::fs::File; -use tuirealm::{ - props::{AttrValue, Attribute}, - State, StateValue, Update, -}; +use tuirealm::props::{AttrValue, Attribute}; +use tuirealm::{State, StateValue, Update}; + +use super::actions::SelectedFile; +use super::browser::{FileExplorerTab, FoundExplorerTab}; +use super::{ExitReason, FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg}; impl Update for FileTransferActivity { fn update(&mut self, msg: Option) -> Option { diff --git a/src/ui/activities/filetransfer/view.rs b/src/ui/activities/filetransfer/view.rs index 9a3b282..6b73a5d 100644 --- a/src/ui/activities/filetransfer/view.rs +++ b/src/ui/activities/filetransfer/view.rs @@ -3,12 +3,6 @@ //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall // locals -use super::{ - browser::{FileExplorerTab, FoundExplorerTab}, - components, Context, FileTransferActivity, Id, -}; -use crate::explorer::FileSorting; -use crate::utils::ui::{Popup, Size}; // Ext use remotefs::fs::File; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; @@ -17,6 +11,11 @@ use tuirealm::tui::widgets::Clear; use tuirealm::{Sub, SubClause, SubEventClause}; use unicode_width::UnicodeWidthStr; +use super::browser::{FileExplorerTab, FoundExplorerTab}; +use super::{components, Context, FileTransferActivity, Id}; +use crate::explorer::FileSorting; +use crate::utils::ui::{Popup, Size}; + impl FileTransferActivity { // -- init diff --git a/src/ui/activities/setup/actions.rs b/src/ui/activities/setup/actions.rs index 7fd8960..6c85cd1 100644 --- a/src/ui/activities/setup/actions.rs +++ b/src/ui/activities/setup/actions.rs @@ -4,12 +4,14 @@ //! work on termscp configuration // Locals +use std::env; + +use tuirealm::tui::style::Color; +use tuirealm::{State, StateValue}; + use super::{Id, IdSsh, IdTheme, SetupActivity, ViewLayout}; // Ext use crate::config::themes::Theme; -use std::env; -use tuirealm::tui::style::Color; -use tuirealm::{State, StateValue}; impl SetupActivity { /// On , if there are changes in the configuration, the quit dialog must be shown, otherwise diff --git a/src/ui/activities/setup/components/commons.rs b/src/ui/activities/setup/components/commons.rs index 5f9ac7d..bf5facd 100644 --- a/src/ui/activities/setup/components/commons.rs +++ b/src/ui/activities/setup/components/commons.rs @@ -2,14 +2,14 @@ //! //! config tab components -use super::{CommonMsg, Msg, ViewLayout}; - use tui_realm_stdlib::{List, Paragraph, Radio, Span}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, TableBuilder, TextSpan}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; +use super::{CommonMsg, Msg, ViewLayout}; + #[derive(MockComponent)] pub struct ErrorPopup { component: Paragraph, diff --git a/src/ui/activities/setup/components/config.rs b/src/ui/activities/setup/components/config.rs index 48b57f1..630e4a9 100644 --- a/src/ui/activities/setup/components/config.rs +++ b/src/ui/activities/setup/components/config.rs @@ -2,17 +2,17 @@ //! //! config tab components -use super::{ConfigMsg, Msg}; -use crate::explorer::GroupDirs as GroupDirsEnum; -use crate::filetransfer::FileTransferProtocol; -use crate::utils::parser::parse_bytesize; - use tui_realm_stdlib::{Input, Radio}; use tuirealm::command::{Cmd, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style}; use tuirealm::{Component, Event, MockComponent, NoUserEvent}; +use super::{ConfigMsg, Msg}; +use crate::explorer::GroupDirs as GroupDirsEnum; +use crate::filetransfer::FileTransferProtocol; +use crate::utils::parser::parse_bytesize; + // -- components #[derive(MockComponent)] diff --git a/src/ui/activities/setup/components/mod.rs b/src/ui/activities/setup/components/mod.rs index f285694..144d144 100644 --- a/src/ui/activities/setup/components/mod.rs +++ b/src/ui/activities/setup/components/mod.rs @@ -16,7 +16,6 @@ pub(super) use config::{ }; pub(super) use ssh::{DelSshKeyPopup, SshHost, SshKeys, SshUsername}; pub(super) use theme::*; - use tui_realm_stdlib::Phantom; use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent}; use tuirealm::{Component, MockComponent}; diff --git a/src/ui/activities/setup/components/ssh.rs b/src/ui/activities/setup/components/ssh.rs index 2acf0a8..7386779 100644 --- a/src/ui/activities/setup/components/ssh.rs +++ b/src/ui/activities/setup/components/ssh.rs @@ -2,8 +2,6 @@ //! //! ssh components -use super::{Msg, SshMsg}; - use tui_realm_stdlib::{Input, List, Radio}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; @@ -12,6 +10,8 @@ use tuirealm::props::{ }; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; +use super::{Msg, SshMsg}; + /* DelSshKeyPopup, SshHost, SshKeys, diff --git a/src/ui/activities/setup/components/theme.rs b/src/ui/activities/setup/components/theme.rs index b6ecd9d..fcafde5 100644 --- a/src/ui/activities/setup/components/theme.rs +++ b/src/ui/activities/setup/components/theme.rs @@ -2,9 +2,6 @@ //! //! theme tab components -use super::{Msg, ThemeMsg}; -use crate::ui::activities::setup::IdTheme; - use tui_realm_stdlib::{Input, Label}; use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::event::{Key, KeyEvent, KeyModifiers}; @@ -13,6 +10,9 @@ use tuirealm::{ AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue, }; +use super::{Msg, ThemeMsg}; +use crate::ui::activities::setup::IdTheme; + // -- components #[derive(MockComponent)] diff --git a/src/ui/activities/setup/config.rs b/src/ui/activities/setup/config.rs index 29562e6..6b5e1ef 100644 --- a/src/ui/activities/setup/config.rs +++ b/src/ui/activities/setup/config.rs @@ -4,10 +4,11 @@ //! work on termscp configuration // Locals -use super::SetupActivity; // Ext use std::env; +use super::SetupActivity; + impl SetupActivity { /// Save configuration pub(super) fn save_config(&mut self) -> Result<(), String> { diff --git a/src/ui/activities/setup/mod.rs b/src/ui/activities/setup/mod.rs index 19c5b30..411e5da 100644 --- a/src/ui/activities/setup/mod.rs +++ b/src/ui/activities/setup/mod.rs @@ -11,15 +11,18 @@ mod update; mod view; // Locals +// Ext +use std::time::Duration; + +use tuirealm::application::PollStrategy; +use tuirealm::listener::EventListenerCfg; +use tuirealm::props::Color; +use tuirealm::{Application, NoUserEvent, Update}; + use super::{Activity, Context, ExitReason}; use crate::config::themes::Theme; use crate::system::config_client::ConfigClient; use crate::system::theme_provider::ThemeProvider; -// Ext -use std::time::Duration; -use tuirealm::listener::EventListenerCfg; -use tuirealm::props::Color; -use tuirealm::{application::PollStrategy, Application, NoUserEvent, Update}; // -- components #[derive(Debug, Eq, PartialEq, Clone, Hash)] diff --git a/src/ui/activities/setup/update.rs b/src/ui/activities/setup/update.rs index f7e4f5d..b816b2d 100644 --- a/src/ui/activities/setup/update.rs +++ b/src/ui/activities/setup/update.rs @@ -4,14 +4,14 @@ //! work on termscp configuration // locals +// ext +use tuirealm::Update; + use super::{ CommonMsg, ConfigMsg, Id, IdConfig, IdSsh, IdTheme, Msg, SetupActivity, SshMsg, ThemeMsg, ViewLayout, }; -// ext -use tuirealm::Update; - impl Update for SetupActivity { /// Update auth activity model based on msg /// The function exits when returns None diff --git a/src/ui/activities/setup/view/mod.rs b/src/ui/activities/setup/view/mod.rs index d866153..1e9b174 100644 --- a/src/ui/activities/setup/view/mod.rs +++ b/src/ui/activities/setup/view/mod.rs @@ -7,17 +7,15 @@ pub mod setup; pub mod ssh_keys; pub mod theme; -use super::*; -use crate::utils::ui::{Popup, Size}; pub use setup::*; pub use ssh_keys::*; pub use theme::*; - +use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::tui::widgets::Clear; -use tuirealm::{ - event::{Key, KeyEvent, KeyModifiers}, - Frame, Sub, SubClause, SubEventClause, -}; +use tuirealm::{Frame, Sub, SubClause, SubEventClause}; + +use super::*; +use crate::utils::ui::{Popup, Size}; impl SetupActivity { // -- view diff --git a/src/ui/activities/setup/view/setup.rs b/src/ui/activities/setup/view/setup.rs index 5f80474..0b1fe95 100644 --- a/src/ui/activities/setup/view/setup.rs +++ b/src/ui/activities/setup/view/setup.rs @@ -4,16 +4,17 @@ //! work on termscp configuration // Locals +// Ext +use std::path::PathBuf; + +use tuirealm::tui::layout::{Constraint, Direction, Layout}; +use tuirealm::{State, StateValue}; + use super::{components, Context, Id, IdCommon, IdConfig, SetupActivity, ViewLayout}; use crate::explorer::GroupDirs; use crate::filetransfer::FileTransferProtocol; use crate::utils::fmt::fmt_bytes; -// Ext -use std::path::PathBuf; -use tuirealm::tui::layout::{Constraint, Direction, Layout}; -use tuirealm::{State, StateValue}; - impl SetupActivity { // -- view diff --git a/src/ui/activities/setup/view/ssh_keys.rs b/src/ui/activities/setup/view/ssh_keys.rs index 33b1e44..14d1ee9 100644 --- a/src/ui/activities/setup/view/ssh_keys.rs +++ b/src/ui/activities/setup/view/ssh_keys.rs @@ -4,13 +4,13 @@ //! work on termscp configuration // Locals -use super::{components, Context, Id, IdCommon, IdSsh, SetupActivity, ViewLayout}; -use crate::utils::ui::{Popup, Size}; - // Ext use tuirealm::tui::layout::{Constraint, Direction, Layout}; use tuirealm::tui::widgets::Clear; +use super::{components, Context, Id, IdCommon, IdSsh, SetupActivity, ViewLayout}; +use crate::utils::ui::{Popup, Size}; + impl SetupActivity { // -- view diff --git a/src/ui/activities/setup/view/theme.rs b/src/ui/activities/setup/view/theme.rs index 91d3530..1ce403d 100644 --- a/src/ui/activities/setup/view/theme.rs +++ b/src/ui/activities/setup/view/theme.rs @@ -4,11 +4,11 @@ //! work on termscp configuration // Locals -use super::{components, Context, Id, IdCommon, IdTheme, SetupActivity, Theme, ViewLayout}; - // Ext use tuirealm::tui::layout::{Constraint, Direction, Layout}; +use super::{components, Context, Id, IdCommon, IdTheme, SetupActivity, Theme, ViewLayout}; + impl SetupActivity { // -- view diff --git a/src/ui/context.rs b/src/ui/context.rs index 955ea64..7ad66ee 100644 --- a/src/ui/context.rs +++ b/src/ui/context.rs @@ -3,14 +3,14 @@ //! `Context` is the module which provides all the functionalities related to the UI data holder, called Context // Locals +use tuirealm::terminal::TerminalBridge; + use super::store::Store; use crate::filetransfer::FileTransferParams; use crate::system::bookmarks_client::BookmarksClient; use crate::system::config_client::ConfigClient; use crate::system::theme_provider::ThemeProvider; -use tuirealm::terminal::TerminalBridge; - /// Context holds data structures shared by the activities pub struct Context { ft_params: Option, diff --git a/src/ui/store.rs b/src/ui/store.rs index 8152026..68f5ed5 100644 --- a/src/ui/store.rs +++ b/src/ui/store.rs @@ -163,10 +163,10 @@ impl Store { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_ui_store() { // Create store diff --git a/src/utils/crypto.rs b/src/utils/crypto.rs index c3fa685..66936e8 100644 --- a/src/utils/crypto.rs +++ b/src/utils/crypto.rs @@ -20,10 +20,10 @@ pub fn aes128_b64_decrypt(key: &str, secret: &str) -> Result String { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_utils_fmt_pex() { assert_eq!(fmt_pex(UnixPexClass::from(7)), String::from("rwx")); diff --git a/src/utils/parser.rs b/src/utils/parser.rs index f2ccf26..e25574a 100644 --- a/src/utils/parser.rs +++ b/src/utils/parser.rs @@ -3,23 +3,22 @@ //! `parser` is the module which provides utilities for parsing different kind of stuff // Locals -use crate::filetransfer::{ - params::{AwsS3Params, GenericProtocolParams, ProtocolParams}, - FileTransferParams, FileTransferProtocol, -}; -#[cfg(not(test))] // NOTE: don't use configuration during tests -use crate::system::config_client::ConfigClient; -#[cfg(not(test))] // NOTE: don't use configuration during tests -use crate::system::environment; +use std::path::PathBuf; +use std::str::FromStr; // Ext use bytesize::ByteSize; use lazy_regex::{Lazy, Regex}; -use std::path::PathBuf; -use std::str::FromStr; use tuirealm::tui::style::Color; use tuirealm::utils::parser as tuirealm_parser; +use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams}; +use crate::filetransfer::{FileTransferParams, FileTransferProtocol}; +#[cfg(not(test))] // NOTE: don't use configuration during tests +use crate::system::config_client::ConfigClient; +#[cfg(not(test))] // NOTE: don't use configuration during tests +use crate::system::environment; + // Regex /** @@ -314,10 +313,10 @@ pub fn parse_bytesize>(bytes: S) -> Option { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_utils_parse_remote_opt() { // Base case diff --git a/src/utils/random.rs b/src/utils/random.rs index 18a2408..7af047d 100644 --- a/src/utils/random.rs +++ b/src/utils/random.rs @@ -3,7 +3,8 @@ //! `random` is the module which provides utilities for rand // Ext -use rand::{distributions::Alphanumeric, thread_rng, Rng}; +use rand::distributions::Alphanumeric; +use rand::{thread_rng, Rng}; /// Generate a random alphanumeric string with provided length pub fn random_alphanumeric_with_len(len: usize) -> String { @@ -18,10 +19,10 @@ pub fn random_alphanumeric_with_len(len: usize) -> String { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_utils_random_alphanumeric_with_len() { assert_eq!(random_alphanumeric_with_len(256).len(), 256); diff --git a/src/utils/test_helpers.rs b/src/utils/test_helpers.rs index af890d5..a1f604c 100644 --- a/src/utils/test_helpers.rs +++ b/src/utils/test_helpers.rs @@ -2,11 +2,12 @@ //! //! contains helper functions for tests -use remotefs::fs::{File, FileType, Metadata}; // ext use std::fs::File as StdFile; use std::io::Write; use std::path::{Path, PathBuf}; + +use remotefs::fs::{File, FileType, Metadata}; use tempfile::NamedTempFile; pub fn create_sample_file_entry() -> (File, NamedTempFile) { @@ -74,10 +75,10 @@ pub fn create_file_ioers(p: &Path) -> (StdFile, StdFile) { } mod test { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_utils_test_helpers_sample_file() { let _ = create_sample_file_entry(); diff --git a/src/utils/ui.rs b/src/utils/ui.rs index 6e69d6c..3791c8e 100644 --- a/src/utils/ui.rs +++ b/src/utils/ui.rs @@ -57,10 +57,10 @@ impl Popup { #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; + use super::*; + #[test] fn test_utils_ui_draw_area_in() { let area: Rect = Rect::new(0, 0, 1024, 512);