From 4475e8c24ce15129253e6ae09c0a1f6eb799bca1 Mon Sep 17 00:00:00 2001 From: veeso Date: Sat, 19 Jun 2021 13:44:38 +0200 Subject: [PATCH] 0.5.1 ready --- CHANGELOG.md | 2 +- README.md | 2 +- codecov.yml | 7 -- dist/build/x86_64_archlinux/Dockerfile | 2 +- docs/developer.md | 138 ------------------------- 5 files changed, 3 insertions(+), 148 deletions(-) delete mode 100644 codecov.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index b9e17ad..6cec85e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ ## 0.5.1 -Released on FIXME: ?? +Released on 21/06/2021 - Enhancements: - **CI now uses containers to test file transfers (SSH/FTP)** diff --git a/README.md b/README.md index 072a1bc..c1ee647 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@

Developed by @veeso

-

Current version: 0.5.1 (23/05/2021)

+

Current version: 0.5.1 (21/06/2021)

[![License: MIT](https://img.shields.io/badge/License-MIT-teal.svg)](https://opensource.org/licenses/MIT) [![Stars](https://img.shields.io/github/stars/veeso/termscp.svg)](https://github.com/veeso/termscp) [![Downloads](https://img.shields.io/crates/d/termscp.svg)](https://crates.io/crates/termscp) [![Crates.io](https://img.shields.io/badge/crates.io-v0.5.1-orange.svg)](https://crates.io/crates/termscp) [![Docs](https://docs.rs/termscp/badge.svg)](https://docs.rs/termscp) diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index a93ff15..0000000 --- a/codecov.yml +++ /dev/null @@ -1,7 +0,0 @@ -ignore: - - src/main.rs - - src/lib.rs - - src/activity_manager.rs - - src/ui/activities/ - - src/ui/context.rs - - src/ui/input.rs diff --git a/dist/build/x86_64_archlinux/Dockerfile b/dist/build/x86_64_archlinux/Dockerfile index ded6c9b..f9a1cc8 100644 --- a/dist/build/x86_64_archlinux/Dockerfile +++ b/dist/build/x86_64_archlinux/Dockerfile @@ -1,4 +1,4 @@ -FROM archlinux:base-20210120.0.13969 as builder +FROM archlinux:latest as builder WORKDIR /usr/src/ # Install dependencies diff --git a/docs/developer.md b/docs/developer.md index a382fca..81e4bb0 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -7,7 +7,6 @@ Document audience: developers - [How termscp works](#how-termscp-works) - [Activities](#activities) - [The Context](#the-context) - - [Implementing File Transfers](#implementing-file-transfers) Welcome to the developer manual for termscp. This chapter DOESN'T contain the documentation for termscp modules, which can instead be found on Rust Docs at This chapter describes how termscp works and the guide lines to implement stuff such as file transfers and add features to the user interface. @@ -72,140 +71,3 @@ The context basically holds the following data: - The **Terminal**: the terminal is used to view the tui on the terminal --- - -## Implementing File Transfers - -This chapter describes how to implement a file transfer in termscp. A file transfer is a module which implements the `FileTransfer` trait. The file transfer provides different modules to interact with a remote server, which in addition to the most obvious methods, used to download and upload files, provides also methods to list files, delete files, create directories etc. - -In the following steps I will describe how to implement a new file transfer, in this case I will be implementing the SCP file transfer (which I'm actually implementing the moment I'm writing this lines). - -1. Add the Scp protocol to the `FileTransferProtocol` enum. - - Move to `src/filetransfer/mod.rs` and add `Scp` to the `FileTransferProtocol` enum - - ```rs - /// ## FileTransferProtocol - /// - /// This enum defines the different transfer protocol available in termscp - #[derive(std::cmp::PartialEq, std::fmt::Debug, std::clone::Clone)] - pub enum FileTransferProtocol { - Sftp, - Ftp(bool), // Bool is for secure (true => ftps) - Scp, // <-- here - } - ``` - - In this case Scp is a "plain" enum type. If you need particular options, follow the implementation of `Ftp` which uses a boolean flag for indicating if using FTPS or FTP. - -2. Implement the FileTransfer struct - - Create a file at `src/filetransfer/mytransfer.rs` - - Declare your file transfer struct - - ```rs - /// ## ScpFileTransfer - /// - /// SFTP file transfer structure - pub struct ScpFileTransfer { - session: Option, - sftp: Option, - wrkdir: PathBuf, - } - ``` - -3. Implement the `FileTransfer` trait for it - - You'll have to implement the following methods for your file transfer: - - - connect: connect to remote server - - disconnect: disconnect from remote server - - is_connected: returns whether the file transfer is connected to remote - - pwd: get working directory - - change_dir: change working directory. - - list_dir: get files and directories at a certain path - - mkdir: make a new directory. Return an error in case the directory already exists - - remove: remove a file or a directory. In case the protocol doesn't support recursive removing of directories you MUST implement this through a recursive algorithm - - rename: rename a file or a directory - - stat: returns detail for a certain path - - send_file: opens a stream to a remote path for write purposes (write a remote file) - - recv_file: opens a stream to a remote path for read purposes (write a local file) - - on_sent: finalize a stream when writing a remote file. In case it's not necessary just return `Ok(())` - - on_recv: fianlize a stream when reading a remote file. In case it's not necessary just return `Ok(())` - - In case the protocol you're working on doesn't support any of this features, just return `Err(FileTransferError::new(FileTransferErrorType::UnsupportedFeature))` - -4. Add your transfer to filetransfers: - - Move to `src/filetransfer/mod.rs` and declare your file transfer: - - ```rs - // Transfers - pub mod ftp_transfer; - pub mod scp_transfer; // <-- here - pub mod sftp_transfer; - ``` - -5. Handle FileTransfer in `FileTransferActivity::new` - - Move to `src/ui/activities/filetransfer_activity/mod.rs` and add the new protocol to the client match - - ```rs - client: match protocol { - FileTransferProtocol::Sftp => Box::new(SftpFileTransfer::new()), - FileTransferProtocol::Ftp(ftps) => Box::new(FtpFileTransfer::new(ftps)), - FileTransferProtocol::Scp => Box::new(ScpFileTransfer::new()), // <--- here - }, - ``` - -6. Handle right/left input events in `AuthActivity`: - - Move to `src/ui/activities/auth_activity.rs` and handle the new protocol in `handle_input_event_mode_text` for `KeyCode::Left` and `KeyCode::Right`. - Consider that the order they "rotate" must match the way they will be drawned in the interface. - For newer protocols, please put them always at the end of the list. In this list I won't, because Scp is more important than Ftp imo. - - ```rs - KeyCode::Left => { - // If current field is Protocol handle event... (move element left) - if self.selected_field == InputField::Protocol { - self.protocol = match self.protocol { - FileTransferProtocol::Sftp => FileTransferProtocol::Ftp(true), // End of list (wrap) - FileTransferProtocol::Scp => FileTransferProtocol::Sftp, - FileTransferProtocol::Ftp(ftps) => match ftps { - false => FileTransferProtocol::Scp, - true => FileTransferProtocol::Ftp(false), - } - }; - } - } - KeyCode::Right => { - // If current field is Protocol handle event... ( move element right ) - if self.selected_field == InputField::Protocol { - self.protocol = match self.protocol { - FileTransferProtocol::Sftp => FileTransferProtocol::Scp, - FileTransferProtocol::Scp => FileTransferProtocol::Ftp(false), - FileTransferProtocol::Ftp(ftps) => match ftps { - false => FileTransferProtocol::Ftp(true), - true => FileTransferProtocol::Sftp, // End of list (wrap) - } - }; - } - } - ``` - -7. Add your new file transfer to the protocol input field - - Move to `AuthActivity::draw_protocol_select` method. - Here add your new protocol to the `Spans` vector and to the match case, which chooses which element to highlight. - - ```rs - let protocols: Vec = vec![Spans::from("SFTP"), Spans::from("SCP"), Spans::from("FTP"), Spans::from("FTPS")]; - let index: usize = match self.protocol { - FileTransferProtocol::Sftp => 0, - FileTransferProtocol::Scp => 1, - FileTransferProtocol::Ftp(ftps) => match ftps { - false => 2, - true => 3, - } - }; - ```