mirror of
https://github.com/veeso/termscp.git
synced 2025-12-06 17:15:35 -08:00
fmt
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<String, PathBuf> = HashMap::with_capacity(1);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<FileExplorer>,
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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!(
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<UpdRelease> 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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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/"));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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!(
|
||||
|
||||
@@ -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<T> = Result<T, FsWatcherError>;
|
||||
|
||||
/// 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();
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Msg> for AuthActivity {
|
||||
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {
|
||||
self.redraw = true;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<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
|
||||
|
||||
// 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<Vec<File>, String> {
|
||||
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
|
||||
|
||||
// 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()) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<Msg> for FileTransferActivity {
|
||||
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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<Msg> for SetupActivity {
|
||||
/// Update auth activity model based on msg
|
||||
/// The function exits when returns None
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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<FileTransferParams>,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,10 +20,10 @@ pub fn aes128_b64_decrypt(key: &str, secret: &str) -> Result<String, magic_crypt
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_utils_crypto_aes128() {
|
||||
let key: &str = "MYSUPERSECRETKEY";
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
//!
|
||||
//! `file` is the module which exposes file related utilities
|
||||
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
//!
|
||||
//! `fmt` is the module which provides utilities for formatting
|
||||
|
||||
use remotefs::fs::UnixPexClass;
|
||||
|
||||
use chrono::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use chrono::prelude::*;
|
||||
use remotefs::fs::UnixPexClass;
|
||||
use tuirealm::tui::style::Color;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
@@ -271,10 +271,10 @@ pub fn fmt_bytes(v: u64) -> 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"));
|
||||
|
||||
@@ -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<S: AsRef<str>>(bytes: S) -> Option<ByteSize> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_utils_parse_remote_opt() {
|
||||
// Base case
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user