This commit is contained in:
veeso
2023-05-09 15:40:21 +02:00
parent 9009002b6e
commit c5eeae74b7
83 changed files with 398 additions and 358 deletions
+9 -10
View File
@@ -3,23 +3,22 @@
//! `activity_manager` is the module which provides run methods and handling for activities //! `activity_manager` is the module which provides run methods and handling for activities
// Deps // Deps
// Namespaces
use std::path::{Path, PathBuf};
use std::time::Duration;
use crate::filetransfer::FileTransferParams; use crate::filetransfer::FileTransferParams;
use crate::host::{HostError, Localhost}; use crate::host::{HostError, Localhost};
use crate::system::bookmarks_client::BookmarksClient; use crate::system::bookmarks_client::BookmarksClient;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
use crate::system::environment; use crate::system::environment;
use crate::system::theme_provider::ThemeProvider; use crate::system::theme_provider::ThemeProvider;
use crate::ui::activities::{ use crate::ui::activities::auth::AuthActivity;
auth::AuthActivity, filetransfer::FileTransferActivity, setup::SetupActivity, Activity, use crate::ui::activities::filetransfer::FileTransferActivity;
ExitReason, use crate::ui::activities::setup::SetupActivity;
}; use crate::ui::activities::{Activity, ExitReason};
use crate::ui::context::Context; use crate::ui::context::Context;
use crate::utils::fmt; use crate::utils::{fmt, tty};
use crate::utils::tty;
// Namespaces
use std::path::{Path, PathBuf};
use std::time::Duration;
/// NextActivity identifies the next identity to run once the current has ended /// NextActivity identifies the next identity to run once the current has ended
pub enum NextActivity { pub enum NextActivity {
+3 -3
View File
@@ -2,15 +2,15 @@
//! //!
//! defines the types for main.rs types //! defines the types for main.rs types
use std::path::PathBuf;
use std::time::Duration;
use argh::FromArgs; use argh::FromArgs;
use crate::activity_manager::NextActivity; use crate::activity_manager::NextActivity;
use crate::filetransfer::FileTransferParams; use crate::filetransfer::FileTransferParams;
use crate::system::logging::LogLevel; use crate::system::logging::LogLevel;
use std::path::PathBuf;
use std::time::Duration;
pub enum Task { pub enum Task {
Activity(NextActivity), Activity(NextActivity),
ImportTheme(PathBuf), ImportTheme(PathBuf),
+8 -5
View File
@@ -2,14 +2,16 @@
//! //!
//! `bookmarks` is the module which provides data types and de/serializer for bookmarks //! `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::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; 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 /// UserHosts contains all the hosts saved by the user in the data storage
/// It contains both `Bookmark` /// It contains both `Bookmark`
#[derive(Deserialize, Serialize, Debug, Default)] #[derive(Deserialize, Serialize, Debug, Default)]
@@ -155,9 +157,10 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_bookmarks_default() { fn test_bookmarks_default() {
let bookmarks: UserHosts = UserHosts::default(); let bookmarks: UserHosts = UserHosts::default();
+6 -4
View File
@@ -3,12 +3,13 @@
//! `config` is the module which provides access to termscp configuration //! `config` is the module which provides access to termscp configuration
// Locals // Locals
use crate::filetransfer::FileTransferProtocol; use std::collections::HashMap;
use std::path::PathBuf;
// Ext // Ext
use serde::{Deserialize, Serialize}; 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 pub const DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD: u64 = 536870912; // 512MB
@@ -91,9 +92,10 @@ impl Default for UserInterfaceConfig {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_config_mod_new() { fn test_config_mod_new() {
let mut keys: HashMap<String, PathBuf> = HashMap::with_capacity(1); let mut keys: HashMap<String, PathBuf> = HashMap::with_capacity(1);
+10 -8
View File
@@ -2,8 +2,10 @@
//! //!
//! `serialization` provides serialization and deserialization for configurations //! `serialization` provides serialization and deserialization for configurations
use serde::{de::DeserializeOwned, Serialize};
use std::io::{Read, Write}; use std::io::{Read, Write};
use serde::de::DeserializeOwned;
use serde::Serialize;
use thiserror::Error; use thiserror::Error;
/// Contains the error for serializer/deserializer /// Contains the error for serializer/deserializer
@@ -105,20 +107,20 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { 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::bookmarks::{Bookmark, S3Params, UserHosts};
use crate::config::params::UserConfig; use crate::config::params::UserConfig;
use crate::config::themes::Theme; use crate::config::themes::Theme;
use crate::filetransfer::FileTransferProtocol; use crate::filetransfer::FileTransferProtocol;
use crate::utils::test_helpers::create_file_ioers; 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] #[test]
fn test_config_serialization_errors() { fn test_config_serialization_errors() {
let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax); let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax);
+5 -4
View File
@@ -3,12 +3,13 @@
//! `themes` is the module which provides the themes configurations and the serializers //! `themes` is the module which provides the themes configurations and the serializers
// locals // locals
use crate::utils::fmt::fmt_color;
use crate::utils::parser::parse_color;
// ext // ext
use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer}; use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer};
use tuirealm::tui::style::Color; 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 /// Theme contains all the colors lookup table for termscp
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub struct Theme { pub struct Theme {
@@ -211,10 +212,10 @@ where
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_config_themes_default() { fn test_config_themes_default() {
let theme: Theme = Theme::default(); let theme: Theme = Theme::default();
+5 -4
View File
@@ -3,11 +3,12 @@
//! `builder` is the module which provides a builder for FileExplorer //! `builder` is the module which provides a builder for FileExplorer
// Locals // Locals
use super::formatter::Formatter;
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
// Ext // Ext
use std::collections::VecDeque; use std::collections::VecDeque;
use super::formatter::Formatter;
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
/// Struct used to create a `FileExplorer` /// Struct used to create a `FileExplorer`
pub struct FileExplorerBuilder { pub struct FileExplorerBuilder {
explorer: Option<FileExplorer>, explorer: Option<FileExplorer>,
@@ -76,10 +77,10 @@ impl FileExplorerBuilder {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_fs_explorer_builder_new_default() { fn test_fs_explorer_builder_new_default() {
let explorer: FileExplorer = FileExplorerBuilder::new().build(); let explorer: FileExplorer = FileExplorerBuilder::new().build();
+11 -8
View File
@@ -3,18 +3,20 @@
//! `formatter` is the module which provides formatting utilities for `FileExplorer` //! `formatter` is the module which provides formatting utilities for `FileExplorer`
// Locals // Locals
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time}; use std::path::PathBuf;
use crate::utils::path::diff_paths; use std::time::UNIX_EPOCH;
use crate::utils::string::secure_substring;
// Ext // Ext
use bytesize::ByteSize; use bytesize::ByteSize;
use lazy_regex::{Lazy, Regex}; use lazy_regex::{Lazy, Regex};
use remotefs::File; use remotefs::File;
use std::path::PathBuf;
use std::time::UNIX_EPOCH;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use users::{get_group_by_gid, get_user_by_uid}; 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 // Types
// FmtCallback: Formatter, fsentry: &File, cur_str, prefix, length, extra // FmtCallback: Formatter, fsentry: &File, cur_str, prefix, length, extra
type FmtCallback = fn(&Formatter, &File, &str, &str, Option<&usize>, Option<&String>) -> String; type FmtCallback = fn(&Formatter, &File, &str, &str, Option<&usize>, Option<&String>) -> String;
@@ -521,12 +523,13 @@ impl Formatter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use std::path::PathBuf;
use std::time::SystemTime;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use remotefs::fs::{File, FileType, Metadata, UnixPex}; use remotefs::fs::{File, FileType, Metadata, UnixPex};
use std::path::PathBuf;
use std::time::SystemTime; use super::*;
#[test] #[test]
fn test_fs_explorer_formatter_callchain() { fn test_fs_explorer_formatter_callchain() {
+9 -7
View File
@@ -6,15 +6,16 @@
pub(crate) mod builder; pub(crate) mod builder;
mod formatter; mod formatter;
// Locals // Locals
use formatter::Formatter;
// Ext
use remotefs::fs::File;
use std::cmp::Reverse; use std::cmp::Reverse;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use std::string::ToString; use std::string::ToString;
use formatter::Formatter;
// Ext
use remotefs::fs::File;
bitflags! { bitflags! {
/// ExplorerOpts are bit options which provides different behaviours to `FileExplorer` /// ExplorerOpts are bit options which provides different behaviours to `FileExplorer`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@@ -289,13 +290,14 @@ impl FromStr for GroupDirs {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use std::thread::sleep;
use crate::utils::fmt::fmt_time; use std::time::{Duration, SystemTime};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use remotefs::fs::{File, FileType, Metadata, UnixPex}; 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] #[test]
fn test_fs_explorer_new() { fn test_fs_explorer_new() {
+9 -7
View File
@@ -2,16 +2,17 @@
//! //!
//! Remotefs client builder //! Remotefs client builder
use super::params::{AwsS3Params, GenericProtocolParams}; use std::path::PathBuf;
use super::{FileTransferProtocol, ProtocolParams};
use crate::system::config_client::ConfigClient;
use crate::system::sshkey_storage::SshKeyStorage;
use remotefs::RemoteFs; use remotefs::RemoteFs;
use remotefs_aws_s3::AwsS3Fs; use remotefs_aws_s3::AwsS3Fs;
use remotefs_ftp::FtpFs; use remotefs_ftp::FtpFs;
use remotefs_ssh::{ScpFs, SftpFs, SshOpts}; 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 /// Remotefs builder
pub struct Builder; pub struct Builder;
@@ -123,11 +124,12 @@ impl Builder {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tempfile::TempDir; use tempfile::TempDir;
use super::*;
#[test] #[test]
fn should_build_aws_s3_fs() { fn should_build_aws_s3_fs() {
let params = ProtocolParams::AwsS3( let params = ProtocolParams::AwsS3(
+4 -3
View File
@@ -54,12 +54,13 @@ impl std::str::FromStr for FileTransferProtocol {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq;
use std::str::FromStr; use std::str::FromStr;
use std::string::ToString; use std::string::ToString;
use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_filetransfer_mod_protocol() { fn test_filetransfer_mod_protocol() {
assert_eq!( assert_eq!(
+4 -3
View File
@@ -2,10 +2,10 @@
//! //!
//! file transfer parameters //! file transfer parameters
use super::FileTransferProtocol;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use super::FileTransferProtocol;
/// Holds connection parameters for file transfers /// Holds connection parameters for file transfers
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct FileTransferParams { pub struct FileTransferParams {
@@ -238,9 +238,10 @@ impl AwsS3Params {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_filetransfer_params() { fn test_filetransfer_params() {
let params: FileTransferParams = let params: FileTransferParams =
+17 -16
View File
@@ -3,19 +3,20 @@
//! `host` is the module which provides functionalities to host file system //! `host` is the module which provides functionalities to host file system
// ext // 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}; use filetime::{self, FileTime};
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use remotefs::fs::UnixPex; use remotefs::fs::UnixPex;
use remotefs::fs::{File, FileType, Metadata}; use remotefs::fs::{File, FileType, Metadata};
use std::fs::{self, File as StdFile, OpenOptions};
use std::path::{Path, PathBuf};
use thiserror::Error; use thiserror::Error;
use wildmatch::WildMatch; 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 // Locals
use crate::utils::path; use crate::utils::path;
@@ -643,21 +644,21 @@ impl Localhost {
#[cfg(test)] #[cfg(test)]
mod tests { 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")] #[cfg(target_family = "unix")]
use std::fs::File as StdFile; use std::fs::File as StdFile;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use std::io::Write; use std::io::Write;
use std::ops::AddAssign;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use std::os::unix::fs::{symlink, PermissionsExt}; use std::os::unix::fs::{symlink, PermissionsExt};
use std::time::SystemTime; use std::time::{Duration, SystemTime};
use std::{ops::AddAssign, time::Duration};
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] #[test]
fn test_host_error_new() { fn test_host_error_new() {
+6 -7
View File
@@ -3,16 +3,15 @@
//! this module exposes some extra run modes for termscp, meant to be used for "support", such as installing themes //! this module exposes some extra run modes for termscp, meant to be used for "support", such as installing themes
// mod // mod
use crate::system::{
auto_update::{Update, UpdateStatus},
config_client::ConfigClient,
environment,
notifications::Notification,
theme_provider::ThemeProvider,
};
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; 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 /// Import theme at provided path into termscp
pub fn import_theme(p: &Path) -> Result<(), String> { pub fn import_theme(p: &Path) -> Result<(), String> {
if !p.exists() { if !p.exists() {
+7 -8
View File
@@ -2,13 +2,12 @@
//! //!
//! Automatic update module. This module is used to upgrade the current version of termscp to the latest available on Github //! 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; pub use self_update::errors::Error as UpdateError;
use self_update::{ use self_update::update::Release as UpdRelease;
backends::github::Update as GithubUpdater, cargo_crate_version, update::Release as UpdRelease, use self_update::{cargo_crate_version, Status};
Status,
}; use crate::utils::parser::parse_semver;
/// The status of the update in case of success /// The status of the update in case of success
#[derive(Debug, Eq, PartialEq)] #[derive(Debug, Eq, PartialEq)]
@@ -131,10 +130,10 @@ impl From<UpdRelease> for Release {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn auto_update_default() { fn auto_update_default() {
let upd: Update = Update::default(); let upd: Update = Update::default();
+14 -11
View File
@@ -3,9 +3,16 @@
//! `bookmarks_client` is the module which provides an API between the Bookmarks module and the system //! `bookmarks_client` is the module which provides an API between the Bookmarks module and the system
// Crate // 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")] #[cfg(feature = "with-keyring")]
use super::keys::keyringstorage::KeyringStorage; use super::keys::keyringstorage::KeyringStorage;
use super::keys::{filestorage::FileStorage, KeyStorage, KeyStorageError}; use super::keys::{KeyStorage, KeyStorageError};
// Local // Local
use crate::config::{ use crate::config::{
bookmarks::{Bookmark, UserHosts}, bookmarks::{Bookmark, UserHosts},
@@ -15,11 +22,6 @@ use crate::filetransfer::FileTransferParams;
use crate::utils::crypto; use crate::utils::crypto;
use crate::utils::fmt::fmt_time; use crate::utils::fmt::fmt_time;
use crate::utils::random::random_alphanumeric_with_len; 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 /// BookmarksClient provides a layer between the host system and the bookmarks module
pub struct BookmarksClient { pub struct BookmarksClient {
@@ -370,15 +372,16 @@ impl BookmarksClient {
#[cfg(not(target_os = "macos"))] // CI/CD blocks #[cfg(not(target_os = "macos"))] // CI/CD blocks
mod tests { mod tests {
use std::thread::sleep;
use std::time::Duration;
use pretty_assertions::assert_eq;
use tempfile::TempDir;
use super::*; use super::*;
use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams}; use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams};
use crate::filetransfer::{FileTransferProtocol, ProtocolParams}; use crate::filetransfer::{FileTransferProtocol, ProtocolParams};
use pretty_assertions::assert_eq;
use std::thread::sleep;
use std::time::Duration;
use tempfile::TempDir;
#[test] #[test]
fn test_system_bookmarks_new() { fn test_system_bookmarks_new() {
+10 -10
View File
@@ -3,12 +3,6 @@
//! `config_client` is the module which provides an API between the Config module and the system //! `config_client` is the module which provides an API between the Config module and the system
// Locals // Locals
use crate::config::{
params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD},
serialization::{deserialize, serialize, SerializerError, SerializerErrorKind},
};
use crate::explorer::GroupDirs;
use crate::filetransfer::FileTransferProtocol;
// Ext // Ext
use std::fs::{create_dir, remove_file, File, OpenOptions}; use std::fs::{create_dir, remove_file, File, OpenOptions};
use std::io::Write; use std::io::Write;
@@ -16,6 +10,11 @@ use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use std::string::ToString; 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 // Types
pub type SshHost = (String, String, PathBuf); // 0: host, 1: username, 2: RSA key path pub type SshHost = (String, String, PathBuf); // 0: host, 1: username, 2: RSA key path
@@ -414,14 +413,15 @@ impl ConfigClient {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io::Read;
use pretty_assertions::assert_eq;
use tempfile::TempDir;
use super::*; use super::*;
use crate::config::UserConfig; use crate::config::UserConfig;
use crate::utils::random::random_alphanumeric_with_len; use crate::utils::random::random_alphanumeric_with_len;
use pretty_assertions::assert_eq;
use std::io::Read;
use tempfile::TempDir;
#[test] #[test]
fn test_system_config_new() { fn test_system_config_new() {
let tmp_dir: TempDir = TempDir::new().ok().unwrap(); let tmp_dir: TempDir = TempDir::new().ok().unwrap();
+4 -3
View File
@@ -101,12 +101,13 @@ pub fn get_theme_path(config_dir: &Path) -> PathBuf {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use std::fs::{File, OpenOptions};
use std::io::Write;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use serial_test::serial; use serial_test::serial;
use std::fs::{File, OpenOptions};
use std::io::Write; use super::*;
#[test] #[test]
#[serial] #[serial]
+4 -3
View File
@@ -3,12 +3,13 @@
//! `filestorage` provides an implementation of the `KeyStorage` trait using a file //! `filestorage` provides an implementation of the `KeyStorage` trait using a file
// Local // Local
use super::{KeyStorage, KeyStorageError};
// Ext // Ext
use std::fs::{OpenOptions, Permissions}; use std::fs::{OpenOptions, Permissions};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; 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 /// File storage is an implementation o the `KeyStorage` which uses a file to store the key
pub struct FileStorage { pub struct FileStorage {
dir_path: PathBuf, dir_path: PathBuf,
@@ -90,10 +91,10 @@ impl KeyStorage for FileStorage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_system_keys_filestorage_make_dir() { fn test_system_keys_filestorage_make_dir() {
let storage: FileStorage = FileStorage::new(Path::new("/tmp/")); let storage: FileStorage = FileStorage::new(Path::new("/tmp/"));
+4 -3
View File
@@ -3,10 +3,11 @@
//! `keyringstorage` provides an implementation of the `KeyStorage` trait using the OS keyring //! `keyringstorage` provides an implementation of the `KeyStorage` trait using the OS keyring
// Local // Local
use super::{KeyStorage, KeyStorageError};
// Ext // Ext
use keyring::{Entry as Keyring, Error as KeyringError}; use keyring::{Entry as Keyring, Error as KeyringError};
use super::{KeyStorage, KeyStorageError};
/// provides a `KeyStorage` implementation using the keyring crate /// provides a `KeyStorage` implementation using the keyring crate
pub struct KeyringStorage { pub struct KeyringStorage {
username: String, username: String,
@@ -75,11 +76,11 @@ impl KeyStorage for KeyringStorage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use whoami::username; use whoami::username;
use super::*;
#[test] #[test]
fn test_system_keys_keyringstorage() { fn test_system_keys_keyringstorage() {
let username: String = username(); let username: String = username();
+3 -4
View File
@@ -7,10 +7,9 @@ pub mod filestorage;
#[cfg(feature = "with-keyring")] #[cfg(feature = "with-keyring")]
pub mod keyringstorage; pub mod keyringstorage;
// ext // ext
use thiserror::Error;
#[cfg(feature = "with-keyring")] #[cfg(feature = "with-keyring")]
use keyring::Error as KeyringError; use keyring::Error as KeyringError;
use thiserror::Error;
/// defines the error type for the `KeyStorage` /// defines the error type for the `KeyStorage`
#[derive(Debug, Error)] #[derive(Debug, Error)]
@@ -53,10 +52,10 @@ pub trait KeyStorage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_system_keys_mod_errors() { fn test_system_keys_mod_errors() {
#[cfg(feature = "with-keyring")] #[cfg(feature = "with-keyring")]
+3 -2
View File
@@ -2,11 +2,12 @@
//! //!
//! `logging` is the module which initializes the logging system for termscp //! `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; pub use simplelog::LevelFilter as LogLevel;
use simplelog::{ConfigBuilder, WriteLogger}; use simplelog::{ConfigBuilder, WriteLogger};
use super::environment::{get_log_paths, init_cache_dir};
use crate::utils::file::open_file;
/// Initialize logger /// Initialize logger
pub fn init(level: LogLevel) -> Result<(), String> { pub fn init(level: LogLevel) -> Result<(), String> {
// Init cache dir // Init cache dir
+9 -6
View File
@@ -3,12 +3,14 @@
//! `SshKeyStorage` is the module which behaves a storage for ssh keys //! `SshKeyStorage` is the module which behaves a storage for ssh keys
// Locals // Locals
use super::config_client::ConfigClient; use std::collections::HashMap;
use std::path::{Path, PathBuf};
// Ext // Ext
use remotefs_ssh::SshKeyStorage as SshKeyStorageTrait; use remotefs_ssh::SshKeyStorage as SshKeyStorageTrait;
use ssh2_config::SshConfig; use ssh2_config::SshConfig;
use std::collections::HashMap;
use std::path::{Path, PathBuf}; use super::config_client::ConfigClient;
#[derive(Default)] #[derive(Default)]
pub struct SshKeyStorage { pub struct SshKeyStorage {
@@ -117,13 +119,14 @@ impl From<&ConfigClient> for SshKeyStorage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::path::Path;
use pretty_assertions::assert_eq;
use super::*; use super::*;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
use crate::utils::test_helpers; use crate::utils::test_helpers;
use pretty_assertions::assert_eq;
use std::path::Path;
#[test] #[test]
fn test_system_sshkey_storage_new() { fn test_system_sshkey_storage_new() {
let tmp_dir: tempfile::TempDir = tempfile::TempDir::new().ok().unwrap(); let tmp_dir: tempfile::TempDir = tempfile::TempDir::new().ok().unwrap();
+5 -6
View File
@@ -3,15 +3,14 @@
//! `theme_provider` is the module which provides an API between the theme configuration and the system //! `theme_provider` is the module which provides an API between the theme configuration and the system
// Locals // Locals
use crate::config::{
serialization::{deserialize, serialize, SerializerError, SerializerErrorKind},
themes::Theme,
};
// Ext // Ext
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::string::ToString; 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 /// ThemeProvider provides a high level API to communicate with the termscp theme
pub struct ThemeProvider { pub struct ThemeProvider {
theme: Theme, // Theme loaded theme: Theme, // Theme loaded
@@ -142,12 +141,12 @@ impl ThemeProvider {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use tempfile::TempDir; use tempfile::TempDir;
use tuirealm::tui::style::Color; use tuirealm::tui::style::Color;
use super::*;
#[test] #[test]
fn test_system_theme_provider_new() { fn test_system_theme_provider_new() {
let tmp_dir: tempfile::TempDir = TempDir::new().ok().unwrap(); let tmp_dir: tempfile::TempDir = TempDir::new().ok().unwrap();
+4 -4
View File
@@ -2,10 +2,10 @@
//! //!
//! this module exposes the types to describe a change to sync on the remote file system //! 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 std::path::{Path, PathBuf};
use crate::utils::path as path_utils;
/// Describes an operation on the remote file system to sync /// Describes an operation on the remote file system to sync
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub enum FsChange { pub enum FsChange {
@@ -190,10 +190,10 @@ fn remote_relative_path(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn should_get_remote_relative_path_from_subdir() { fn should_get_remote_relative_path_from_subdir() {
assert_eq!( assert_eq!(
+11 -12
View File
@@ -5,19 +5,19 @@
mod change; mod change;
// -- export // -- 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::collections::HashMap;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError}; use std::sync::mpsc::{channel, Receiver, RecvTimeoutError};
use std::time::Duration; use std::time::Duration;
pub use change::FsChange;
use notify::{
watcher, DebouncedEvent, Error as WatcherError, RecommendedWatcher, RecursiveMode, Watcher,
};
use thiserror::Error; use thiserror::Error;
use crate::utils::path as path_utils;
type FsWatcherResult<T> = Result<T, FsWatcherError>; type FsWatcherResult<T> = Result<T, FsWatcherError>;
/// Describes an error returned by the `FsWatcher` /// Describes an error returned by the `FsWatcher`
@@ -172,14 +172,13 @@ impl FsWatcher {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*;
#[cfg(target_os = "macos")]
use crate::utils::test_helpers;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use tempfile::TempDir; use tempfile::TempDir;
use super::*;
#[cfg(target_os = "macos")]
use crate::utils::test_helpers;
#[test] #[test]
fn should_init_fswatcher() { fn should_init_fswatcher() {
let watcher = FsWatcher::init(Duration::from_secs(5)).unwrap(); let watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
@@ -2,14 +2,14 @@
//! //!
//! auth activity bookmarks components //! auth activity bookmarks components
use super::{FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{Input, List, Radio}; use tui_realm_stdlib::{Input, List, Radio};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, InputType, TextSpan}; use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, InputType, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
use super::{FormMsg, Msg, UiMsg};
// -- bookmark list // -- bookmark list
#[derive(MockComponent)] #[derive(MockComponent)]
+2 -2
View File
@@ -2,14 +2,14 @@
//! //!
//! auth activity components for file transfer params form //! auth activity components for file transfer params form
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{Input, Radio}; use tui_realm_stdlib::{Input, Radio};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style}; use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
// -- protocol // -- protocol
#[derive(MockComponent)] #[derive(MockComponent)]
-1
View File
@@ -23,7 +23,6 @@ pub use popup::{
WindowSizeError, WindowSizeError,
}; };
pub use text::{HelpFooter, NewVersionDisclaimer, Subtitle, Title}; pub use text::{HelpFooter, NewVersionDisclaimer, Subtitle, Title};
use tui_realm_stdlib::Phantom; use tui_realm_stdlib::Phantom;
use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent}; use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent};
use tuirealm::{Component, MockComponent}; use tuirealm::{Component, MockComponent};
+2 -2
View File
@@ -2,14 +2,14 @@
//! //!
//! auth activity popups //! auth activity popups
use super::{FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{List, Paragraph, Radio, Textarea}; use tui_realm_stdlib::{List, Paragraph, Radio, Textarea};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderType, Borders, Color, TableBuilder, TextSpan}; use tuirealm::props::{Alignment, BorderType, Borders, Color, TableBuilder, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
use super::{FormMsg, Msg, UiMsg};
// -- error popup // -- error popup
#[derive(MockComponent)] #[derive(MockComponent)]
+2 -2
View File
@@ -2,12 +2,12 @@
//! //!
//! auth activity texts //! auth activity texts
use super::Msg;
use tui_realm_stdlib::{Label, Span}; use tui_realm_stdlib::{Label, Span};
use tuirealm::props::{Color, TextModifiers, TextSpan}; use tuirealm::props::{Color, TextModifiers, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent}; use tuirealm::{Component, Event, MockComponent, NoUserEvent};
use super::Msg;
// -- Title // -- Title
#[derive(MockComponent)] #[derive(MockComponent)]
+7 -5
View File
@@ -10,17 +10,19 @@ mod update;
mod view; mod view;
// locals // 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 super::{Activity, Context, ExitReason};
use crate::config::themes::Theme; use crate::config::themes::Theme;
use crate::filetransfer::{FileTransferParams, FileTransferProtocol}; use crate::filetransfer::{FileTransferParams, FileTransferProtocol};
use crate::system::bookmarks_client::BookmarksClient; use crate::system::bookmarks_client::BookmarksClient;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
// Includes
use std::time::Duration;
use tuirealm::listener::EventListenerCfg;
use tuirealm::{application::PollStrategy, Application, NoUserEvent, Update};
// -- components // -- components
#[derive(Debug, Eq, PartialEq, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Clone, Hash)]
pub enum Id { pub enum Id {
+2 -2
View File
@@ -2,10 +2,10 @@
//! //!
//! Update impl //! Update impl
use super::{AuthActivity, ExitReason, FormMsg, Id, InputMask, Msg, UiMsg, Update};
use tuirealm::{State, StateValue}; use tuirealm::{State, StateValue};
use super::{AuthActivity, ExitReason, FormMsg, Id, InputMask, Msg, UiMsg, Update};
impl Update<Msg> for AuthActivity { impl Update<Msg> for AuthActivity {
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> { fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {
self.redraw = true; self.redraw = true;
+7 -6
View File
@@ -3,17 +3,18 @@
//! `auth_activity` is the module which implements the authentication activity //! `auth_activity` is the module which implements the authentication activity
// Locals // 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 super::{components, AuthActivity, Context, FileTransferProtocol, Id, InputMask};
use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams}; use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams};
use crate::filetransfer::FileTransferParams; use crate::filetransfer::FileTransferParams;
use crate::utils::ui::{Popup, Size}; 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 { impl AuthActivity {
/// Initialize view, mounting all startup components inside the view /// Initialize view, mounting all startup components inside the view
pub(super) fn init(&mut self) { pub(super) fn init(&mut self) {
@@ -3,10 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileExplorerTab, FileTransferActivity, LogLevel, Msg, PendingActionMsg}; use std::path::PathBuf;
use remotefs::File; use remotefs::File;
use std::path::PathBuf;
use super::{FileExplorerTab, FileTransferActivity, LogLevel, Msg, PendingActionMsg};
/// Describes destination for sync browsing /// Describes destination for sync browsing
enum SyncBrowsingDestination { enum SyncBrowsingDestination {
@@ -3,10 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload}; use std::path::{Path, PathBuf};
use remotefs::{File, RemoteErrorType}; use remotefs::{File, RemoteErrorType};
use std::path::{Path, PathBuf};
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
impl FileTransferActivity { impl FileTransferActivity {
/// Copy file on local /// Copy file on local
@@ -3,10 +3,10 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileTransferActivity, LogLevel, SelectedFile};
use remotefs::File; use remotefs::File;
use super::{FileTransferActivity, LogLevel, SelectedFile};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_delete(&mut self) { pub(crate) fn action_local_delete(&mut self) {
match self.get_local_selected_entries() { match self.get_local_selected_entries() {
@@ -3,15 +3,16 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
// ext
use remotefs::File;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Read; use std::io::Read;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::time::SystemTime; use std::time::SystemTime;
// ext
use remotefs::File;
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_edit_local_file(&mut self) { pub(crate) fn action_edit_local_file(&mut self) {
let entries: Vec<File> = match self.get_local_selected_entries() { let entries: Vec<File> = match self.get_local_selected_entries() {
@@ -3,11 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use std::path::PathBuf;
use super::super::browser::FileExplorerTab; use super::super::browser::FileExplorerTab;
use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferOpts, TransferPayload}; use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferOpts, TransferPayload};
use std::path::PathBuf;
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_find(&mut self, input: String) -> Result<Vec<File>, String> { pub(crate) fn action_local_find(&mut self, input: String) -> Result<Vec<File>, String> {
match self.host.find(input.as_str()) { match self.host.find(input.as_str()) {
@@ -3,10 +3,12 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileTransferActivity, LogLevel};
use remotefs::fs::UnixPex;
use std::path::PathBuf; use std::path::PathBuf;
use remotefs::fs::UnixPex;
use super::{FileTransferActivity, LogLevel};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_mkdir(&mut self, input: String) { pub(crate) fn action_local_mkdir(&mut self, input: String) {
match self.host.mkdir(PathBuf::from(input.as_str()).as_path()) { match self.host.mkdir(PathBuf::from(input.as_str()).as_path()) {
@@ -2,13 +2,15 @@
//! //!
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `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; pub(self) use remotefs::File;
use tuirealm::{State, StateValue}; use tuirealm::{State, StateValue};
pub(self) use super::browser::FileExplorerTab;
pub(self) use super::{
FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts,
TransferPayload, UiMsg,
};
// actions // actions
pub(crate) mod change_dir; pub(crate) mod change_dir;
pub(crate) mod copy; pub(crate) mod copy;
@@ -3,10 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{File, FileTransferActivity, LogLevel};
use std::fs::File as StdFile; use std::fs::File as StdFile;
use std::path::PathBuf; use std::path::PathBuf;
use super::{File, FileTransferActivity, LogLevel};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_newfile(&mut self, input: String) { pub(crate) fn action_local_newfile(&mut self, input: String) {
// Check if file exists // Check if file exists
@@ -3,10 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
// ext // ext
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
impl FileTransferActivity { impl FileTransferActivity {
/// Open local file /// Open local file
pub(crate) fn action_open_local(&mut self) { pub(crate) fn action_open_local(&mut self) {
@@ -3,10 +3,10 @@
//! this little module exposes the routine to create a pending action on the file transfer activity. //! 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`. //! 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 tuirealm::{PollStrategy, Update};
use super::{FileTransferActivity, Msg};
impl FileTransferActivity { impl FileTransferActivity {
/// Block execution of activity, preventing ANY kind of message not specified in the `wait_for` argument. /// 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. /// Once `wait_for` clause is satisfied, the function returns.
@@ -3,10 +3,11 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{File, FileTransferActivity, LogLevel, SelectedFile}; use std::path::{Path, PathBuf};
use remotefs::RemoteErrorType; use remotefs::RemoteErrorType;
use std::path::{Path, PathBuf};
use super::{File, FileTransferActivity, LogLevel, SelectedFile};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_rename(&mut self, input: String) { pub(crate) fn action_local_rename(&mut self, input: String) {
@@ -3,11 +3,12 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use std::path::{Path, PathBuf};
use super::{ use super::{
File, FileTransferActivity, LogLevel, Msg, PendingActionMsg, SelectedFile, TransferOpts, File, FileTransferActivity, LogLevel, Msg, PendingActionMsg, SelectedFile, TransferOpts,
TransferPayload, TransferPayload,
}; };
use std::path::{Path, PathBuf};
impl FileTransferActivity { impl FileTransferActivity {
pub(crate) fn action_local_saveas(&mut self, input: String) { pub(crate) fn action_local_saveas(&mut self, input: String) {
@@ -3,10 +3,10 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{FileTransferActivity, LogLevel, SelectedFile};
use std::path::PathBuf; use std::path::PathBuf;
use super::{FileTransferActivity, LogLevel, SelectedFile};
impl FileTransferActivity { impl FileTransferActivity {
/// Create symlink on localhost /// Create symlink on localhost
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
@@ -2,10 +2,10 @@
//! //!
//! actions associated to the file watcher //! actions associated to the file watcher
use super::{FileTransferActivity, LogLevel, Msg, SelectedFile, TransferMsg, UiMsg};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use super::{FileTransferActivity, LogLevel, Msg, SelectedFile, TransferMsg, UiMsg};
impl FileTransferActivity { impl FileTransferActivity {
pub fn action_show_radio_watch(&mut self) { pub fn action_show_radio_watch(&mut self) {
// return if fswatcher is not working // return if fswatcher is not working
@@ -2,8 +2,6 @@
//! //!
//! log tab component //! log tab component
use super::{Msg, UiMsg};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent}; use tuirealm::event::{Key, KeyEvent};
use tuirealm::props::{Alignment, AttrValue, Attribute, Borders, Color, Style, Table}; 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::tui::widgets::{List as TuiList, ListItem, ListState};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, Props, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, Props, State, StateValue};
use super::{Msg, UiMsg};
pub struct Log { pub struct Log {
props: Props, props: Props,
states: OwnStates, states: OwnStates,
@@ -2,12 +2,12 @@
//! //!
//! file transfer activity components //! file transfer activity components
use super::Msg;
use tui_realm_stdlib::Span; use tui_realm_stdlib::Span;
use tuirealm::props::{Color, TextSpan}; use tuirealm::props::{Color, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent}; use tuirealm::{Component, Event, MockComponent, NoUserEvent};
use super::Msg;
#[derive(MockComponent)] #[derive(MockComponent)]
pub struct FooterBar { pub struct FooterBar {
component: Span, component: Span,
@@ -2,13 +2,11 @@
//! //!
//! file transfer activity components //! file transfer activity components
use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
use tui_realm_stdlib::Phantom; use tui_realm_stdlib::Phantom;
use tuirealm::{ use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers};
event::{Event, Key, KeyEvent, KeyModifiers}, use tuirealm::{Component, MockComponent, NoUserEvent};
Component, MockComponent, NoUserEvent,
}; use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
// -- export // -- export
mod log; mod log;
@@ -16,7 +14,6 @@ mod misc;
mod popups; mod popups;
mod transfer; mod transfer;
pub use self::log::Log;
pub use misc::FooterBar; pub use misc::FooterBar;
pub use popups::{ pub use popups::{
CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, ExecPopup, FatalPopup, FileInfoPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, ExecPopup, FatalPopup, FileInfoPopup,
@@ -27,6 +24,8 @@ pub use popups::{
}; };
pub use transfer::{ExplorerFind, ExplorerLocal, ExplorerRemote}; pub use transfer::{ExplorerFind, ExplorerLocal, ExplorerRemote};
pub use self::log::Log;
#[derive(Default, MockComponent)] #[derive(Default, MockComponent)]
pub struct GlobalListener { pub struct GlobalListener {
component: Phantom, component: Phantom,
@@ -2,15 +2,10 @@
//! //!
//! popups components //! popups components
use super::super::Browser; use std::time::UNIX_EPOCH;
use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
use crate::explorer::FileSorting;
use crate::utils::fmt::fmt_time;
use bytesize::ByteSize; use bytesize::ByteSize;
use remotefs::File; use remotefs::File;
use std::time::UNIX_EPOCH;
use tui_realm_stdlib::{Input, List, Paragraph, ProgressBar, Radio, Span}; use tui_realm_stdlib::{Input, List, Paragraph, ProgressBar, Radio, Span};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
@@ -21,6 +16,11 @@ use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use users::{get_group_by_gid, get_user_by_uid}; 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)] #[derive(MockComponent)]
pub struct CopyPopup { pub struct CopyPopup {
component: Input, component: Input,
@@ -6,7 +6,6 @@ use super::{Msg, TransferMsg, UiMsg};
mod file_list; mod file_list;
use file_list::FileList; use file_list::FileList;
use tuirealm::command::{Cmd, Direction, Position}; use tuirealm::command::{Cmd, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, Borders, Color, TextSpan}; use tuirealm::props::{Alignment, Borders, Color, TextSpan};
+2 -2
View File
@@ -1,8 +1,8 @@
use std::path::Path;
use super::{FileTransferActivity, LogLevel, TransferPayload}; use super::{FileTransferActivity, LogLevel, TransferPayload};
use crate::system::watcher::FsChange; use crate::system::watcher::FsChange;
use std::path::Path;
impl FileTransferActivity { impl FileTransferActivity {
/// poll file watcher /// poll file watcher
pub(super) fn poll_watcher(&mut self) { pub(super) fn poll_watcher(&mut self) {
@@ -2,11 +2,13 @@
//! //!
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `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 std::path::Path;
use crate::system::config_client::ConfigClient;
use remotefs::File; 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 /// File explorer tab
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
@@ -2,10 +2,11 @@
//! //!
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
use bytesize::ByteSize;
use std::fmt; use std::fmt;
use std::time::Instant; use std::time::Instant;
use bytesize::ByteSize;
// -- States and progress // -- States and progress
/// TransferStates contains the states related to the transfer process /// TransferStates contains the states related to the transfer process
@@ -173,10 +174,11 @@ impl TransferOpts {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use std::time::Duration;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use std::time::Duration;
use super::*;
#[test] #[test]
fn test_ui_activities_filetransfer_lib_transfer_progress_states() { fn test_ui_activities_filetransfer_lib_transfer_progress_states() {
+11 -11
View File
@@ -1,21 +1,21 @@
// Locals // Locals
use super::{ use std::env;
browser::FileExplorerTab, ConfigClient, FileTransferActivity, Id, LogLevel, LogRecord, use std::path::{Path, PathBuf};
TransferPayload,
// 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::filetransfer::ProtocolParams;
use crate::system::environment; use crate::system::environment;
use crate::system::notifications::Notification; use crate::system::notifications::Notification;
use crate::utils::fmt::{fmt_millis, fmt_path_elide_ex}; use crate::utils::fmt::{fmt_millis, fmt_path_elide_ex};
use crate::utils::path; 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; const LOG_CAPACITY: usize = 256;
+13 -12
View File
@@ -13,6 +13,19 @@ mod update;
mod view; mod view;
// locals // 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 super::{Activity, Context, ExitReason};
use crate::config::themes::Theme; use crate::config::themes::Theme;
use crate::explorer::{FileExplorer, FileSorting}; use crate::explorer::{FileExplorer, FileSorting};
@@ -20,18 +33,6 @@ use crate::filetransfer::{Builder, FileTransferParams};
use crate::host::Localhost; use crate::host::Localhost;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
use crate::system::watcher::FsWatcher; 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 // -- components
+8 -7
View File
@@ -3,20 +3,21 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// Locals // Locals
use super::{FileTransferActivity, LogLevel}; use std::fs::File as StdFile;
use crate::host::HostError; use std::io::{Read, Seek, Write};
use crate::utils::fmt::fmt_millis; use std::path::{Path, PathBuf};
use std::time::Instant;
// Ext // Ext
use bytesize::ByteSize; use bytesize::ByteSize;
use remotefs::fs::{File, Metadata, ReadStream, UnixPex, Welcome, WriteStream}; use remotefs::fs::{File, Metadata, ReadStream, UnixPex, Welcome, WriteStream};
use remotefs::{RemoteError, RemoteErrorType}; 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 thiserror::Error;
use super::{FileTransferActivity, LogLevel};
use crate::host::HostError;
use crate::utils::fmt::fmt_millis;
/// Buffer size for remote I/O /// Buffer size for remote I/O
const BUFSIZE: usize = 65535; const BUFSIZE: usize = 65535;
+6 -9
View File
@@ -3,17 +3,14 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{
actions::SelectedFile,
browser::{FileExplorerTab, FoundExplorerTab},
ExitReason, FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg,
};
// externals // externals
use remotefs::fs::File; use remotefs::fs::File;
use tuirealm::{ use tuirealm::props::{AttrValue, Attribute};
props::{AttrValue, Attribute}, use tuirealm::{State, StateValue, Update};
State, StateValue, Update,
}; use super::actions::SelectedFile;
use super::browser::{FileExplorerTab, FoundExplorerTab};
use super::{ExitReason, FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg};
impl Update<Msg> for FileTransferActivity { impl Update<Msg> for FileTransferActivity {
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> { fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {
+5 -6
View File
@@ -3,12 +3,6 @@
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall //! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals // locals
use super::{
browser::{FileExplorerTab, FoundExplorerTab},
components, Context, FileTransferActivity, Id,
};
use crate::explorer::FileSorting;
use crate::utils::ui::{Popup, Size};
// Ext // Ext
use remotefs::fs::File; use remotefs::fs::File;
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
@@ -17,6 +11,11 @@ use tuirealm::tui::widgets::Clear;
use tuirealm::{Sub, SubClause, SubEventClause}; use tuirealm::{Sub, SubClause, SubEventClause};
use unicode_width::UnicodeWidthStr; 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 { impl FileTransferActivity {
// -- init // -- init
+5 -3
View File
@@ -4,12 +4,14 @@
//! work on termscp configuration //! work on termscp configuration
// Locals // Locals
use std::env;
use tuirealm::tui::style::Color;
use tuirealm::{State, StateValue};
use super::{Id, IdSsh, IdTheme, SetupActivity, ViewLayout}; use super::{Id, IdSsh, IdTheme, SetupActivity, ViewLayout};
// Ext // Ext
use crate::config::themes::Theme; use crate::config::themes::Theme;
use std::env;
use tuirealm::tui::style::Color;
use tuirealm::{State, StateValue};
impl SetupActivity { impl SetupActivity {
/// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise /// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise
@@ -2,14 +2,14 @@
//! //!
//! config tab components //! config tab components
use super::{CommonMsg, Msg, ViewLayout};
use tui_realm_stdlib::{List, Paragraph, Radio, Span}; use tui_realm_stdlib::{List, Paragraph, Radio, Span};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, TableBuilder, TextSpan}; use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, TableBuilder, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
use super::{CommonMsg, Msg, ViewLayout};
#[derive(MockComponent)] #[derive(MockComponent)]
pub struct ErrorPopup { pub struct ErrorPopup {
component: Paragraph, component: Paragraph,
+5 -5
View File
@@ -2,17 +2,17 @@
//! //!
//! config tab components //! 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 tui_realm_stdlib::{Input, Radio};
use tuirealm::command::{Cmd, Direction, Position}; use tuirealm::command::{Cmd, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style}; use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style};
use tuirealm::{Component, Event, MockComponent, NoUserEvent}; 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 // -- components
#[derive(MockComponent)] #[derive(MockComponent)]
@@ -16,7 +16,6 @@ pub(super) use config::{
}; };
pub(super) use ssh::{DelSshKeyPopup, SshHost, SshKeys, SshUsername}; pub(super) use ssh::{DelSshKeyPopup, SshHost, SshKeys, SshUsername};
pub(super) use theme::*; pub(super) use theme::*;
use tui_realm_stdlib::Phantom; use tui_realm_stdlib::Phantom;
use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent}; use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent};
use tuirealm::{Component, MockComponent}; use tuirealm::{Component, MockComponent};
+2 -2
View File
@@ -2,8 +2,6 @@
//! //!
//! ssh components //! ssh components
use super::{Msg, SshMsg};
use tui_realm_stdlib::{Input, List, Radio}; use tui_realm_stdlib::{Input, List, Radio};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
@@ -12,6 +10,8 @@ use tuirealm::props::{
}; };
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
use super::{Msg, SshMsg};
/* DelSshKeyPopup, /* DelSshKeyPopup,
SshHost, SshHost,
SshKeys, SshKeys,
+3 -3
View File
@@ -2,9 +2,6 @@
//! //!
//! theme tab components //! theme tab components
use super::{Msg, ThemeMsg};
use crate::ui::activities::setup::IdTheme;
use tui_realm_stdlib::{Input, Label}; use tui_realm_stdlib::{Input, Label};
use tuirealm::command::{Cmd, CmdResult, Direction, Position}; use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent, KeyModifiers}; use tuirealm::event::{Key, KeyEvent, KeyModifiers};
@@ -13,6 +10,9 @@ use tuirealm::{
AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue, AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue,
}; };
use super::{Msg, ThemeMsg};
use crate::ui::activities::setup::IdTheme;
// -- components // -- components
#[derive(MockComponent)] #[derive(MockComponent)]
+2 -1
View File
@@ -4,10 +4,11 @@
//! work on termscp configuration //! work on termscp configuration
// Locals // Locals
use super::SetupActivity;
// Ext // Ext
use std::env; use std::env;
use super::SetupActivity;
impl SetupActivity { impl SetupActivity {
/// Save configuration /// Save configuration
pub(super) fn save_config(&mut self) -> Result<(), String> { pub(super) fn save_config(&mut self) -> Result<(), String> {
+8 -5
View File
@@ -11,15 +11,18 @@ mod update;
mod view; mod view;
// Locals // 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 super::{Activity, Context, ExitReason};
use crate::config::themes::Theme; use crate::config::themes::Theme;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
use crate::system::theme_provider::ThemeProvider; 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 // -- components
#[derive(Debug, Eq, PartialEq, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Clone, Hash)]
+3 -3
View File
@@ -4,14 +4,14 @@
//! work on termscp configuration //! work on termscp configuration
// locals // locals
// ext
use tuirealm::Update;
use super::{ use super::{
CommonMsg, ConfigMsg, Id, IdConfig, IdSsh, IdTheme, Msg, SetupActivity, SshMsg, ThemeMsg, CommonMsg, ConfigMsg, Id, IdConfig, IdSsh, IdTheme, Msg, SetupActivity, SshMsg, ThemeMsg,
ViewLayout, ViewLayout,
}; };
// ext
use tuirealm::Update;
impl Update<Msg> for SetupActivity { impl Update<Msg> for SetupActivity {
/// Update auth activity model based on msg /// Update auth activity model based on msg
/// The function exits when returns None /// The function exits when returns None
+5 -7
View File
@@ -7,17 +7,15 @@ pub mod setup;
pub mod ssh_keys; pub mod ssh_keys;
pub mod theme; pub mod theme;
use super::*;
use crate::utils::ui::{Popup, Size};
pub use setup::*; pub use setup::*;
pub use ssh_keys::*; pub use ssh_keys::*;
pub use theme::*; pub use theme::*;
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::tui::widgets::Clear; use tuirealm::tui::widgets::Clear;
use tuirealm::{ use tuirealm::{Frame, Sub, SubClause, SubEventClause};
event::{Key, KeyEvent, KeyModifiers},
Frame, Sub, SubClause, SubEventClause, use super::*;
}; use crate::utils::ui::{Popup, Size};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
+6 -5
View File
@@ -4,16 +4,17 @@
//! work on termscp configuration //! work on termscp configuration
// Locals // 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 super::{components, Context, Id, IdCommon, IdConfig, SetupActivity, ViewLayout};
use crate::explorer::GroupDirs; use crate::explorer::GroupDirs;
use crate::filetransfer::FileTransferProtocol; use crate::filetransfer::FileTransferProtocol;
use crate::utils::fmt::fmt_bytes; use crate::utils::fmt::fmt_bytes;
// Ext
use std::path::PathBuf;
use tuirealm::tui::layout::{Constraint, Direction, Layout};
use tuirealm::{State, StateValue};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
+3 -3
View File
@@ -4,13 +4,13 @@
//! work on termscp configuration //! work on termscp configuration
// Locals // Locals
use super::{components, Context, Id, IdCommon, IdSsh, SetupActivity, ViewLayout};
use crate::utils::ui::{Popup, Size};
// Ext // Ext
use tuirealm::tui::layout::{Constraint, Direction, Layout}; use tuirealm::tui::layout::{Constraint, Direction, Layout};
use tuirealm::tui::widgets::Clear; use tuirealm::tui::widgets::Clear;
use super::{components, Context, Id, IdCommon, IdSsh, SetupActivity, ViewLayout};
use crate::utils::ui::{Popup, Size};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
+2 -2
View File
@@ -4,11 +4,11 @@
//! work on termscp configuration //! work on termscp configuration
// Locals // Locals
use super::{components, Context, Id, IdCommon, IdTheme, SetupActivity, Theme, ViewLayout};
// Ext // Ext
use tuirealm::tui::layout::{Constraint, Direction, Layout}; use tuirealm::tui::layout::{Constraint, Direction, Layout};
use super::{components, Context, Id, IdCommon, IdTheme, SetupActivity, Theme, ViewLayout};
impl SetupActivity { impl SetupActivity {
// -- view // -- view
+2 -2
View File
@@ -3,14 +3,14 @@
//! `Context` is the module which provides all the functionalities related to the UI data holder, called Context //! `Context` is the module which provides all the functionalities related to the UI data holder, called Context
// Locals // Locals
use tuirealm::terminal::TerminalBridge;
use super::store::Store; use super::store::Store;
use crate::filetransfer::FileTransferParams; use crate::filetransfer::FileTransferParams;
use crate::system::bookmarks_client::BookmarksClient; use crate::system::bookmarks_client::BookmarksClient;
use crate::system::config_client::ConfigClient; use crate::system::config_client::ConfigClient;
use crate::system::theme_provider::ThemeProvider; use crate::system::theme_provider::ThemeProvider;
use tuirealm::terminal::TerminalBridge;
/// Context holds data structures shared by the activities /// Context holds data structures shared by the activities
pub struct Context { pub struct Context {
ft_params: Option<FileTransferParams>, ft_params: Option<FileTransferParams>,
+2 -2
View File
@@ -163,10 +163,10 @@ impl Store {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_ui_store() { fn test_ui_store() {
// Create store // Create store
+2 -2
View File
@@ -20,10 +20,10 @@ pub fn aes128_b64_decrypt(key: &str, secret: &str) -> Result<String, magic_crypt
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_crypto_aes128() { fn test_utils_crypto_aes128() {
let key: &str = "MYSUPERSECRETKEY"; let key: &str = "MYSUPERSECRETKEY";
+1 -2
View File
@@ -2,8 +2,7 @@
//! //!
//! `file` is the module which exposes file related utilities //! `file` is the module which exposes file related utilities
use std::fs::File; use std::fs::{File, OpenOptions};
use std::fs::OpenOptions;
use std::io; use std::io;
use std::path::Path; use std::path::Path;
+5 -5
View File
@@ -2,11 +2,11 @@
//! //!
//! `fmt` is the module which provides utilities for formatting //! `fmt` is the module which provides utilities for formatting
use remotefs::fs::UnixPexClass;
use chrono::prelude::*;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use chrono::prelude::*;
use remotefs::fs::UnixPexClass;
use tuirealm::tui::style::Color; use tuirealm::tui::style::Color;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
@@ -271,10 +271,10 @@ pub fn fmt_bytes(v: u64) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_fmt_pex() { fn test_utils_fmt_pex() {
assert_eq!(fmt_pex(UnixPexClass::from(7)), String::from("rwx")); assert_eq!(fmt_pex(UnixPexClass::from(7)), String::from("rwx"));
+11 -12
View File
@@ -3,23 +3,22 @@
//! `parser` is the module which provides utilities for parsing different kind of stuff //! `parser` is the module which provides utilities for parsing different kind of stuff
// Locals // Locals
use crate::filetransfer::{ use std::path::PathBuf;
params::{AwsS3Params, GenericProtocolParams, ProtocolParams}, use std::str::FromStr;
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;
// Ext // Ext
use bytesize::ByteSize; use bytesize::ByteSize;
use lazy_regex::{Lazy, Regex}; use lazy_regex::{Lazy, Regex};
use std::path::PathBuf;
use std::str::FromStr;
use tuirealm::tui::style::Color; use tuirealm::tui::style::Color;
use tuirealm::utils::parser as tuirealm_parser; 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 // Regex
/** /**
@@ -314,10 +313,10 @@ pub fn parse_bytesize<S: AsRef<str>>(bytes: S) -> Option<ByteSize> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_parse_remote_opt() { fn test_utils_parse_remote_opt() {
// Base case // Base case
+4 -3
View File
@@ -3,7 +3,8 @@
//! `random` is the module which provides utilities for rand //! `random` is the module which provides utilities for rand
// Ext // 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 /// Generate a random alphanumeric string with provided length
pub fn random_alphanumeric_with_len(len: usize) -> String { pub fn random_alphanumeric_with_len(len: usize) -> String {
@@ -18,10 +19,10 @@ pub fn random_alphanumeric_with_len(len: usize) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_random_alphanumeric_with_len() { fn test_utils_random_alphanumeric_with_len() {
assert_eq!(random_alphanumeric_with_len(256).len(), 256); assert_eq!(random_alphanumeric_with_len(256).len(), 256);
+4 -3
View File
@@ -2,11 +2,12 @@
//! //!
//! contains helper functions for tests //! contains helper functions for tests
use remotefs::fs::{File, FileType, Metadata};
// ext // ext
use std::fs::File as StdFile; use std::fs::File as StdFile;
use std::io::Write; use std::io::Write;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use remotefs::fs::{File, FileType, Metadata};
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
pub fn create_sample_file_entry() -> (File, NamedTempFile) { pub fn create_sample_file_entry() -> (File, NamedTempFile) {
@@ -74,10 +75,10 @@ pub fn create_file_ioers(p: &Path) -> (StdFile, StdFile) {
} }
mod test { mod test {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_test_helpers_sample_file() { fn test_utils_test_helpers_sample_file() {
let _ = create_sample_file_entry(); let _ = create_sample_file_entry();
+2 -2
View File
@@ -57,10 +57,10 @@ impl Popup {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*;
#[test] #[test]
fn test_utils_ui_draw_area_in() { fn test_utils_ui_draw_area_in() {
let area: Rect = Rect::new(0, 0, 1024, 512); let area: Rect = Rect::new(0, 0, 1024, 512);