mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Compare commits
40 Commits
v0.16.1
...
4bebec369f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bebec369f | ||
|
|
05c8613279 | ||
|
|
205d2813ad | ||
|
|
86660a0cc9 | ||
|
|
3c79e812eb | ||
|
|
0287e7706a | ||
|
|
67a14c2725 | ||
|
|
df03c5c1bf | ||
|
|
3ce3ffee3d | ||
|
|
c0b32a1847 | ||
|
|
81ae0035c3 | ||
|
|
783da22ca2 | ||
|
|
8715c2b6f9 | ||
|
|
98a748dccc | ||
|
|
bef031a414 | ||
|
|
ce0e953182 | ||
|
|
9a5caf75c3 | ||
|
|
446f4a3a32 | ||
|
|
da75912d26 | ||
|
|
4ed23c2a18 | ||
|
|
23ae334bef | ||
|
|
ec75ae1486 | ||
|
|
368570592f | ||
|
|
806793421e | ||
|
|
1f377b242d | ||
|
|
a4906b129a | ||
|
|
5c6e8925ad | ||
|
|
a18eff689d | ||
|
|
274742d6d9 | ||
|
|
cdebcbd4dc | ||
|
|
cdf303a847 | ||
|
|
dd35fe825c | ||
|
|
5c4a971aca | ||
|
|
7522b4d0ff | ||
|
|
b0f314837e | ||
|
|
8a9ba7745a | ||
|
|
b7d75a2749 | ||
|
|
fe0d9b0aa6 | ||
|
|
7dba691ccc | ||
|
|
099e2154ba |
47
.github/workflows/build-artifacts.yml
vendored
47
.github/workflows/build-artifacts.yml
vendored
@@ -3,6 +3,9 @@ name: "Build artifacts"
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
TERMSCP_VERSION: "0.19.0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-binaries:
|
build-binaries:
|
||||||
name: Build - ${{ matrix.platform.release_for }}
|
name: Build - ${{ matrix.platform.release_for }}
|
||||||
@@ -26,17 +29,55 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
targets: ${{ matrix.platform.target }}
|
targets: ${{ matrix.platform.target }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
brew update
|
||||||
|
brew install \
|
||||||
|
bison \
|
||||||
|
cpanminus \
|
||||||
|
cups \
|
||||||
|
flex \
|
||||||
|
gettext \
|
||||||
|
gmp \
|
||||||
|
gnutls \
|
||||||
|
icu4c \
|
||||||
|
jansson \
|
||||||
|
libarchive \
|
||||||
|
libbsd \
|
||||||
|
libunistring \
|
||||||
|
libgit2 \
|
||||||
|
libtirpc \
|
||||||
|
openldap \
|
||||||
|
pkg-config \
|
||||||
|
zlib
|
||||||
|
brew link --force bison
|
||||||
|
brew link --force cups
|
||||||
|
brew link --force flex
|
||||||
|
brew link --force gettext
|
||||||
|
brew link --force gmp
|
||||||
|
brew link --force gnutls
|
||||||
|
brew link --force icu4c
|
||||||
|
brew link --force jansson
|
||||||
|
brew link --force libarchive
|
||||||
|
brew link --force libbsd
|
||||||
|
brew link --force libgit2
|
||||||
|
brew link --force libtirpc
|
||||||
|
brew link --force libunistring
|
||||||
|
brew link --force openldap
|
||||||
|
brew link --force zlib
|
||||||
|
cpanm Parse::Yapp::Driver
|
||||||
- name: Build release
|
- name: Build release
|
||||||
run: cargo build --release --target ${{ matrix.platform.target }}
|
run: cargo build --release --features smb-vendored --target ${{ matrix.platform.target }}
|
||||||
- name: Prepare artifact files
|
- name: Prepare artifact files
|
||||||
run: |
|
run: |
|
||||||
mkdir -p .artifact
|
mkdir -p .artifact
|
||||||
mv target/${{ matrix.platform.target }}/release/termscp .artifact/termscp
|
mv target/${{ matrix.platform.target }}/release/termscp .artifact/termscp
|
||||||
|
tar -czf .artifact/termscp-v${{ env.TERMSCP_VERSION }}-${{ matrix.platform.target }}.tar.gz -C .artifact termscp
|
||||||
ls -l .artifact/
|
ls -l .artifact/
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
name: ${{ matrix.platform.release_for }}
|
name: termscp-${{ matrix.platform.target }}
|
||||||
path: .artifact/termscp
|
path: .artifact/termscp-v${{ env.TERMSCP_VERSION }}-${{ matrix.platform.target }}.tar.gz
|
||||||
|
|||||||
7
.github/workflows/macos.yml
vendored
7
.github/workflows/macos.yml
vendored
@@ -22,6 +22,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
brew update
|
||||||
|
brew install \
|
||||||
|
pkg-config \
|
||||||
|
samba
|
||||||
|
brew link --force samba
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo build
|
run: cargo build
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|||||||
1
.github/workflows/stale.yml
vendored
1
.github/workflows/stale.yml
vendored
@@ -21,3 +21,4 @@ jobs:
|
|||||||
days-before-pr-close: -1
|
days-before-pr-close: -1
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
exempt-issue-labels: "backlog"
|
exempt-issue-labels: "backlog"
|
||||||
|
exempt-all-milestones: true
|
||||||
|
|||||||
6
.github/workflows/website.yml
vendored
6
.github/workflows/website.yml
vendored
@@ -33,11 +33,11 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
uses: actions/configure-pages@v2
|
uses: actions/configure-pages@v5
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v1
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: "./site/"
|
path: "./site/"
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v1
|
uses: actions/deploy-pages@v4
|
||||||
|
|||||||
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
@@ -15,7 +15,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-2019
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
56
CHANGELOG.md
56
CHANGELOG.md
@@ -1,6 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
- [Changelog](#changelog)
|
- [Changelog](#changelog)
|
||||||
|
- [0.19.0](#0190)
|
||||||
|
- [0.18.0](#0180)
|
||||||
|
- [0.17.0](#0170)
|
||||||
- [0.16.1](#0161)
|
- [0.16.1](#0161)
|
||||||
- [0.16.0](#0160)
|
- [0.16.0](#0160)
|
||||||
- [0.15.0](#0150)
|
- [0.15.0](#0150)
|
||||||
@@ -39,6 +42,59 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.19.0
|
||||||
|
|
||||||
|
Released on 20/09/2025
|
||||||
|
|
||||||
|
- [Issue 356](https://github.com/veeso/termscp/issues/356): Fixed SSH auth issue not trying with the password if any RSA key was found.
|
||||||
|
- [Issue 334](https://github.com/veeso/termscp/issues/334): SMB support for MacOS with vendored build of libsmbclient.
|
||||||
|
- [Issue 337](https://github.com/veeso/termscp/issues/337): Migrated to libssh.org on Linux and MacOS for better ssh agent support.
|
||||||
|
- [Issue 361](https://github.com/veeso/termscp/issues/361): Report a message while calculating total size of files to transfer.
|
||||||
|
- [Issue 354](https://github.com/veeso/termscp/issues/354):
|
||||||
|
- Removed error popup message if failed to check for updates.
|
||||||
|
- Prevent long timeouts when checking for updates if the network is down or the DNS is not working.
|
||||||
|
|
||||||
|
## 0.18.0
|
||||||
|
|
||||||
|
Released on 10/06/2025
|
||||||
|
|
||||||
|
- 🐚 An **Embedded shell for termscp**:
|
||||||
|
- [Issue 340](https://github.com/veeso/termscp/issues/340): Replaced the `Exec` popup with a **fully functional terminal emulator** embedded thanks to [A-Kenji's tui-term](https://github.com/a-kenji/tui-term).
|
||||||
|
- Command History
|
||||||
|
- Support for `cd` and `exit` commands as well.
|
||||||
|
- Exit just closes the terminal emulator.
|
||||||
|
- [Issue 345](https://github.com/veeso/termscp/issues/345): Default keys are used from `~/.ssh` directory if no keys are resolved for the host.
|
||||||
|
- **Updated dependencies** and updated the Rust edition to `2024`
|
||||||
|
|
||||||
|
## 0.17.0
|
||||||
|
|
||||||
|
Released on 24/03/2025
|
||||||
|
|
||||||
|
- **Queuing transfers**:
|
||||||
|
- the logic of selecting files has been extended!
|
||||||
|
- From now on selecting file will put the files into a **transfer queue**, which is shown on the bottom panel.
|
||||||
|
- When a file is selected the file is added to the queue with a destination path, which is the **current other explorer path at the moment of selection.**
|
||||||
|
- It is possible to navigate to the transfer queue by using `P` and pressing `ENTER` or `DELETE` on a file will remove it from the transfer queue.
|
||||||
|
- Other commands will work as well on the transfer queue, like `COPY`, `MOVE`, `DELETE`, `RENAME`.
|
||||||
|
- [issue 308](https://github.com/veeso/termscp/issues/308): added `--wno-keyring` flag to disable keyring
|
||||||
|
- [issue 316](https://github.com/veeso/termscp/issues/316): Local directory path is not switching to what's specified in the bookmark. Now the local directory path is correctly set following this hierarchy:
|
||||||
|
1. Local directory path specified for the host bridge
|
||||||
|
2. Local directory path specified in the bookmark
|
||||||
|
3. Working directory
|
||||||
|
- [issue 317](https://github.com/veeso/termscp/issues/317): the return value of `--version` should be `0`
|
||||||
|
- [issue 319](https://github.com/veeso/termscp/issues/319): fixed a crash when the local directory specified in the auth form does not exist
|
||||||
|
- [issue 327](https://github.com/veeso/termscp/issues/327): fixed a panic when trying to go up from local directory on localhost in the auth form
|
||||||
|
- [issue 330](https://github.com/veeso/termscp/issues/330): add suppaftp/pavao/kube to allowed logs
|
||||||
|
- Dependencies:
|
||||||
|
- `argh` to `0.1.13`
|
||||||
|
- `bytesize` to `2`
|
||||||
|
- `dirs` to `6`
|
||||||
|
- `magic-crypt` to `4`
|
||||||
|
- `notify` to `8`
|
||||||
|
- `ssh2-config` to `0.4`
|
||||||
|
- `remotefs-ssh` to `0.6`
|
||||||
|
- `rust` edition to `2024`
|
||||||
|
|
||||||
## 0.16.1
|
## 0.16.1
|
||||||
|
|
||||||
Released on 12/11/2024
|
Released on 12/11/2024
|
||||||
|
|||||||
@@ -2,75 +2,131 @@
|
|||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
contributors and maintainers pledge to making participation in our project and
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
level of experience, education, socio-economic status, nationality, personal
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
appearance, race, religion, or sexual identity and orientation.
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
## Our Standards
|
## Our Standards
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
Examples of behavior that contributes to a positive environment for our
|
||||||
include:
|
community include:
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
* Demonstrating empathy and kindness toward other people
|
||||||
* Being respectful of differing viewpoints and experiences
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
* Gracefully accepting constructive criticism
|
* Giving and gracefully accepting constructive feedback
|
||||||
* Focusing on what is best for the community
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
* Showing empathy towards other community members
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
advances
|
any kind
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
* Public or private harassment
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or electronic
|
* Publishing others' private information, such as a physical or email address,
|
||||||
address, without explicit permission
|
without their explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
professional setting
|
professional setting
|
||||||
|
|
||||||
## Our Responsibilities
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
response to any instances of unacceptable behavior.
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
decisions when appropriate.
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
when an individual is representing the project or its community. Examples of
|
an individual is officially representing the community in public spaces.
|
||||||
representing a project or community include using an official project e-mail
|
Examples of representing our community include using an official email address,
|
||||||
address, posting via an official social media account, or acting as an appointed
|
posting via an official social media account, or acting as an appointed
|
||||||
representative at an online or offline event. Representation of a project may be
|
representative at an online or offline event.
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported by contacting the project team at christian.visintin1997@gmail.com. All
|
reported to the community leaders responsible for enforcement at
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
[INSERT CONTACT METHOD].
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
reporter of any incident.
|
||||||
members of the project's leadership.
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
For answers to common questions about this code of conduct, see
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
<https://www.contributor-covenant.org/faq>
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
Before contributing to this repository, please first discuss the change you wish to make via issue of this repository before making a change.
|
Before contributing to this repository, please first discuss the change you wish to make via issue of this repository before making a change.
|
||||||
Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
|
Please note we have a [code of conduct](CODE_OF_CONDUCT.md). Please follow it in all your interactions with the project.
|
||||||
|
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [Project mission](#project-mission)
|
- [Project mission](#project-mission)
|
||||||
@@ -20,9 +20,13 @@ Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in
|
|||||||
|
|
||||||
## Project mission
|
## Project mission
|
||||||
|
|
||||||
termscp was born because, as a terminal lover and Linux user, I wanted something like WinSCP on Linux and on terminal. I my previous job I used SFTP/SCP pratically everyday and that made me to desire an application like termscp so much, that eventually I started to work on it in the spare time. I saw there was a very cool library to create terminal user interface (`tui-rs`), so I started to code it. I wrote termscp as an experiment, I designed kinda nothing at the time. I just said
|
termscp was born because, as a terminal lover and Linux user, I wanted something like WinSCP on Linux and on terminal. At my previous job, I used SFTP/SCP practically everyday and that made me desire an application like termscp so much that eventually I started to work on it in my spare time.
|
||||||
|
|
||||||
> Ok, there must be a `FileTransfer` trait somehow, I'll have more views, so I'll use something like Android activities, and there must be a module to interact with the local host".
|
I saw there was a very cool library to create terminal user interfaces (`tui-rs`, now `ratatui`), so I started to code it.
|
||||||
|
|
||||||
|
I wrote termscp as an experiment. I didn't design anything at the time. I just said,
|
||||||
|
|
||||||
|
> "Ok, there must be a FileTransfer trait somehow. I'll have more views, so I'll use something like Android activities, and there must be a module to interact with the local host."
|
||||||
|
|
||||||
And so in december 2020 I had the first version of termscp running and it worked, but was very simple, raw and minimal.
|
And so in december 2020 I had the first version of termscp running and it worked, but was very simple, raw and minimal.
|
||||||
A lot of things have changed since them, both the features the project provides and my personal view of this project.
|
A lot of things have changed since them, both the features the project provides and my personal view of this project.
|
||||||
|
|||||||
3598
Cargo.lock
generated
3598
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
84
Cargo.toml
84
Cargo.toml
@@ -2,7 +2,7 @@
|
|||||||
authors = ["Christian Visintin <christian.visintin@veeso.dev>"]
|
authors = ["Christian Visintin <christian.visintin@veeso.dev>"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
description = "termscp is a feature rich terminal file transfer and explorer with support for SCP/SFTP/FTP/Kube/S3/WebDAV"
|
description = "termscp is a feature rich terminal file transfer and explorer with support for SCP/SFTP/FTP/Kube/S3/WebDAV"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
homepage = "https://termscp.veeso.dev"
|
homepage = "https://termscp.veeso.dev"
|
||||||
include = ["src/**/*", "build.rs", "LICENSE", "README.md", "CHANGELOG.md"]
|
include = ["src/**/*", "build.rs", "LICENSE", "README.md", "CHANGELOG.md"]
|
||||||
keywords = ["terminal", "ftp", "scp", "sftp", "tui"]
|
keywords = ["terminal", "ftp", "scp", "sftp", "tui"]
|
||||||
@@ -10,7 +10,8 @@ license = "MIT"
|
|||||||
name = "termscp"
|
name = "termscp"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/veeso/termscp"
|
repository = "https://github.com/veeso/termscp"
|
||||||
version = "0.16.1"
|
version = "0.19.0"
|
||||||
|
rust-version = "1.87.0"
|
||||||
|
|
||||||
[package.metadata.rpm]
|
[package.metadata.rpm]
|
||||||
package = "termscp"
|
package = "termscp"
|
||||||
@@ -23,7 +24,7 @@ termscp = { path = "/usr/bin/termscp" }
|
|||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
maintainer = "Christian Visintin <christian.visintin@veeso.dev>"
|
maintainer = "Christian Visintin <christian.visintin@veeso.dev>"
|
||||||
copyright = "2022, Christian Visintin <christian.visintin@veeso.dev>"
|
copyright = "2025, Christian Visintin <christian.visintin@veeso.dev>"
|
||||||
extended-description-file = "docs/misc/README.deb.txt"
|
extended-description-file = "docs/misc/README.deb.txt"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
@@ -33,37 +34,36 @@ path = "src/main.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
argh = "^0.1"
|
argh = "^0.1"
|
||||||
bitflags = "^2"
|
bitflags = "^2"
|
||||||
bytesize = "^1"
|
bytesize = "^2"
|
||||||
chrono = "^0.4"
|
chrono = "^0.4"
|
||||||
content_inspector = "^0.2"
|
content_inspector = "^0.2"
|
||||||
dirs = "^5.0"
|
dirs = "^6"
|
||||||
edit = "^0.1"
|
edit = "^0.1"
|
||||||
filetime = "^0.2"
|
filetime = "^0.2"
|
||||||
hostname = "^0.4"
|
hostname = "^0.4"
|
||||||
keyring = { version = "^3", optional = true, features = [
|
keyring = { version = "^3", features = [
|
||||||
"apple-native",
|
"apple-native",
|
||||||
"windows-native",
|
"windows-native",
|
||||||
"sync-secret-service",
|
"sync-secret-service",
|
||||||
|
"vendored",
|
||||||
] }
|
] }
|
||||||
lazy-regex = "^3"
|
lazy-regex = "^3"
|
||||||
lazy_static = "^1"
|
lazy_static = "^1"
|
||||||
log = "^0.4"
|
log = "^0.4"
|
||||||
magic-crypt = "^3"
|
magic-crypt = "4"
|
||||||
notify = "6"
|
notify = "8"
|
||||||
notify-rust = { version = "^4.5", default-features = false, features = ["d"] }
|
notify-rust = { version = "^4", default-features = false, features = ["d"] }
|
||||||
nucleo = "0.5"
|
nucleo = "0.5"
|
||||||
open = "^5.0"
|
open = "^5.0"
|
||||||
rand = "^0.8.5"
|
rand = "^0.9"
|
||||||
regex = "^1"
|
regex = "^1"
|
||||||
remotefs = "^0.3"
|
remotefs = "^0.3"
|
||||||
remotefs-aws-s3 = { version = "^0.3", default-features = false, features = [
|
remotefs-aws-s3 = "0.4"
|
||||||
"find",
|
|
||||||
"rustls",
|
|
||||||
] }
|
|
||||||
remotefs-kube = "0.4"
|
remotefs-kube = "0.4"
|
||||||
|
remotefs-smb = { version = "^0.3", optional = true }
|
||||||
remotefs-webdav = "^0.2"
|
remotefs-webdav = "^0.2"
|
||||||
rpassword = "^7"
|
rpassword = "^7"
|
||||||
self_update = { version = "^0.41", default-features = false, features = [
|
self_update = { version = "^0.42", default-features = false, features = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"archive-tar",
|
"archive-tar",
|
||||||
"archive-zip",
|
"archive-zip",
|
||||||
@@ -72,18 +72,34 @@ self_update = { version = "^0.41", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
serde = { version = "^1", features = ["derive"] }
|
serde = { version = "^1", features = ["derive"] }
|
||||||
simplelog = "^0.12"
|
simplelog = "^0.12"
|
||||||
ssh2-config = "^0.2"
|
ssh2-config = "^0.6"
|
||||||
tempfile = "^3"
|
tempfile = "3"
|
||||||
thiserror = "^1"
|
thiserror = "2"
|
||||||
tokio = { version = "=1.38.1", features = ["rt"] }
|
tokio = { version = "1.44", features = ["rt"] }
|
||||||
toml = "^0.8"
|
toml = "^0.9"
|
||||||
tui-realm-stdlib = "2"
|
tui-realm-stdlib = "3"
|
||||||
tuirealm = "2"
|
tuirealm = "3"
|
||||||
|
tui-term = "0.2"
|
||||||
unicode-width = "^0.2"
|
unicode-width = "^0.2"
|
||||||
version-compare = "^0.2"
|
version-compare = "^0.2"
|
||||||
whoami = "^1.5"
|
whoami = "^1.6"
|
||||||
wildmatch = "^2"
|
wildmatch = "^2"
|
||||||
|
|
||||||
|
[target."cfg(target_family = \"unix\")".dependencies]
|
||||||
|
remotefs-ftp = { version = "^0.3", features = [
|
||||||
|
"native-tls-vendored",
|
||||||
|
"native-tls",
|
||||||
|
] }
|
||||||
|
remotefs-ssh = { version = "^0.7", default-features = false, features = [
|
||||||
|
"find",
|
||||||
|
"libssh-vendored",
|
||||||
|
] }
|
||||||
|
uzers = "0.12"
|
||||||
|
|
||||||
|
[target."cfg(target_family = \"windows\")".dependencies]
|
||||||
|
remotefs-ftp = { version = "^0.3", features = ["native-tls"] }
|
||||||
|
remotefs-ssh = { version = "^0.7" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "^1"
|
pretty_assertions = "^1"
|
||||||
serial_test = "^3"
|
serial_test = "^3"
|
||||||
@@ -92,27 +108,13 @@ serial_test = "^3"
|
|||||||
cfg_aliases = "0.2"
|
cfg_aliases = "0.2"
|
||||||
vergen-git2 = { version = "1", features = ["build", "cargo", "rustc", "si"] }
|
vergen-git2 = { version = "1", features = ["build", "cargo", "rustc", "si"] }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["smb", "with-keyring"]
|
default = ["smb", "keyring"]
|
||||||
github-actions = []
|
github-actions = []
|
||||||
isolated-tests = []
|
isolated-tests = []
|
||||||
smb = ["remotefs-smb"]
|
keyring = []
|
||||||
with-keyring = ["keyring"]
|
smb = ["dep:remotefs-smb"]
|
||||||
|
smb-vendored = ["remotefs-smb/vendored"]
|
||||||
[target."cfg(not(target_os = \"macos\"))".dependencies]
|
|
||||||
remotefs-smb = { version = "^0.3", optional = true }
|
|
||||||
|
|
||||||
[target."cfg(target_family = \"windows\")"]
|
|
||||||
[target."cfg(target_family = \"windows\")".dependencies]
|
|
||||||
remotefs-ftp = { version = "^0.2", features = ["native-tls"] }
|
|
||||||
remotefs-ssh = "^0.4"
|
|
||||||
|
|
||||||
[target."cfg(target_family = \"unix\")"]
|
|
||||||
[target."cfg(target_family = \"unix\")".dependencies]
|
|
||||||
remotefs-ftp = { version = "^0.2", features = ["vendored", "native-tls"] }
|
|
||||||
remotefs-ssh = { version = "^0.4", features = ["ssh2-vendored"] }
|
|
||||||
uzers = "0.12"
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
incremental = true
|
incremental = true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="/docs/ptbr/README.md"
|
href="/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Developed by <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Developed by <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Current version: 0.16.1 12/11/2024</p>
|
<p align="center">Current version: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
@@ -144,6 +144,7 @@ Termscp is a feature rich terminal file transfer and explorer, with support for
|
|||||||
- 📝 View and edit files with your favourite applications
|
- 📝 View and edit files with your favourite applications
|
||||||
- 💁 SFTP/SCP authentication with SSH keys and username/password
|
- 💁 SFTP/SCP authentication with SSH keys and username/password
|
||||||
- 🐧 Compatible with Windows, Linux, FreeBSD, NetBSD and MacOS
|
- 🐧 Compatible with Windows, Linux, FreeBSD, NetBSD and MacOS
|
||||||
|
- 🐚 Embedded terminal for executing commands on the system.
|
||||||
- 🎨 Make it yours!
|
- 🎨 Make it yours!
|
||||||
- Themes
|
- Themes
|
||||||
- Custom file explorer format
|
- Custom file explorer format
|
||||||
|
|||||||
4
build.rs
4
build.rs
@@ -10,8 +10,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
posix: { target_family = "unix" },
|
posix: { target_family = "unix" },
|
||||||
win: { target_family = "windows" },
|
win: { target_family = "windows" },
|
||||||
// exclusive features
|
// exclusive features
|
||||||
smb: { all(feature = "smb", not( macos )) },
|
smb: { feature = "smb" },
|
||||||
smb_unix: { all(unix, feature = "smb", not(macos)) },
|
smb_unix: { all(unix, feature = "smb") },
|
||||||
smb_windows: { all(windows, feature = "smb") }
|
smb_windows: { all(windows, feature = "smb") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
dist/build/aarch64_debian10/Dockerfile
vendored
28
dist/build/aarch64_debian10/Dockerfile
vendored
@@ -9,9 +9,33 @@ RUN apt update && apt install -y \
|
|||||||
libdbus-1-dev \
|
libdbus-1-dev \
|
||||||
build-essential \
|
build-essential \
|
||||||
libsmbclient-dev \
|
libsmbclient-dev \
|
||||||
libsmbclient \
|
libgit2-dev \
|
||||||
|
build-essential \
|
||||||
|
pkg-config \
|
||||||
|
libbsd-dev \
|
||||||
|
libcap-dev \
|
||||||
|
libcups2-dev \
|
||||||
|
libgnutls28-dev \
|
||||||
|
libicu-dev \
|
||||||
|
libjansson-dev \
|
||||||
|
libkeyutils-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libpam0g-dev \
|
||||||
|
libacl1-dev \
|
||||||
|
libarchive-dev \
|
||||||
|
flex \
|
||||||
|
bison \
|
||||||
|
libntirpc-dev \
|
||||||
|
libtracker-sparql-3.0-dev \
|
||||||
|
libglib2.0-dev \
|
||||||
|
libdbus-1-dev \
|
||||||
|
libsasl2-dev \
|
||||||
|
libunistring-dev \
|
||||||
bash \
|
bash \
|
||||||
curl
|
curl \
|
||||||
|
cpanminus && \
|
||||||
|
cpanm Parse::Yapp::Driver;
|
||||||
|
|
||||||
# Install rust
|
# Install rust
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
|
||||||
|
|||||||
2
dist/build/linux-aarch64.sh
vendored
2
dist/build/linux-aarch64.sh
vendored
@@ -38,7 +38,7 @@ cd -
|
|||||||
mkdir -p ${PKGS_DIR}/deb/
|
mkdir -p ${PKGS_DIR}/deb/
|
||||||
mkdir -p ${PKGS_DIR}/aarch64-unknown-linux-gnu/
|
mkdir -p ${PKGS_DIR}/aarch64-unknown-linux-gnu/
|
||||||
docker run --name "$ARM64_DEB_NAME" -d "$ARM64_DEB_NAME" || docker start "$ARM64_DEB_NAME"
|
docker run --name "$ARM64_DEB_NAME" -d "$ARM64_DEB_NAME" || docker start "$ARM64_DEB_NAME"
|
||||||
docker exec -it "$ARM64_DEB_NAME" bash -c ". \$HOME/.cargo/env && git fetch origin && git checkout origin/$BRANCH && cargo build --release && cargo deb"
|
docker exec -it "$ARM64_DEB_NAME" bash -c ". \$HOME/.cargo/env && git fetch origin && git checkout origin/$BRANCH && cargo build --release --features smb-vendored && cargo deb"
|
||||||
docker cp ${ARM64_DEB_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}-1_arm64.deb ${PKGS_DIR}/deb/termscp_${VERSION}_arm64.deb
|
docker cp ${ARM64_DEB_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}-1_arm64.deb ${PKGS_DIR}/deb/termscp_${VERSION}_arm64.deb
|
||||||
docker cp ${ARM64_DEB_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/aarch64-unknown-linux-gnu/
|
docker cp ${ARM64_DEB_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/aarch64-unknown-linux-gnu/
|
||||||
docker stop "$ARM64_DEB_NAME"
|
docker stop "$ARM64_DEB_NAME"
|
||||||
|
|||||||
4
dist/build/linux-x86_64.sh
vendored
4
dist/build/linux-x86_64.sh
vendored
@@ -30,13 +30,13 @@ PKGS_DIR=$(pwd)/pkgs
|
|||||||
cd -
|
cd -
|
||||||
mkdir -p ${PKGS_DIR}/
|
mkdir -p ${PKGS_DIR}/
|
||||||
# Build x86_64_deb
|
# Build x86_64_deb
|
||||||
cd x86_64_debian10/
|
cd x86_64_debian12/
|
||||||
docker build $CACHE --build-arg branch=${BRANCH} --tag "$X86_64_DEB_NAME" .
|
docker build $CACHE --build-arg branch=${BRANCH} --tag "$X86_64_DEB_NAME" .
|
||||||
cd -
|
cd -
|
||||||
mkdir -p ${PKGS_DIR}/deb/
|
mkdir -p ${PKGS_DIR}/deb/
|
||||||
mkdir -p ${PKGS_DIR}/x86_64-unknown-linux-gnu/
|
mkdir -p ${PKGS_DIR}/x86_64-unknown-linux-gnu/
|
||||||
docker run --name "$X86_64_DEB_NAME" -d "$X86_64_DEB_NAME" || docker start "$X86_64_DEB_NAME"
|
docker run --name "$X86_64_DEB_NAME" -d "$X86_64_DEB_NAME" || docker start "$X86_64_DEB_NAME"
|
||||||
docker exec -it "$X86_64_DEB_NAME" bash -c ". \$HOME/.cargo/env && git fetch origin && git checkout origin/$BRANCH && cargo build --release && cargo deb"
|
docker exec -it "$X86_64_DEB_NAME" bash -c ". \$HOME/.cargo/env && git fetch origin && git checkout origin/$BRANCH && cargo build --release --features smb-vendored && cargo deb"
|
||||||
docker cp ${X86_64_DEB_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}-1_amd64.deb ${PKGS_DIR}/deb/termscp_${VERSION}_amd64.deb
|
docker cp ${X86_64_DEB_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}-1_amd64.deb ${PKGS_DIR}/deb/termscp_${VERSION}_amd64.deb
|
||||||
docker cp ${X86_64_DEB_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/x86_64-unknown-linux-gnu/
|
docker cp ${X86_64_DEB_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/x86_64-unknown-linux-gnu/
|
||||||
docker stop "$X86_64_DEB_NAME"
|
docker stop "$X86_64_DEB_NAME"
|
||||||
|
|||||||
4
dist/build/macos.sh
vendored
4
dist/build/macos.sh
vendored
@@ -81,7 +81,7 @@ fi
|
|||||||
# Build release (x86_64)
|
# Build release (x86_64)
|
||||||
X86_TARGET=""
|
X86_TARGET=""
|
||||||
X86_TARGET_DIR=""
|
X86_TARGET_DIR=""
|
||||||
if [ "$ARCH" = "aarch64" ]; then
|
if [ "$ARCH" = "x86_64" ]; then
|
||||||
X86_TARGET="--target x86_64-apple-darwin"
|
X86_TARGET="--target x86_64-apple-darwin"
|
||||||
X86_TARGET_DIR="target/x86_64-apple-darwin/release/"
|
X86_TARGET_DIR="target/x86_64-apple-darwin/release/"
|
||||||
fi
|
fi
|
||||||
@@ -92,7 +92,7 @@ RET_X86_64=$?
|
|||||||
|
|
||||||
ARM64_TARGET=""
|
ARM64_TARGET=""
|
||||||
ARM64_TARGET_DIR=""
|
ARM64_TARGET_DIR=""
|
||||||
if [ "$ARCH" = "aarch64" ]; then
|
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||||
ARM64_TARGET="--target aarch64-apple-darwin"
|
ARM64_TARGET="--target aarch64-apple-darwin"
|
||||||
ARM64_TARGET_DIR="target/aarch64-apple-darwin/release/"
|
ARM64_TARGET_DIR="target/aarch64-apple-darwin/release/"
|
||||||
fi
|
fi
|
||||||
|
|||||||
27
dist/build/x86_64_debian10/Dockerfile
vendored
27
dist/build/x86_64_debian10/Dockerfile
vendored
@@ -1,27 +0,0 @@
|
|||||||
FROM debian:buster
|
|
||||||
|
|
||||||
WORKDIR /usr/src/
|
|
||||||
# Install dependencies
|
|
||||||
RUN apt update && apt install -y \
|
|
||||||
git \
|
|
||||||
gcc \
|
|
||||||
pkg-config \
|
|
||||||
libdbus-1-dev \
|
|
||||||
build-essential \
|
|
||||||
libsmbclient-dev \
|
|
||||||
libsmbclient \
|
|
||||||
bash \
|
|
||||||
curl
|
|
||||||
|
|
||||||
# Install rust
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
|
|
||||||
chmod +x /tmp/rust.sh && \
|
|
||||||
/tmp/rust.sh -y
|
|
||||||
# Clone repository
|
|
||||||
RUN git clone https://github.com/veeso/termscp.git
|
|
||||||
# Set workdir to termscp
|
|
||||||
WORKDIR /usr/src/termscp/
|
|
||||||
# Install cargo deb
|
|
||||||
RUN . $HOME/.cargo/env && cargo install cargo-deb
|
|
||||||
|
|
||||||
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
|
||||||
54
dist/build/x86_64_debian12/Dockerfile
vendored
Normal file
54
dist/build/x86_64_debian12/Dockerfile
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
FROM debian:bookworm
|
||||||
|
|
||||||
|
WORKDIR /usr/src/
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt update && apt install -y \
|
||||||
|
git \
|
||||||
|
gcc \
|
||||||
|
pkg-config \
|
||||||
|
libdbus-1-dev \
|
||||||
|
build-essential \
|
||||||
|
libsmbclient-dev \
|
||||||
|
libgit2-dev \
|
||||||
|
build-essential \
|
||||||
|
pkg-config \
|
||||||
|
libbsd-dev \
|
||||||
|
libcap-dev \
|
||||||
|
libcups2-dev \
|
||||||
|
libgnutls28-dev \
|
||||||
|
libgnutls30 \
|
||||||
|
libicu-dev \
|
||||||
|
libjansson-dev \
|
||||||
|
libkeyutils-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libpam0g-dev \
|
||||||
|
libacl1-dev \
|
||||||
|
libarchive-dev \
|
||||||
|
libssl-dev \
|
||||||
|
flex \
|
||||||
|
bison \
|
||||||
|
libntirpc-dev \
|
||||||
|
libglib2.0-dev \
|
||||||
|
libdbus-1-dev \
|
||||||
|
libsasl2-dev \
|
||||||
|
libunistring-dev \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
cpanminus && \
|
||||||
|
cpanm Parse::Yapp::Driver;
|
||||||
|
|
||||||
|
# Install rust
|
||||||
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
|
||||||
|
chmod +x /tmp/rust.sh && \
|
||||||
|
/tmp/rust.sh -y && \
|
||||||
|
. $HOME/.cargo/env && \
|
||||||
|
cargo version
|
||||||
|
# Clone repository
|
||||||
|
RUN git clone https://github.com/veeso/termscp.git
|
||||||
|
# Set workdir to termscp
|
||||||
|
WORKDIR /usr/src/termscp/
|
||||||
|
# Install cargo deb
|
||||||
|
RUN . $HOME/.cargo/env && cargo install cargo-deb
|
||||||
|
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Entwickelt von <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Entwickelt von <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Aktuelle Version: 0.16.1 12/11/2024</p>
|
<p align="center">Aktuelle Version: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
- [Dateiexplorer 📂](#dateiexplorer-)
|
- [Dateiexplorer 📂](#dateiexplorer-)
|
||||||
- [Tastenkombinationen ⌨](#tastenkombinationen-)
|
- [Tastenkombinationen ⌨](#tastenkombinationen-)
|
||||||
- [Mit mehreren Dateien arbeiten 🥷](#mit-mehreren-dateien-arbeiten-)
|
- [Mit mehreren Dateien arbeiten 🥷](#mit-mehreren-dateien-arbeiten-)
|
||||||
|
- [Beispiel](#beispiel)
|
||||||
- [Synchronisiertes Durchsuchen ⏲️](#synchronisiertes-durchsuchen-️)
|
- [Synchronisiertes Durchsuchen ⏲️](#synchronisiertes-durchsuchen-️)
|
||||||
- [Öffnen und Öffnen mit 🚪](#öffnen-und-öffnen-mit-)
|
- [Öffnen und Öffnen mit 🚪](#öffnen-und-öffnen-mit-)
|
||||||
- [Lesezeichen ⭐](#lesezeichen-)
|
- [Lesezeichen ⭐](#lesezeichen-)
|
||||||
@@ -297,19 +298,34 @@ Diese Panels sind im Wesentlichen 3 (ja, tatsächlich drei):
|
|||||||
| <CTRL+C> | Dateiübertragungsvorgang abbrechen | |
|
| <CTRL+C> | Dateiübertragungsvorgang abbrechen | |
|
||||||
| <CTRL+T> | Alle synchronisierten Pfade anzeigen | Track |
|
| <CTRL+T> | Alle synchronisierten Pfade anzeigen | Track |
|
||||||
|
|
||||||
### Mit mehreren Dateien arbeiten 🥷
|
### Mit mehreren Dateien arbeiten 🥷
|
||||||
|
|
||||||
Sie können mit mehreren Dateien arbeiten, indem Sie `<M>` drücken, um die aktuelle Datei auszuwählen, oder `<CTRL+A>`, um alle Dateien im Arbeitsverzeichnis auszuwählen.
|
Du kannst mit mehreren Dateien gleichzeitig arbeiten, mit diesen einfachen Tastenkombinationen:
|
||||||
Sobald eine Datei zur Auswahl markiert ist, wird sie mit einem `*` auf der linken Seite angezeigt.
|
|
||||||
Bei der Arbeit mit der Auswahl werden nur die ausgewählten Dateien für Aktionen verarbeitet, während der aktuell hervorgehobene Eintrag ignoriert wird.
|
|
||||||
Es ist auch möglich, mit mehreren Dateien im Suchergebnis-Panel zu arbeiten.
|
|
||||||
Alle Aktionen sind verfügbar, wenn Sie mit mehreren Dateien arbeiten, aber beachten Sie, dass einige Aktionen etwas anders funktionieren. Schauen wir uns das genauer an:
|
|
||||||
|
|
||||||
- _Kopieren_: Wann immer Sie eine Datei kopieren, werden Sie aufgefordert, den Zielnamen einzugeben. Bei der Arbeit mit mehreren Dateien bezieht sich dieser Name auf das Zielverzeichnis, in dem alle diese Dateien kopiert werden.
|
- `<M>`: Datei zur Auswahl markieren
|
||||||
|
- `<CTRL+A>`: alle Dateien im aktuellen Verzeichnis auswählenas
|
||||||
|
- `<ALT+A>`: Auswahl aller Dateien aufheben
|
||||||
|
|
||||||
- _Umbenennen_: Dasselbe wie Kopieren, aber die Dateien werden dorthin verschoben.
|
Markierte Dateien werden **mit hervorgehobenem Hintergrund** angezeigt.
|
||||||
|
Bei Auswahlaktionen werden nur die markierten Dateien verarbeitet, das aktuell hervorgehobene Element wird ignoriert.
|
||||||
|
|
||||||
- _Speichern unter_: Dasselbe wie Kopieren, aber die Dateien werden dorthin geschrieben.
|
Auch im Suchergebnis-Panel ist die Mehrfachauswahl möglich.
|
||||||
|
|
||||||
|
Alle Aktionen sind bei mehreren Dateien verfügbar, einige funktionieren jedoch leicht anders:
|
||||||
|
|
||||||
|
- *Kopieren*: du wirst nach einem Zielnamen gefragt. Bei mehreren Dateien ist das das Zielverzeichnis.
|
||||||
|
- *Umbenennen*: wie Kopieren, aber verschiebt die Dateien.
|
||||||
|
- *Speichern unter*: wie Kopieren, aber schreibt die Dateien dorthin.
|
||||||
|
|
||||||
|
Wenn du eine Datei in einem Verzeichnis (z. B. `/home`) auswählst und dann das Verzeichnis wechselst, bleibt sie ausgewählt und erscheint in der **Transfer-Warteschlange** im unteren Panel.
|
||||||
|
Beim Markieren einer Datei wird das aktuelle *Remote*-Verzeichnis gespeichert; bei einem Transfer wird sie in dieses Verzeichnis übertragen.
|
||||||
|
|
||||||
|
#### Beispiel
|
||||||
|
|
||||||
|
Wenn wir `/home/a.txt` lokal auswählen und im Remote-Panel in `/tmp` sind, dann zu `/var` wechseln, `/var/b.txt` auswählen und im Remote-Panel in `/home` sind, ergibt der Transfer:
|
||||||
|
|
||||||
|
- `/home/a.txt` → `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` → `/home/b.txt`
|
||||||
|
|
||||||
### Synchronisiertes Durchsuchen ⏲️
|
### Synchronisiertes Durchsuchen ⏲️
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Desarrollado por <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Desarrollado por <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Versión actual: 0.16.1 12/11/2024</p>
|
<p align="center">Versión actual: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
- [Credenciales de S3 🦊](#credenciales-de-s3-)
|
- [Credenciales de S3 🦊](#credenciales-de-s3-)
|
||||||
- [Explorador de archivos 📂](#explorador-de-archivos-)
|
- [Explorador de archivos 📂](#explorador-de-archivos-)
|
||||||
- [Keybindings ⌨](#keybindings-)
|
- [Keybindings ⌨](#keybindings-)
|
||||||
- [Trabaja en varios archivos 🥷](#trabaja-en-varios-archivos-)
|
- [Trabajar con múltiples archivos 🥷](#trabajar-con-múltiples-archivos-)
|
||||||
|
- [Ejemplo](#ejemplo)
|
||||||
- [Navegación sincronizada ⏲️](#navegación-sincronizada-️)
|
- [Navegación sincronizada ⏲️](#navegación-sincronizada-️)
|
||||||
- [Abierta y abierta con 🚪](#abierta-y-abierta-con-)
|
- [Abierta y abierta con 🚪](#abierta-y-abierta-con-)
|
||||||
- [Marcadores ⭐](#marcadores-)
|
- [Marcadores ⭐](#marcadores-)
|
||||||
@@ -259,17 +260,34 @@ Para cambiar de panel, debe escribir `<LEFT>` para mover el panel del explorador
|
|||||||
| `<CTRL+C>` | Abortar el proceso de transferencia de archivos | |
|
| `<CTRL+C>` | Abortar el proceso de transferencia de archivos | |
|
||||||
| `<CTRL+T>` | Mostrar todas las rutas sincronizadas | Track |
|
| `<CTRL+T>` | Mostrar todas las rutas sincronizadas | Track |
|
||||||
|
|
||||||
### Trabaja en varios archivos 🥷
|
### Trabajar con múltiples archivos 🥷
|
||||||
|
|
||||||
Puede optar por trabajar en varios archivos, seleccionándolos presionando `<M>`, para seleccionar el archivo actual, o presionando `<CTRL + A>`, que seleccionará todos los archivos en el directorio de trabajo.
|
Puedes optar por trabajar con varios archivos, usando estos controles:
|
||||||
Una vez que un archivo está marcado para su selección, se mostrará con un `*` a la izquierda.
|
|
||||||
Al trabajar en la selección, solo se procesará el archivo seleccionado para las acciones, mientras que el elemento resaltado actual se ignorará.
|
|
||||||
También es posible trabajar en varios archivos desde el panel de resultados de búsqueda.
|
|
||||||
Todas las acciones están disponibles cuando se trabaja con varios archivos, pero tenga en cuenta que algunas acciones funcionan de forma ligeramente diferente. Vamos a sumergirnos en:
|
|
||||||
|
|
||||||
- *Copy*: cada vez que copie un archivo, se le pedirá que inserte el nombre de destino. Cuando se trabaja con varios archivos, este nombre se refiere al directorio de destino donde se copiarán todos estos archivos.
|
- `<M>`: marcar un archivo para selección
|
||||||
- *Rename*: igual que copiar, pero moverá archivos allí.
|
- `<CTRL+A>`: seleccionar todos los archivos del directorio actual
|
||||||
- *Save as*: igual que copiar, pero los escribirá allí.
|
- `<ALT+A>`: deseleccionar todos los archivos
|
||||||
|
|
||||||
|
Una vez marcado, el archivo será **mostrado con un fondo resaltado** .
|
||||||
|
Cuando se trabaja con una selección, solo los archivos seleccionados serán procesados; el archivo resaltado actual será ignorado.
|
||||||
|
|
||||||
|
También se puede trabajar con múltiples archivos desde el panel de resultados de búsqueda.
|
||||||
|
|
||||||
|
Todas las acciones están disponibles con archivos múltiples, pero algunas funcionan de forma algo distinta. Veamos:
|
||||||
|
|
||||||
|
- *Copiar*: al copiar, se pedirá el nombre de destino. Para varios archivos, es el directorio donde se copiarán.
|
||||||
|
- *Renombrar*: igual que copiar, pero mueve los archivos.
|
||||||
|
- *Guardar como*: igual que copiar, pero escribe los archivos allí.
|
||||||
|
|
||||||
|
Si seleccionas un archivo en un directorio (ej. `/home`) y cambias de directorio, seguirá seleccionado y se mostrará en la **cola de transferencia** en el panel inferior.
|
||||||
|
Cuando se selecciona un archivo, se asocia la carpeta *remota* actual con él; si se transfiere, será a esa carpeta.
|
||||||
|
|
||||||
|
#### Ejemplo
|
||||||
|
|
||||||
|
Si seleccionamos `/home/a.txt` localmente y estamos en `/tmp` en remoto, luego cambiamos a `/var`, seleccionamos `/var/b.txt` y estamos en `/home` en el panel remoto, el resultado de transferir será:
|
||||||
|
|
||||||
|
- `/home/a.txt` transferido a `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` transferido a `/home/b.txt`
|
||||||
|
|
||||||
### Navegación sincronizada ⏲️
|
### Navegación sincronizada ⏲️
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Développé par <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Développé par <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Version actuelle: 0.16.1 12/11/2024</p>
|
<p align="center">Version actuelle: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- [Explorateur de fichiers 📂](#explorateur-de-fichiers-)
|
- [Explorateur de fichiers 📂](#explorateur-de-fichiers-)
|
||||||
- [Raccourcis clavier ⌨](#raccourcis-clavier-)
|
- [Raccourcis clavier ⌨](#raccourcis-clavier-)
|
||||||
- [Travailler sur plusieurs fichiers 🥷](#travailler-sur-plusieurs-fichiers-)
|
- [Travailler sur plusieurs fichiers 🥷](#travailler-sur-plusieurs-fichiers-)
|
||||||
|
- [Exemple](#exemple)
|
||||||
- [Navigation synchronisée ⏲️](#navigation-synchronisée-️)
|
- [Navigation synchronisée ⏲️](#navigation-synchronisée-️)
|
||||||
- [Ouvrir et ouvrir avec 🚪](#ouvrir-et-ouvrir-avec-)
|
- [Ouvrir et ouvrir avec 🚪](#ouvrir-et-ouvrir-avec-)
|
||||||
- [Signets ⭐](#signets-)
|
- [Signets ⭐](#signets-)
|
||||||
@@ -258,17 +259,34 @@ Pour changer de panneau, vous devez taper `<LEFT>` pour déplacer le panneau de
|
|||||||
| `<CTRL+C>` | Abandonner le processus de transfert de fichiers | |
|
| `<CTRL+C>` | Abandonner le processus de transfert de fichiers | |
|
||||||
| `<CTRL+T>` | Afficher tous les chemins synchronisés | Track |
|
| `<CTRL+T>` | Afficher tous les chemins synchronisés | Track |
|
||||||
|
|
||||||
### Travailler sur plusieurs fichiers 🥷
|
### Travailler sur plusieurs fichiers 🥷
|
||||||
|
|
||||||
Vous pouvez choisir de travailler sur plusieurs fichiers, en les sélectionnant en appuyant sur `<M>`, afin de sélectionner le fichier actuel, ou en appuyant sur `<CTRL+A>`, ce qui sélectionnera tous les fichiers dans le répertoire de travail.
|
Vous pouvez choisir de travailler sur plusieurs fichiers avec ces simples commandes :
|
||||||
Une fois qu'un fichier est marqué pour la sélection, il sera affiché avec un `*` sur la gauche.
|
|
||||||
Lorsque vous travaillez sur la sélection, seul le fichier sélectionné sera traité pour les actions, tandis que l'élément en surbrillance actuel sera ignoré.
|
|
||||||
Il est également possible de travailler sur plusieurs fichiers dans le panneau des résultats de recherche.
|
|
||||||
Toutes les actions sont disponibles lorsque vous travaillez avec plusieurs fichiers, mais sachez que certaines actions fonctionnent de manière légèrement différente. Plongeons dans:
|
|
||||||
|
|
||||||
- *Copy*: chaque fois que vous copiez un fichier, vous serez invité à insérer le nom de destination. Lorsque vous travaillez avec plusieurs fichiers, ce nom fait référence au répertoire de destination où tous ces fichiers seront copiés.
|
- `<M>` : marquer un fichier à sélectionner
|
||||||
- *Rename*: identique à la copie, mais y déplacera les fichiers.
|
- `<CTRL+A>` : sélectionner tous les fichiers du répertoire actuel
|
||||||
- *Save as*: identique à la copie, mais les y écrira.
|
- `<ALT+A>` : désélectionner tous les fichiers
|
||||||
|
|
||||||
|
Une fois sélectionné, un fichier sera **affiché avec un fond en surbrillance** .
|
||||||
|
Lorsqu’on travaille avec des sélections, seules les fichiers sélectionnés seront affectés par les actions, tandis que l'élément actuellement surligné sera ignoré.
|
||||||
|
|
||||||
|
Il est également possible de travailler avec plusieurs fichiers depuis le panneau des résultats de recherche.
|
||||||
|
|
||||||
|
Toutes les actions sont disponibles avec des fichiers multiples, mais certaines peuvent se comporter différemment. Détails :
|
||||||
|
|
||||||
|
- *Copier* : lors de la copie, il vous sera demandé un nom de destination. Avec plusieurs fichiers, cela correspond au dossier de destination.
|
||||||
|
- *Renommer* : identique à la copie, mais déplace les fichiers.
|
||||||
|
- *Enregistrer sous* : identique à la copie, mais enregistre les fichiers à cet emplacement.
|
||||||
|
|
||||||
|
Si vous sélectionnez un fichier dans un dossier (ex. `/home`) puis changez de répertoire, il restera sélectionné et sera affiché dans la **file d’attente de transfert** en bas.
|
||||||
|
Lorsqu’un fichier est sélectionné, le dossier *distant* courant lui est associé ; en cas de transfert, il sera envoyé vers ce dossier.
|
||||||
|
|
||||||
|
#### Exemple
|
||||||
|
|
||||||
|
Si on sélectionne `/home/a.txt` localement et que le panneau distant est sur `/tmp`, puis on passe à `/var`, on sélectionne `/var/b.txt` et que le panneau distant est sur `/home`, le transfert donnera :
|
||||||
|
|
||||||
|
- `/home/a.txt` transféré vers `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` transféré vers `/home/b.txt`
|
||||||
|
|
||||||
### Navigation synchronisée ⏲️
|
### Navigation synchronisée ⏲️
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Sviluppato da <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Sviluppato da <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Versione corrente: 0.16.1 12/11/2024</p>
|
<p align="center">Versione corrente: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
- [Credenziali S3 🦊](#credenziali-s3-)
|
- [Credenziali S3 🦊](#credenziali-s3-)
|
||||||
- [File explorer 📂](#file-explorer-)
|
- [File explorer 📂](#file-explorer-)
|
||||||
- [Abbinamento tasti ⌨](#abbinamento-tasti-)
|
- [Abbinamento tasti ⌨](#abbinamento-tasti-)
|
||||||
- [Lavora su più file 🥷](#lavora-su-più-file-)
|
- [Lavora con più file 🥷](#lavora-con-più-file-)
|
||||||
|
- [Esempio](#esempio)
|
||||||
- [Synchronized browsing ⏲️](#synchronized-browsing-️)
|
- [Synchronized browsing ⏲️](#synchronized-browsing-️)
|
||||||
- [Apri e apri con 🚪](#apri-e-apri-con-)
|
- [Apri e apri con 🚪](#apri-e-apri-con-)
|
||||||
- [Segnalibri ⭐](#segnalibri-)
|
- [Segnalibri ⭐](#segnalibri-)
|
||||||
@@ -254,17 +255,34 @@ Per cambiare pannello ti puoi muovere con le frecce, `<LEFT>` per andare sul pan
|
|||||||
| `<CTRL+C>` | Annulla trasferimento file | |
|
| `<CTRL+C>` | Annulla trasferimento file | |
|
||||||
| `<CTRL+T>` | Visualizza tutti i percorsi sincronizzati | Track |
|
| `<CTRL+T>` | Visualizza tutti i percorsi sincronizzati | Track |
|
||||||
|
|
||||||
### Lavora su più file 🥷
|
### Lavora con più file 🥷
|
||||||
|
|
||||||
Puoi lavorare su una selezione di file, marcandoli come selezionati tramite `<M>`, per selezionare il file corrente o con `<CTRL+A` per selezionarli tutti.
|
Puoi scegliere di lavorare con più file, usando questi semplici comandi:
|
||||||
Una volta che un file è marcato, sarà visualizzato con un `*` prima del nome.
|
|
||||||
Quando lavori con una selezioni, solo i file selezionati saranno presi in considerazione (l'eventuale file evidenziato sarà ignorato).
|
|
||||||
È possibile operare su più file anche nel pannello di ricerca.
|
|
||||||
Tutte le azioni sono disponibili quando si lavora sulle selezioni, ma occhio, che alcune azioni si comporteranno in maniera leggermente differente. Vediamo quali e come:
|
|
||||||
|
|
||||||
- *Copia*: Se copi un file, ti verrà richiesto di inserire il nome delle destinazione, ma quando lavori con la selezione, il nome si riferisce alla directory di destinazione, mentre il nome del file rimarrà inviariato.
|
- `<M>`: marca un file per la selezione
|
||||||
- *Rinomina*: Come il copia, ma li sposterà.
|
- `<CTRL+A>`: seleziona tutti i file nella directory corrente
|
||||||
- *Salva con nome*: Come il copia, ma li trasferirà.
|
- `<ALT+A>`: deseleziona tutti i file
|
||||||
|
|
||||||
|
Una volta che un file è stato selezionato, verrà **evidenziato con uno sfondo colorato** .
|
||||||
|
Quando lavori su una selezione, solo i file selezionati verranno processati per le azioni, mentre l'elemento attualmente evidenziato sarà ignorato.
|
||||||
|
|
||||||
|
È possibile lavorare con più file anche dal pannello dei risultati di ricerca.
|
||||||
|
|
||||||
|
Tutte le azioni sono disponibili anche quando si lavora con più file, ma alcune funzionano in modo leggermente diverso. Ecco i dettagli:
|
||||||
|
|
||||||
|
- *Copia*: quando copi un file, ti verrà chiesto di inserire il nome di destinazione. Con più file selezionati, questo nome rappresenta la cartella di destinazione dove verranno copiati.
|
||||||
|
- *Rinomina*: come la copia, ma i file verranno spostati lì.
|
||||||
|
- *Salva come*: come la copia, ma i file verranno salvati lì.
|
||||||
|
|
||||||
|
Se selezioni un file in una directory (es. `/home`) e poi cambi directory, il file rimarrà selezionato e sarà visibile nella **coda di trasferimento** nel pannello inferiore.
|
||||||
|
Quando un file viene selezionato, la directory *remota* corrente viene associata all’elemento; quindi, se il file viene trasferito, verrà trasferito nella directory associata.
|
||||||
|
|
||||||
|
#### Esempio
|
||||||
|
|
||||||
|
Se selezioniamo un file locale `/home/a.txt`, siamo su `/tmp` nel pannello remoto, poi ci spostiamo su `/var`, selezioniamo `/var/b.txt`, e sul pannello remoto siamo su `/home`, eseguendo il trasferimento otterremo:
|
||||||
|
|
||||||
|
- `/home/a.txt` trasferito su `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` trasferito su `/home/b.txt`
|
||||||
|
|
||||||
### Synchronized browsing ⏲️
|
### Synchronized browsing ⏲️
|
||||||
|
|
||||||
|
|||||||
23
docs/man.md
23
docs/man.md
@@ -16,6 +16,7 @@
|
|||||||
- [File explorer 📂](#file-explorer-)
|
- [File explorer 📂](#file-explorer-)
|
||||||
- [Keybindings ⌨](#keybindings-)
|
- [Keybindings ⌨](#keybindings-)
|
||||||
- [Work on multiple files 🥷](#work-on-multiple-files-)
|
- [Work on multiple files 🥷](#work-on-multiple-files-)
|
||||||
|
- [Example](#example)
|
||||||
- [Synchronized browsing ⏲️](#synchronized-browsing-️)
|
- [Synchronized browsing ⏲️](#synchronized-browsing-️)
|
||||||
- [Open and Open With 🚪](#open-and-open-with-)
|
- [Open and Open With 🚪](#open-and-open-with-)
|
||||||
- [Bookmarks ⭐](#bookmarks-)
|
- [Bookmarks ⭐](#bookmarks-)
|
||||||
@@ -274,16 +275,34 @@ In order to change panel you need to type `<LEFT>` to move the remote explorer p
|
|||||||
|
|
||||||
### Work on multiple files 🥷
|
### Work on multiple files 🥷
|
||||||
|
|
||||||
You can opt to work on multiple files, selecting them pressing `<M>`, in order to select the current file, or pressing `<CTRL+A>`, which will select all the files in the working directory.
|
You can opt to work on multiple files, with these simple controls:
|
||||||
Once a file is marked for selection, it will be displayed with a `*` on the left.
|
|
||||||
|
- `<M>`: mark a file for selection
|
||||||
|
- `<CTRL+A>`: select all files in the current directory
|
||||||
|
- `<ALT+A>`: deselect all files
|
||||||
|
|
||||||
|
Once a file is marked for selection, it will be **displayed with an highlighted background**.
|
||||||
|
|
||||||
When working on selection, only selected file will be processed for actions, while the current highlighted item will be ignored.
|
When working on selection, only selected file will be processed for actions, while the current highlighted item will be ignored.
|
||||||
It is possible to work on multiple files also when in the find result panel.
|
It is possible to work on multiple files also when in the find result panel.
|
||||||
|
|
||||||
All the actions are available when working with multiple files, but be aware that some actions work in a slightly different way. Let's dive in:
|
All the actions are available when working with multiple files, but be aware that some actions work in a slightly different way. Let's dive in:
|
||||||
|
|
||||||
- *Copy*: whenever you copy a file, you'll be prompted to insert the destination name. When working with multiple file, this name refers to the destination directory where all these files will be copied.
|
- *Copy*: whenever you copy a file, you'll be prompted to insert the destination name. When working with multiple file, this name refers to the destination directory where all these files will be copied.
|
||||||
- *Rename*: same as copy, but will move files there.
|
- *Rename*: same as copy, but will move files there.
|
||||||
- *Save as*: same as copy, but will write them there.
|
- *Save as*: same as copy, but will write them there.
|
||||||
|
|
||||||
|
If you select a file in a directory (e.g. `/home`) and then you change directory the file will be kept selected and it will be displayed in the **transfer queue** in the bottom panel.
|
||||||
|
|
||||||
|
When a file gets selected the current *remote* directory is associated to its entry; so in case the file gets transferred it will be transferred to the directory associated to the file.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
If we select a file on local `/home/a.txt` and we're currently at `/tmp` on remote and then we move to `/var` and we select `/var/b.txt` and on the remote panel we're at `/home` and we perform a transfer the result will be:
|
||||||
|
|
||||||
|
- `/home/a.txt` transferred to `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` transferred to `/home/b.txt`
|
||||||
|
|
||||||
### Synchronized browsing ⏲️
|
### Synchronized browsing ⏲️
|
||||||
|
|
||||||
When enabled, synchronized browsing, will allow you to synchronize the navigation between the two panels.
|
When enabled, synchronized browsing, will allow you to synchronize the navigation between the two panels.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">Desenvolvido por <a href="https://veeso.dev/" target="_blank">@veeso</a></p>
|
<p align="center">Desenvolvido por <a href="https://veeso.me/" target="_blank">@veeso</a></p>
|
||||||
<p align="center">Versão atual: 0.16.1 12/11/2024</p>
|
<p align="center">Versão atual: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
- [Credenciais do S3 🦊](#credenciais-do-s3-)
|
- [Credenciais do S3 🦊](#credenciais-do-s3-)
|
||||||
- [Explorador de Arquivos 📂](#explorador-de-arquivos-)
|
- [Explorador de Arquivos 📂](#explorador-de-arquivos-)
|
||||||
- [Atalhos de Teclado ⌨](#atalhos-de-teclado-)
|
- [Atalhos de Teclado ⌨](#atalhos-de-teclado-)
|
||||||
- [Trabalhar com Vários Arquivos 🥷](#trabalhar-com-vários-arquivos-)
|
- [Trabalhar com múltiplos arquivos 🥷](#trabalhar-com-múltiplos-arquivos-)
|
||||||
|
- [Exemplo](#exemplo)
|
||||||
- [Navegação Sincronizada ⏲️](#navegação-sincronizada-️)
|
- [Navegação Sincronizada ⏲️](#navegação-sincronizada-️)
|
||||||
- [Abrir e Abrir Com 🚪](#abrir-e-abrir-com-)
|
- [Abrir e Abrir Com 🚪](#abrir-e-abrir-com-)
|
||||||
- [Favoritos ⭐](#favoritos-)
|
- [Favoritos ⭐](#favoritos-)
|
||||||
@@ -272,17 +273,34 @@ Para trocar de painel, você precisa pressionar `<LEFT>` para mover para o paine
|
|||||||
| `<CTRL+C>` | Abortir processo de transferência de arquivo | |
|
| `<CTRL+C>` | Abortir processo de transferência de arquivo | |
|
||||||
| `<CTRL+T>` | Mostrar todos os caminhos sincronizados | Track |
|
| `<CTRL+T>` | Mostrar todos os caminhos sincronizados | Track |
|
||||||
|
|
||||||
### Trabalhar com Vários Arquivos 🥷
|
### Trabalhar com múltiplos arquivos 🥷
|
||||||
|
|
||||||
Você pode optar por trabalhar com vários arquivos, selecionando-os pressionando `<M>`, para selecionar o arquivo atual, ou pressionando `<CTRL+A>`, que selecionará todos os arquivos no diretório de trabalho.
|
Você pode optar por trabalhar com vários arquivos, usando estes controles simples:
|
||||||
Uma vez que um arquivo esteja marcado para seleção, ele será exibido com um `*` à esquerda.
|
|
||||||
Ao trabalhar com seleção, apenas o arquivo selecionado será processado para ações, enquanto o item destacado atual será ignorado.
|
|
||||||
É possível trabalhar com vários arquivos também quando estiver no painel de resultados da busca.
|
|
||||||
Todas as ações estão disponíveis ao trabalhar com vários arquivos, mas tenha em mente que algumas ações funcionam de forma ligeiramente diferente. Vamos explicar algumas delas:
|
|
||||||
|
|
||||||
- *Copiar*: sempre que você copiar um arquivo, você será solicitado a inserir o nome de destino. Ao trabalhar com vários arquivos, esse nome refere-se ao diretório de destino onde todos esses arquivos serão copiados.
|
- `<M>`: marcar um arquivo para seleção
|
||||||
- *Renomear*: igual ao copiar, mas moverá os arquivos para lá.
|
- `<CTRL+A>`: selecionar todos os arquivos no diretório atual
|
||||||
- *Salvar como*: igual ao copiar, mas gravará lá.
|
- `<ALT+A>`: desselecionar todos os arquivos
|
||||||
|
|
||||||
|
Uma vez marcado, o arquivo será **exibido com fundo destacado** .
|
||||||
|
Ao trabalhar com seleção, apenas os arquivos selecionados serão processados, enquanto o item atualmente destacado será ignorado.
|
||||||
|
|
||||||
|
É possível trabalhar com múltiplos arquivos também no painel de resultados de busca.
|
||||||
|
|
||||||
|
Todas as ações estão disponíveis ao trabalhar com múltiplos arquivos, mas algumas funcionam de forma ligeiramente diferente. Vamos ver:
|
||||||
|
|
||||||
|
- *Copiar*: ao copiar, será solicitado o nome de destino. Com múltiplos arquivos, esse nome será o diretório de destino para todos eles.
|
||||||
|
- *Renomear*: igual a copiar, mas moverá os arquivos.
|
||||||
|
- *Salvar como*: igual a copiar, mas escreverá os arquivos nesse local.
|
||||||
|
|
||||||
|
Se você selecionar um arquivo num diretório (ex: `/home`) e mudar de diretório, ele continuará selecionado e aparecerá na **fila de transferência** no painel inferior.
|
||||||
|
Ao selecionar um arquivo, o diretório *remoto* atual é associado a ele; então, se for transferido, será enviado para esse diretório associado.
|
||||||
|
|
||||||
|
#### Exemplo
|
||||||
|
|
||||||
|
Se selecionarmos `/home/a.txt` localmente e estivermos em `/tmp` no painel remoto, depois mudarmos para `/var` e selecionarmos `/var/b.txt`, e estivermos em `/home` no painel remoto, ao transferir teremos:
|
||||||
|
|
||||||
|
- `/home/a.txt` transferido para `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` transferido para `/home/b.txt`
|
||||||
|
|
||||||
### Navegação Sincronizada ⏲️
|
### Navegação Sincronizada ⏲️
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href="https://github.com/veeso/termscp/blob/main/docs/ptbr/README.md"
|
href="https://github.com/veeso/termscp/blob/main/docs/pt-BR/README.md"
|
||||||
><img
|
><img
|
||||||
height="20"
|
height="20"
|
||||||
src="/assets/images/flags/br.png"
|
src="/assets/images/flags/br.png"
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">由 <a href="https://veeso.dev/" target="_blank">@veeso</a> 开发</p>
|
<p align="center">由 <a href="https://veeso.me/" target="_blank">@veeso</a> 开发</p>
|
||||||
<p align="center">当前版本: 0.16.1 12/11/2024</p>
|
<p align="center">当前版本: 0.19.0 10/06/2025</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://opensource.org/licenses/MIT"
|
<a href="https://opensource.org/licenses/MIT"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
- [Aws S3 凭证](#aws-s3-凭证)
|
- [Aws S3 凭证](#aws-s3-凭证)
|
||||||
- [文件浏览](#文件浏览)
|
- [文件浏览](#文件浏览)
|
||||||
- [快捷键](#快捷键)
|
- [快捷键](#快捷键)
|
||||||
- [处理多个文件](#处理多个文件)
|
- [操作多个文件 🥷](#操作多个文件-)
|
||||||
|
- [示例](#示例)
|
||||||
- [同步浏览](#同步浏览)
|
- [同步浏览](#同步浏览)
|
||||||
- [打开/打开方式](#打开打开方式)
|
- [打开/打开方式](#打开打开方式)
|
||||||
- [书签](#书签)
|
- [书签](#书签)
|
||||||
@@ -254,14 +255,34 @@ termscp中的文件资源管理器是指你与远程建立连接后可以看到
|
|||||||
| `<CTRL+C>` | 终止文件传输 | |
|
| `<CTRL+C>` | 终止文件传输 | |
|
||||||
| `<CTRL+T>` | 显示所有同步路径 | Track |
|
| `<CTRL+T>` | 显示所有同步路径 | Track |
|
||||||
|
|
||||||
### 处理多个文件
|
### 操作多个文件 🥷
|
||||||
|
|
||||||
你可以同时操作多个文件,按`<M>`选定它们,或者按`<CTRL+A>` 全选当前工作目录中的所有文件。一旦一个文件被标记为选择,它将在左边显示一个 "*"。在这种模式下,只有选定的文件会被处理,而当前光标高亮显示的项目会被忽略。在查找结果面板中,也可以对多个文件进行处理。
|
你可以通过以下简单的控制操作多个文件:
|
||||||
在处理多个文件时,所有的操作都是可用的,但请注意,有些操作的工作方式略有不同。让我们深入了解一下:
|
|
||||||
|
|
||||||
- *复制*: 当你复制一个文件时,你会被提示输入完整目标路径名。当处理多个文件时,这个名称指的是所有这些文件将被复制到的目标目录。
|
- `<M>`:标记文件以进行选择
|
||||||
- *重命名*: 和复制操作类似, 但是会移动文件到目标路径。
|
- `<CTRL+A>`:选择当前目录下的所有文件
|
||||||
- *保存为*: 和复制操作类似, 但是会写入文件到目标路径。
|
- `<ALT+A>`:取消选择所有文件
|
||||||
|
|
||||||
|
被标记的文件将会以**高亮背景** 显示。
|
||||||
|
当进行选择操作时,只有被选中的文件会执行操作,而当前高亮显示的项目会被忽略。
|
||||||
|
|
||||||
|
即使是在查找结果面板中,也可以操作多个文件。
|
||||||
|
|
||||||
|
在操作多个文件时,所有功能都可用,但某些功能会有些许不同。具体如下:
|
||||||
|
|
||||||
|
- *复制*:复制时会提示你输入目标名称。操作多个文件时,该名称是目标目录,所有文件将被复制到此目录中。
|
||||||
|
- *重命名*:与复制相同,但文件将被移动到该目录。
|
||||||
|
- *另存为*:与复制相同,但文件将被写入该目录。
|
||||||
|
|
||||||
|
如果你在某个目录(如 `/home`)中选择了文件,然后切换目录,文件仍会保持被选中状态,并在底部面板的**传输队列** 中显示。
|
||||||
|
文件被选中时,会将当前*远程*目录与该文件关联;如果文件被传输,它将被传输到与之关联的目录中。
|
||||||
|
|
||||||
|
#### 示例
|
||||||
|
|
||||||
|
如果我们在本地选择 `/home/a.txt`,此时远程目录是 `/tmp`,然后我们切换到 `/var`,选择 `/var/b.txt`,而此时远程目录为 `/home`,执行传输后的结果为:
|
||||||
|
|
||||||
|
- `/home/a.txt` 传输到 `/tmp/a.txt`
|
||||||
|
- `/var/b.txt` 传输到 `/home/b.txt`
|
||||||
|
|
||||||
### 同步浏览
|
### 同步浏览
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
# -f, -y, --force, --yes
|
# -f, -y, --force, --yes
|
||||||
# Skip the confirmation prompt during installation
|
# Skip the confirmation prompt during installation
|
||||||
|
|
||||||
TERMSCP_VERSION="0.16.1"
|
TERMSCP_VERSION="0.19.0"
|
||||||
GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}"
|
GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}"
|
||||||
DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb"
|
DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb"
|
||||||
DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb"
|
DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb"
|
||||||
|
|||||||
@@ -30,9 +30,9 @@
|
|||||||
<p class="text-xs font-thin">
|
<p class="text-xs font-thin">
|
||||||
<span>Christian Visintin © </span><span resolve-copyright></span>
|
<span>Christian Visintin © </span><span resolve-copyright></span>
|
||||||
<span> | </span>
|
<span> | </span>
|
||||||
<a class="text-xs font-thin" href="https://veeso.dev/en/privacy" target="_blank">Privacy policy</a>
|
<a class="text-xs font-thin" href="https://veeso.me/en/privacy" target="_blank">Privacy policy</a>
|
||||||
<span> | </span>
|
<span> | </span>
|
||||||
<a class="text-xs font-thin" href="https://veeso.dev/en/cookie-policy" target="_blank">Cookie policy</a>
|
<a class="text-xs font-thin" href="https://veeso.me/en/cookie-policy" target="_blank">Cookie policy</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<span translate="getStarted.windows.moderation">Consider that Chocolatey moderation can take up to a few weeks
|
<span translate="getStarted.windows.moderation">Consider that Chocolatey moderation can take up to a few weeks
|
||||||
since last release, so if the latest version is not available yet,
|
since last release, so if the latest version is not available yet,
|
||||||
you can install it downloading the ZIP file from</span>
|
you can install it downloading the ZIP file from</span>
|
||||||
<a href="https://github.com/veeso/termscp/releases/latest/download/termscp.0.16.1.nupkg"
|
<a href="https://github.com/veeso/termscp/releases/latest/download/termscp.0.19.0.nupkg"
|
||||||
target="_blank">Github</a>
|
target="_blank">Github</a>
|
||||||
<span translate="getStarted.windows.then">and then, from the ZIP directory, install it via</span>
|
<span translate="getStarted.windows.then">and then, from the ZIP directory, install it via</span>
|
||||||
</p>
|
</p>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
On Debian based distros, you can install termscp using the Deb
|
On Debian based distros, you can install termscp using the Deb
|
||||||
package via:
|
package via:
|
||||||
</p>
|
</p>
|
||||||
<pre><span class="function">wget</span> -O termscp.deb <span class="string">https://github.com/veeso/termscp/releases/latest/download/termscp_0.16.1_amd64.deb</span>
|
<pre><span class="function">wget</span> -O termscp.deb <span class="string">https://github.com/veeso/termscp/releases/latest/download/termscp_0.19.0_amd64.deb</span>
|
||||||
sudo <span class="function">dpkg</span> -i <span class="string">termscp.deb</span></pre>
|
sudo <span class="function">dpkg</span> -i <span class="string">termscp.deb</span></pre>
|
||||||
</div>
|
</div>
|
||||||
<h3>
|
<h3>
|
||||||
@@ -157,7 +157,7 @@ sudo <span class="function">dpkg</span> -i <span class="string">termscp.deb</spa
|
|||||||
</p>
|
</p>
|
||||||
<pre><span class="function">cargo</span> install --locked --no-default-features --features smb <span class="string">termscp</span></pre>
|
<pre><span class="function">cargo</span> install --locked --no-default-features --features smb <span class="string">termscp</span></pre>
|
||||||
<p translate="getStarted.cargo.noSMB" class="pt-4 pb-2"></p>
|
<p translate="getStarted.cargo.noSMB" class="pt-4 pb-2"></p>
|
||||||
<pre><span class="function">cargo</span> install --locked --no-default-features --features with-keyring <span class="string">termscp</span></pre>
|
<pre><span class="function">cargo</span> install --locked --no-default-features --features keyring <span class="string">termscp</span></pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="p-4 my-4 text-sm text-green-800 rounded-lg bg-green-50">
|
<div class="p-4 my-4 text-sm text-green-800 rounded-lg bg-green-50">
|
||||||
<p class="text-lg">
|
<p class="text-lg">
|
||||||
<span translate="intro.versionAlert">termscp 0.16.1 is NOW out! Download it from</span>
|
<span translate="intro.versionAlert">termscp 0.19.0 is NOW out! Download it from</span>
|
||||||
<a href="/get-started.html" translate="intro.here">here!</a>
|
<a href="/get-started.html" translate="intro.here">here!</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"intro": {
|
"intro": {
|
||||||
"caption": "A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/Kube/S3/WebDAV",
|
"caption": "A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/Kube/S3/WebDAV",
|
||||||
"getStarted": "Get started →",
|
"getStarted": "Get started →",
|
||||||
"versionAlert": "termscp 0.16.1 is NOW out! Download it from",
|
"versionAlert": "termscp 0.19.0 is NOW out! Download it from",
|
||||||
"here": "here",
|
"here": "here",
|
||||||
"features": {
|
"features": {
|
||||||
"handy": {
|
"handy": {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"intro": {
|
"intro": {
|
||||||
"caption": "Un explorador y transferencia de archivos de terminal rico en funciones, con apoyo para SCP/SFTP/FTP/Kube/S3/WebDAV",
|
"caption": "Un explorador y transferencia de archivos de terminal rico en funciones, con apoyo para SCP/SFTP/FTP/Kube/S3/WebDAV",
|
||||||
"getStarted": "Para iniciar →",
|
"getStarted": "Para iniciar →",
|
||||||
"versionAlert": "termscp 0.16.1 ya está disponible! Descárgalo desde",
|
"versionAlert": "termscp 0.19.0 ya está disponible! Descárgalo desde",
|
||||||
"here": "aquì",
|
"here": "aquì",
|
||||||
"features": {
|
"features": {
|
||||||
"handy": {
|
"handy": {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"intro": {
|
"intro": {
|
||||||
"caption": "Un file transfer et navigateur de terminal riche en fonctionnalités avec support pour SCP/SFTP/FTP/Kube/S3/WebDAV",
|
"caption": "Un file transfer et navigateur de terminal riche en fonctionnalités avec support pour SCP/SFTP/FTP/Kube/S3/WebDAV",
|
||||||
"getStarted": "Pour commencer →",
|
"getStarted": "Pour commencer →",
|
||||||
"versionAlert": "termscp 0.16.1 est maintenant sorti! Télécharge-le depuis",
|
"versionAlert": "termscp 0.19.0 est maintenant sorti! Télécharge-le depuis",
|
||||||
"here": "ici",
|
"here": "ici",
|
||||||
"features": {
|
"features": {
|
||||||
"handy": {
|
"handy": {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"intro": {
|
"intro": {
|
||||||
"caption": "Un file transfer ed explorer ricco di funzionalità con supporto per SFTP/SCP/FTP/S3",
|
"caption": "Un file transfer ed explorer ricco di funzionalità con supporto per SFTP/SCP/FTP/S3",
|
||||||
"getStarted": "Installa termscp →",
|
"getStarted": "Installa termscp →",
|
||||||
"versionAlert": "termscp 0.16.1 è ORA disponbile! Scaricalo da",
|
"versionAlert": "termscp 0.19.0 è ORA disponbile! Scaricalo da",
|
||||||
"here": "qui",
|
"here": "qui",
|
||||||
"features": {
|
"features": {
|
||||||
"handy": {
|
"handy": {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"intro": {
|
"intro": {
|
||||||
"caption": "功能丰富的终端 UI 文件传输和浏览器,支持 SCP/SFTP/FTP/Kube/S3/WebDAV",
|
"caption": "功能丰富的终端 UI 文件传输和浏览器,支持 SCP/SFTP/FTP/Kube/S3/WebDAV",
|
||||||
"getStarted": "开始 →",
|
"getStarted": "开始 →",
|
||||||
"versionAlert": "termscp 0.16.1 现已发布! 从下载",
|
"versionAlert": "termscp 0.19.0 现已发布! 从下载",
|
||||||
"here": "这里",
|
"here": "这里",
|
||||||
"features": {
|
"features": {
|
||||||
"handy": {
|
"handy": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -50,7 +50,7 @@ pub struct ActivityManager {
|
|||||||
|
|
||||||
impl ActivityManager {
|
impl ActivityManager {
|
||||||
/// Initializes a new Activity Manager
|
/// Initializes a new Activity Manager
|
||||||
pub fn new(ticks: Duration) -> Result<ActivityManager, HostError> {
|
pub fn new(ticks: Duration, keyring: bool) -> Result<ActivityManager, HostError> {
|
||||||
// Prepare Context
|
// Prepare Context
|
||||||
// Initialize configuration client
|
// Initialize configuration client
|
||||||
let (config_client, error_config): (ConfigClient, Option<String>) =
|
let (config_client, error_config): (ConfigClient, Option<String>) =
|
||||||
@@ -61,7 +61,7 @@ impl ActivityManager {
|
|||||||
(ConfigClient::degraded(), Some(err))
|
(ConfigClient::degraded(), Some(err))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (bookmarks_client, error_bookmark) = match Self::init_bookmarks_client() {
|
let (bookmarks_client, error_bookmark) = match Self::init_bookmarks_client(keyring) {
|
||||||
Ok(cli) => (cli, None),
|
Ok(cli) => (cli, None),
|
||||||
Err(err) => (None, Some(err)),
|
Err(err) => (None, Some(err)),
|
||||||
};
|
};
|
||||||
@@ -90,13 +90,18 @@ impl ActivityManager {
|
|||||||
)),
|
)),
|
||||||
host_params.password.as_deref(),
|
host_params.password.as_deref(),
|
||||||
),
|
),
|
||||||
Remote::None => self.set_host_params(
|
Remote::None => {
|
||||||
HostParams::HostBridge(HostBridgeParams::Localhost(
|
// local dir is remote_args.local_dir if set, otherwise current dir
|
||||||
env::current_dir()
|
let local_dir = remote_args
|
||||||
.map_err(|e| format!("Could not get current directory: {e}"))?,
|
.local_dir
|
||||||
)),
|
.unwrap_or_else(|| env::current_dir().unwrap());
|
||||||
None,
|
debug!("host bridge is None, setting local dir to {:?}", local_dir,);
|
||||||
),
|
|
||||||
|
self.set_host_params(
|
||||||
|
HostParams::HostBridge(HostBridgeParams::Localhost(local_dir)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
// set remote
|
// set remote
|
||||||
@@ -243,7 +248,7 @@ impl ActivityManager {
|
|||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
r#"Could not resolve bookmark name: "{bookmark_name}" no such bookmark"#
|
r#"Could not resolve bookmark name: "{bookmark_name}" no such bookmark"#
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
Some(params) => params,
|
Some(params) => params,
|
||||||
};
|
};
|
||||||
@@ -342,7 +347,7 @@ impl ActivityManager {
|
|||||||
fn run_filetransfer(&mut self) -> Option<NextActivity> {
|
fn run_filetransfer(&mut self) -> Option<NextActivity> {
|
||||||
info!("Starting FileTransferActivity");
|
info!("Starting FileTransferActivity");
|
||||||
// Get context
|
// Get context
|
||||||
let ctx: Context = match self.context.take() {
|
let mut ctx: Context = match self.context.take() {
|
||||||
Some(ctx) => ctx,
|
Some(ctx) => ctx,
|
||||||
None => {
|
None => {
|
||||||
error!("Failed to start FileTransferActivity: context is None");
|
error!("Failed to start FileTransferActivity: context is None");
|
||||||
@@ -367,8 +372,18 @@ impl ActivityManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut activity: FileTransferActivity =
|
// try to setup activity
|
||||||
FileTransferActivity::new(host_bridge_params, remote_params, self.ticks);
|
let mut activity =
|
||||||
|
match FileTransferActivity::new(host_bridge_params, remote_params, self.ticks) {
|
||||||
|
Ok(activity) => activity,
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to start FileTransferActivity: {}", err);
|
||||||
|
ctx.set_error(err);
|
||||||
|
self.context = Some(ctx);
|
||||||
|
// Return to authentication
|
||||||
|
return Some(NextActivity::Authentication);
|
||||||
|
}
|
||||||
|
};
|
||||||
// Prepare result
|
// Prepare result
|
||||||
let result: Option<NextActivity>;
|
let result: Option<NextActivity>;
|
||||||
// Create activity
|
// Create activity
|
||||||
@@ -432,7 +447,7 @@ impl ActivityManager {
|
|||||||
|
|
||||||
// -- misc
|
// -- misc
|
||||||
|
|
||||||
fn init_bookmarks_client() -> Result<Option<BookmarksClient>, String> {
|
fn init_bookmarks_client(keyring: bool) -> Result<Option<BookmarksClient>, String> {
|
||||||
// Get config dir
|
// Get config dir
|
||||||
match environment::init_config_dir() {
|
match environment::init_config_dir() {
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
@@ -441,16 +456,21 @@ impl ActivityManager {
|
|||||||
let bookmarks_file: PathBuf =
|
let bookmarks_file: PathBuf =
|
||||||
environment::get_bookmarks_paths(config_dir_path.as_path());
|
environment::get_bookmarks_paths(config_dir_path.as_path());
|
||||||
// Initialize client
|
// Initialize client
|
||||||
BookmarksClient::new(bookmarks_file.as_path(), config_dir_path.as_path(), 16)
|
BookmarksClient::new(
|
||||||
.map(Option::Some)
|
bookmarks_file.as_path(),
|
||||||
.map_err(|e| {
|
config_dir_path.as_path(),
|
||||||
format!(
|
16,
|
||||||
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
|
keyring,
|
||||||
bookmarks_file.display(),
|
)
|
||||||
config_dir_path.display(),
|
.map(Option::Some)
|
||||||
e
|
.map_err(|e| {
|
||||||
)
|
format!(
|
||||||
})
|
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
|
||||||
|
bookmarks_file.display(),
|
||||||
|
config_dir_path.display(),
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
@@ -495,19 +515,28 @@ impl ActivityManager {
|
|||||||
match ThemeProvider::new(theme_path.as_path()) {
|
match ThemeProvider::new(theme_path.as_path()) {
|
||||||
Ok(provider) => provider,
|
Ok(provider) => provider,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Could not initialize theme provider with file '{}': {}; using theme provider in degraded mode", theme_path.display(), err);
|
error!(
|
||||||
|
"Could not initialize theme provider with file '{}': {}; using theme provider in degraded mode",
|
||||||
|
theme_path.display(),
|
||||||
|
err
|
||||||
|
);
|
||||||
ThemeProvider::degraded()
|
ThemeProvider::degraded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
error!("This system doesn't provide a configuration directory; using theme provider in degraded mode");
|
error!(
|
||||||
|
"This system doesn't provide a configuration directory; using theme provider in degraded mode"
|
||||||
|
);
|
||||||
ThemeProvider::degraded()
|
ThemeProvider::degraded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Could not initialize configuration directory: {}; using theme provider in degraded mode", err);
|
error!(
|
||||||
|
"Could not initialize configuration directory: {}; using theme provider in degraded mode",
|
||||||
|
err
|
||||||
|
);
|
||||||
ThemeProvider::degraded()
|
ThemeProvider::degraded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ pub enum Task {
|
|||||||
Activity(NextActivity),
|
Activity(NextActivity),
|
||||||
ImportTheme(PathBuf),
|
ImportTheme(PathBuf),
|
||||||
InstallUpdate,
|
InstallUpdate,
|
||||||
|
Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, FromArgs)]
|
#[derive(Default, FromArgs)]
|
||||||
@@ -59,6 +60,9 @@ pub struct Args {
|
|||||||
/// print version
|
/// print version
|
||||||
#[argh(switch, short = 'v')]
|
#[argh(switch, short = 'v')]
|
||||||
pub version: bool,
|
pub version: bool,
|
||||||
|
/// disable keyring support
|
||||||
|
#[argh(switch)]
|
||||||
|
pub wno_keyring: bool,
|
||||||
// -- positional
|
// -- positional
|
||||||
#[argh(positional, description = "address1 address2 local-wrkdir")]
|
#[argh(positional, description = "address1 address2 local-wrkdir")]
|
||||||
pub positional: Vec<String>,
|
pub positional: Vec<String>,
|
||||||
@@ -93,6 +97,7 @@ pub struct LoadThemeArgs {
|
|||||||
|
|
||||||
pub struct RunOpts {
|
pub struct RunOpts {
|
||||||
pub remote: RemoteArgs,
|
pub remote: RemoteArgs,
|
||||||
|
pub keyring: bool,
|
||||||
pub ticks: Duration,
|
pub ticks: Duration,
|
||||||
pub log_level: LogLevel,
|
pub log_level: LogLevel,
|
||||||
pub task: Task,
|
pub task: Task,
|
||||||
@@ -126,6 +131,7 @@ impl Default for RunOpts {
|
|||||||
Self {
|
Self {
|
||||||
remote: RemoteArgs::default(),
|
remote: RemoteArgs::default(),
|
||||||
ticks: Duration::from_millis(10),
|
ticks: Duration::from_millis(10),
|
||||||
|
keyring: true,
|
||||||
log_level: LogLevel::Info,
|
log_level: LogLevel::Info,
|
||||||
task: Task::Activity(NextActivity::Authentication),
|
task: Task::Activity(NextActivity::Authentication),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// Contains the error for serializer/deserializer
|
/// Contains the error for serializer/deserializer
|
||||||
@@ -63,7 +63,7 @@ where
|
|||||||
return Err(SerializerError::new_ex(
|
return Err(SerializerError::new_ex(
|
||||||
SerializerErrorKind::Serialization,
|
SerializerErrorKind::Serialization,
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
trace!("Serialized new bookmarks data: {}", data);
|
trace!("Serialized new bookmarks data: {}", data);
|
||||||
|
|||||||
@@ -364,8 +364,16 @@ impl Formatter {
|
|||||||
if fsentry.is_file() {
|
if fsentry.is_file() {
|
||||||
// Get byte size
|
// Get byte size
|
||||||
let size: ByteSize = ByteSize(fsentry.metadata().size);
|
let size: ByteSize = ByteSize(fsentry.metadata().size);
|
||||||
|
let mut fmt = size.display().si().to_string();
|
||||||
|
// pad with up to len 10
|
||||||
|
let pad = 10usize.saturating_sub(fmt.len());
|
||||||
|
for _ in 0..pad {
|
||||||
|
fmt.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
format!("{cur_str}{prefix}{fmt}")
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{cur_str}{prefix}{size:10}")
|
//format!("{cur_str}{prefix}{size:10}", size = size.display().si())
|
||||||
} else if fsentry.metadata().symlink.is_some() {
|
} else if fsentry.metadata().symlink.is_some() {
|
||||||
let size = ByteSize(
|
let size = ByteSize(
|
||||||
fsentry
|
fsentry
|
||||||
@@ -376,7 +384,14 @@ impl Formatter {
|
|||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.len() as u64,
|
.len() as u64,
|
||||||
);
|
);
|
||||||
format!("{cur_str}{prefix}{size:10}")
|
let mut fmt = size.display().si().to_string();
|
||||||
|
// pad with up to len 10
|
||||||
|
let pad = 10usize.saturating_sub(fmt.len());
|
||||||
|
for _ in 0..pad {
|
||||||
|
fmt.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
format!("{cur_str}{prefix}{fmt}")
|
||||||
} else {
|
} else {
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{cur_str}{prefix} ")
|
format!("{cur_str}{prefix} ")
|
||||||
@@ -489,10 +504,7 @@ impl Formatter {
|
|||||||
};
|
};
|
||||||
// Match format length: group 3
|
// Match format length: group 3
|
||||||
let fmt_len: Option<usize> = match ®ex_match.get(3) {
|
let fmt_len: Option<usize> = match ®ex_match.get(3) {
|
||||||
Some(len) => match len.as_str().parse::<usize>() {
|
Some(len) => len.as_str().parse::<usize>().ok(),
|
||||||
Ok(len) => Some(len),
|
|
||||||
Err(_) => None,
|
|
||||||
},
|
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
// Match format extra: group 2 + 1
|
// Match format extra: group 2 + 1
|
||||||
@@ -596,7 +608,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -rw-r--r-- root 8.2 KB {}",
|
"bar.txt -rw-r--r-- root 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -604,7 +616,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -rw-r--r-- 0 8.2 KB {}",
|
"bar.txt -rw-r--r-- 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -627,7 +639,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"piroparoporoperoperupup… -rw-r--r-- root 8.2 KB {}",
|
"piroparoporoperoperupup… -rw-r--r-- root 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -635,7 +647,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"piroparoporoperoperupup… -rw-r--r-- 0 8.2 KB {}",
|
"piroparoporoperoperupup… -rw-r--r-- 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -658,7 +670,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -????????? root 8.2 KB {}",
|
"bar.txt -????????? root 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -666,7 +678,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -????????? 0 8.2 KB {}",
|
"bar.txt -????????? 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -689,7 +701,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -????????? 0 8.2 KB {}",
|
"bar.txt -????????? 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -697,7 +709,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
formatter.fmt(&entry),
|
formatter.fmt(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -????????? 0 8.2 KB {}",
|
"bar.txt -????????? 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -774,8 +786,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fs_explorer_formatter_all_together_now() {
|
fn test_fs_explorer_formatter_all_together_now() {
|
||||||
let formatter: Formatter =
|
let formatter: Formatter = Formatter::new(
|
||||||
Formatter::new("{NAME:16} {SYMLINK:12} {GROUP} {USER} {PEX} {SIZE} {ATIME:20:%a %b %d %Y %H:%M} {CTIME:20:%a %b %d %Y %H:%M} {MTIME:20:%a %b %d %Y %H:%M}");
|
"{NAME:16} {SYMLINK:12} {GROUP} {USER} {PEX} {SIZE} {ATIME:20:%a %b %d %Y %H:%M} {CTIME:20:%a %b %d %Y %H:%M} {MTIME:20:%a %b %d %Y %H:%M}",
|
||||||
|
);
|
||||||
// Directory (with symlink)
|
// Directory (with symlink)
|
||||||
let t: SystemTime = SystemTime::now();
|
let t: SystemTime = SystemTime::now();
|
||||||
let entry = File {
|
let entry = File {
|
||||||
@@ -792,12 +805,15 @@ mod tests {
|
|||||||
mode: Some(UnixPex::from(0o755)),
|
mode: Some(UnixPex::from(0o755)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert_eq!(formatter.fmt(&entry), format!(
|
assert_eq!(
|
||||||
"projects -> project.info 0 0 lrwxr-xr-x 12 B {} {} {}",
|
formatter.fmt(&entry),
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
format!(
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
"projects -> project.info 0 0 lrwxr-xr-x 12 B {} {} {}",
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
));
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
)
|
||||||
|
);
|
||||||
// Directory without symlink
|
// Directory without symlink
|
||||||
let entry = File {
|
let entry = File {
|
||||||
path: PathBuf::from("/home/cvisintin/projects"),
|
path: PathBuf::from("/home/cvisintin/projects"),
|
||||||
@@ -813,12 +829,15 @@ mod tests {
|
|||||||
mode: Some(UnixPex::from(0o755)),
|
mode: Some(UnixPex::from(0o755)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert_eq!(formatter.fmt(&entry), format!(
|
assert_eq!(
|
||||||
"projects/ 0 0 drwxr-xr-x {} {} {}",
|
formatter.fmt(&entry),
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
format!(
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
"projects/ 0 0 drwxr-xr-x {} {} {}",
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
));
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
)
|
||||||
|
);
|
||||||
// File with symlink
|
// File with symlink
|
||||||
let entry = File {
|
let entry = File {
|
||||||
path: PathBuf::from("/bar.txt"),
|
path: PathBuf::from("/bar.txt"),
|
||||||
@@ -834,12 +853,15 @@ mod tests {
|
|||||||
mode: Some(UnixPex::from(0o644)),
|
mode: Some(UnixPex::from(0o644)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert_eq!(formatter.fmt(&entry), format!(
|
assert_eq!(
|
||||||
"bar.txt -> project.info 0 0 lrw-r--r-- 12 B {} {} {}",
|
formatter.fmt(&entry),
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
format!(
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
"bar.txt -> project.info 0 0 lrw-r--r-- 12 B {} {} {}",
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
));
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
)
|
||||||
|
);
|
||||||
// File without symlink
|
// File without symlink
|
||||||
let entry = File {
|
let entry = File {
|
||||||
path: PathBuf::from("/bar.txt"),
|
path: PathBuf::from("/bar.txt"),
|
||||||
@@ -855,12 +877,15 @@ mod tests {
|
|||||||
mode: Some(UnixPex::from(0o644)),
|
mode: Some(UnixPex::from(0o644)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert_eq!(formatter.fmt(&entry), format!(
|
assert_eq!(
|
||||||
"bar.txt 0 0 -rw-r--r-- 8.2 KB {} {} {}",
|
formatter.fmt(&entry),
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
format!(
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
"bar.txt 0 0 -rw-r--r-- 8.2 kB {} {} {}",
|
||||||
fmt_time(t, "%a %b %d %Y %H:%M"),
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
));
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
fmt_time(t, "%a %b %d %Y %H:%M"),
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pub(crate) mod builder;
|
|||||||
mod formatter;
|
mod formatter;
|
||||||
// Locals
|
// Locals
|
||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
use std::collections::VecDeque;
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
@@ -42,14 +42,26 @@ pub enum GroupDirs {
|
|||||||
|
|
||||||
/// File explorer states
|
/// File explorer states
|
||||||
pub struct FileExplorer {
|
pub struct FileExplorer {
|
||||||
pub wrkdir: PathBuf, // Current directory
|
/// Current working directory
|
||||||
pub(crate) dirstack: VecDeque<PathBuf>, // Stack of visited directory (max 16)
|
pub wrkdir: PathBuf,
|
||||||
pub(crate) stack_size: usize, // Directory stack size
|
/// Stack of visited directories
|
||||||
pub(crate) file_sorting: FileSorting, // File sorting criteria
|
pub(crate) dirstack: VecDeque<PathBuf>,
|
||||||
pub(crate) group_dirs: Option<GroupDirs>, // If Some, defines how to group directories
|
/// Stack size
|
||||||
pub(crate) opts: ExplorerOpts, // Explorer options
|
pub(crate) stack_size: usize,
|
||||||
pub(crate) fmt: Formatter, // File formatter
|
/// Criteria to sort file
|
||||||
files: Vec<File>, // Files in directory
|
pub(crate) file_sorting: FileSorting,
|
||||||
|
/// defines how to group directories in the explorer
|
||||||
|
pub(crate) group_dirs: Option<GroupDirs>,
|
||||||
|
/// Explorer options
|
||||||
|
pub(crate) opts: ExplorerOpts,
|
||||||
|
/// Formatter for file entries
|
||||||
|
pub(crate) fmt: Formatter,
|
||||||
|
/// Is terminal open for this explorer?
|
||||||
|
terminal: bool,
|
||||||
|
/// Files in directory
|
||||||
|
files: Vec<File>,
|
||||||
|
/// files enqueued for transfer. Map between source and destination
|
||||||
|
transfer_queue: HashMap<PathBuf, PathBuf>, // transfer queue
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FileExplorer {
|
impl Default for FileExplorer {
|
||||||
@@ -63,6 +75,8 @@ impl Default for FileExplorer {
|
|||||||
opts: ExplorerOpts::empty(),
|
opts: ExplorerOpts::empty(),
|
||||||
fmt: Formatter::default(),
|
fmt: Formatter::default(),
|
||||||
files: Vec::new(),
|
files: Vec::new(),
|
||||||
|
terminal: false,
|
||||||
|
transfer_queue: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,6 +153,44 @@ impl FileExplorer {
|
|||||||
filtered.get(idx).copied()
|
filtered.get(idx).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enqueue a file for transfer
|
||||||
|
pub fn enqueue(&mut self, src: &Path, dst: &Path) {
|
||||||
|
self.transfer_queue
|
||||||
|
.insert(PathBuf::from(src), PathBuf::from(dst));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Enqueue all files for transfer
|
||||||
|
pub fn enqueue_all(&mut self, dst: &Path) {
|
||||||
|
let files: Vec<_> = self.iter_files().map(|f| f.path.clone()).collect();
|
||||||
|
for file in files {
|
||||||
|
self.enqueue(&file, dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get enqueued files
|
||||||
|
pub fn enqueued(&self) -> &HashMap<PathBuf, PathBuf> {
|
||||||
|
&self.transfer_queue
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Dequeue a file
|
||||||
|
pub fn dequeue(&mut self, src: &Path) {
|
||||||
|
self.transfer_queue.remove(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clear transfer queue
|
||||||
|
pub fn clear_queue(&mut self) {
|
||||||
|
self.transfer_queue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Toggle terminal state
|
||||||
|
pub fn toggle_terminal(&mut self, terminal: bool) {
|
||||||
|
self.terminal = terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn terminal_open(&self) -> bool {
|
||||||
|
self.terminal
|
||||||
|
}
|
||||||
|
|
||||||
// Formatting
|
// Formatting
|
||||||
|
|
||||||
/// Format a file entry
|
/// Format a file entry
|
||||||
@@ -523,7 +575,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
explorer.fmt_file(&entry),
|
explorer.fmt_file(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -rw-r--r-- root 8.2 KB {}",
|
"bar.txt -rw-r--r-- root 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -531,7 +583,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
explorer.fmt_file(&entry),
|
explorer.fmt_file(&entry),
|
||||||
format!(
|
format!(
|
||||||
"bar.txt -rw-r--r-- 0 8.2 KB {}",
|
"bar.txt -rw-r--r-- 0 8.2 kB {}",
|
||||||
fmt_time(t, "%b %d %Y %H:%M")
|
fmt_time(t, "%b %d %Y %H:%M")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -586,6 +638,26 @@ mod tests {
|
|||||||
assert_eq!(explorer.files.len(), 3);
|
assert_eq!(explorer.files.len(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_should_enqueue_and_dequeue_files() {
|
||||||
|
let mut explorer: FileExplorer = FileExplorer::default();
|
||||||
|
// Create files (files are then sorted by name)
|
||||||
|
explorer.set_files(vec![
|
||||||
|
make_fs_entry("CONTRIBUTING.md", false),
|
||||||
|
make_fs_entry("docs", true),
|
||||||
|
make_fs_entry("src", true),
|
||||||
|
make_fs_entry("README.md", false),
|
||||||
|
]);
|
||||||
|
// Enqueue
|
||||||
|
explorer.enqueue(Path::new("CONTRIBUTING.md"), Path::new("CONTRIBUTING.md"));
|
||||||
|
explorer.enqueue(Path::new("docs"), Path::new("docs"));
|
||||||
|
// Dequeue
|
||||||
|
explorer.dequeue(Path::new("CONTRIBUTING.md"));
|
||||||
|
assert_eq!(explorer.enqueued().len(), 1);
|
||||||
|
explorer.dequeue(Path::new("docs"));
|
||||||
|
assert_eq!(explorer.enqueued().len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
fn make_fs_entry(name: &str, is_dir: bool) -> File {
|
fn make_fs_entry(name: &str, is_dir: bool) -> File {
|
||||||
let t: SystemTime = SystemTime::now();
|
let t: SystemTime = SystemTime::now();
|
||||||
let metadata = Metadata {
|
let metadata = Metadata {
|
||||||
|
|||||||
@@ -7,15 +7,19 @@ pub struct HostBridgeBuilder;
|
|||||||
impl HostBridgeBuilder {
|
impl HostBridgeBuilder {
|
||||||
/// Build Host Bridge from parms
|
/// Build Host Bridge from parms
|
||||||
///
|
///
|
||||||
/// if protocol and parameters are inconsistent, the function will panic.
|
/// if protocol and parameters are inconsistent, the function will return an error.
|
||||||
pub fn build(params: HostBridgeParams, config_client: &ConfigClient) -> Box<dyn HostBridge> {
|
pub fn build(
|
||||||
|
params: HostBridgeParams,
|
||||||
|
config_client: &ConfigClient,
|
||||||
|
) -> Result<Box<dyn HostBridge>, String> {
|
||||||
match params {
|
match params {
|
||||||
HostBridgeParams::Localhost(path) => {
|
HostBridgeParams::Localhost(path) => Localhost::new(path)
|
||||||
Box::new(Localhost::new(path).expect("Failed to create Localhost"))
|
.map(|host| Box::new(host) as Box<dyn HostBridge>)
|
||||||
|
.map_err(|e| e.to_string()),
|
||||||
|
HostBridgeParams::Remote(protocol, params) => {
|
||||||
|
RemoteFsBuilder::build(protocol, params, config_client)
|
||||||
|
.map(|host| Box::new(RemoteBridged::from(host)) as Box<dyn HostBridge>)
|
||||||
}
|
}
|
||||||
HostBridgeParams::Remote(protocol, params) => Box::new(RemoteBridged::from(
|
|
||||||
RemoteFsBuilder::build(protocol, params, config_client),
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ impl HostBridgeParams {
|
|||||||
HostBridgeParams::Remote(_, params) => params,
|
HostBridgeParams::Remote(_, params) => params,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the host name for the bridge params
|
||||||
|
pub fn username(&self) -> Option<String> {
|
||||||
|
match self {
|
||||||
|
HostBridgeParams::Localhost(_) => Some(whoami::username()),
|
||||||
|
HostBridgeParams::Remote(_, params) => {
|
||||||
|
params.generic_params().and_then(|p| p.username.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds connection parameters for file transfers
|
/// Holds connection parameters for file transfers
|
||||||
@@ -42,6 +52,15 @@ pub struct FileTransferParams {
|
|||||||
pub local_path: Option<PathBuf>,
|
pub local_path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FileTransferParams {
|
||||||
|
/// Returns the remote path if set, otherwise returns the local path
|
||||||
|
pub fn username(&self) -> Option<String> {
|
||||||
|
self.params
|
||||||
|
.generic_params()
|
||||||
|
.and_then(|p| p.username.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Container for protocol params
|
/// Container for protocol params
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ProtocolParams {
|
pub enum ProtocolParams {
|
||||||
@@ -301,11 +320,13 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn password_missing() {
|
fn password_missing() {
|
||||||
assert!(FileTransferParams::new(
|
assert!(
|
||||||
FileTransferProtocol::Scp,
|
FileTransferParams::new(
|
||||||
ProtocolParams::AwsS3(AwsS3Params::new("omar", Some("eu-west-1"), Some("test")))
|
FileTransferProtocol::Scp,
|
||||||
)
|
ProtocolParams::AwsS3(AwsS3Params::new("omar", Some("eu-west-1"), Some("test")))
|
||||||
.password_missing());
|
)
|
||||||
|
.password_missing()
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FileTransferParams::new(
|
FileTransferParams::new(
|
||||||
FileTransferProtocol::Scp,
|
FileTransferProtocol::Scp,
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ use remotefs_kube::KubeMultiPodFs as KubeFs;
|
|||||||
use remotefs_smb::SmbOptions;
|
use remotefs_smb::SmbOptions;
|
||||||
#[cfg(smb)]
|
#[cfg(smb)]
|
||||||
use remotefs_smb::{SmbCredentials, SmbFs};
|
use remotefs_smb::{SmbCredentials, SmbFs};
|
||||||
|
#[cfg(windows)]
|
||||||
|
use remotefs_ssh::LibSsh2Session as SshSession;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use remotefs_ssh::LibSshSession as SshSession;
|
||||||
use remotefs_ssh::{ScpFs, SftpFs, SshAgentIdentity, SshConfigParseRule, SshOpts};
|
use remotefs_ssh::{ScpFs, SftpFs, SshAgentIdentity, SshConfigParseRule, SshOpts};
|
||||||
use remotefs_webdav::WebDAVFs;
|
use remotefs_webdav::WebDAVFs;
|
||||||
|
|
||||||
@@ -37,40 +41,50 @@ impl RemoteFsBuilder {
|
|||||||
protocol: FileTransferProtocol,
|
protocol: FileTransferProtocol,
|
||||||
params: ProtocolParams,
|
params: ProtocolParams,
|
||||||
config_client: &ConfigClient,
|
config_client: &ConfigClient,
|
||||||
) -> Box<dyn RemoteFs> {
|
) -> Result<Box<dyn RemoteFs>, String> {
|
||||||
match (protocol, params) {
|
match (protocol, params) {
|
||||||
(FileTransferProtocol::AwsS3, ProtocolParams::AwsS3(params)) => {
|
(FileTransferProtocol::AwsS3, ProtocolParams::AwsS3(params)) => {
|
||||||
Box::new(Self::aws_s3_client(params))
|
Ok(Box::new(Self::aws_s3_client(params)))
|
||||||
}
|
}
|
||||||
(FileTransferProtocol::Ftp(secure), ProtocolParams::Generic(params)) => {
|
(FileTransferProtocol::Ftp(secure), ProtocolParams::Generic(params)) => {
|
||||||
Box::new(Self::ftp_client(params, secure))
|
Ok(Box::new(Self::ftp_client(params, secure)))
|
||||||
}
|
}
|
||||||
(FileTransferProtocol::Kube, ProtocolParams::Kube(params)) => {
|
(FileTransferProtocol::Kube, ProtocolParams::Kube(params)) => {
|
||||||
Box::new(Self::kube_client(params))
|
Ok(Box::new(Self::kube_client(params)))
|
||||||
}
|
}
|
||||||
(FileTransferProtocol::Scp, ProtocolParams::Generic(params)) => {
|
(FileTransferProtocol::Scp, ProtocolParams::Generic(params)) => {
|
||||||
Box::new(Self::scp_client(params, config_client))
|
Ok(Box::new(Self::scp_client(params, config_client)))
|
||||||
}
|
}
|
||||||
(FileTransferProtocol::Sftp, ProtocolParams::Generic(params)) => {
|
(FileTransferProtocol::Sftp, ProtocolParams::Generic(params)) => {
|
||||||
Box::new(Self::sftp_client(params, config_client))
|
Ok(Box::new(Self::sftp_client(params, config_client)))
|
||||||
}
|
}
|
||||||
#[cfg(smb)]
|
#[cfg(smb)]
|
||||||
(FileTransferProtocol::Smb, ProtocolParams::Smb(params)) => {
|
(FileTransferProtocol::Smb, ProtocolParams::Smb(params)) => {
|
||||||
Box::new(Self::smb_client(params))
|
Ok(Box::new(Self::smb_client(params)))
|
||||||
}
|
}
|
||||||
(FileTransferProtocol::WebDAV, ProtocolParams::WebDAV(params)) => {
|
(FileTransferProtocol::WebDAV, ProtocolParams::WebDAV(params)) => {
|
||||||
Box::new(Self::webdav_client(params))
|
Ok(Box::new(Self::webdav_client(params)))
|
||||||
}
|
}
|
||||||
(protocol, params) => {
|
(protocol, params) => {
|
||||||
error!("Invalid params for protocol '{:?}'", protocol);
|
error!("Invalid params for protocol '{:?}'", protocol);
|
||||||
panic!("Invalid protocol '{protocol:?}' with parameters of type {params:?}")
|
Err(format!(
|
||||||
|
"Invalid protocol '{protocol:?}' with parameters of type {params:?}",
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build aws s3 client from parameters
|
/// Build aws s3 client from parameters
|
||||||
fn aws_s3_client(params: AwsS3Params) -> AwsS3Fs {
|
fn aws_s3_client(params: AwsS3Params) -> AwsS3Fs {
|
||||||
let mut client = AwsS3Fs::new(params.bucket_name).new_path_style(params.new_path_style);
|
let rt = Arc::new(
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.worker_threads(1)
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.expect("Unable to create tokio runtime"),
|
||||||
|
);
|
||||||
|
let mut client =
|
||||||
|
AwsS3Fs::new(params.bucket_name, &rt).new_path_style(params.new_path_style);
|
||||||
if let Some(region) = params.region {
|
if let Some(region) = params.region {
|
||||||
client = client.region(region);
|
client = client.region(region);
|
||||||
}
|
}
|
||||||
@@ -128,12 +142,18 @@ impl RemoteFsBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build scp client
|
/// Build scp client
|
||||||
fn scp_client(params: GenericProtocolParams, config_client: &ConfigClient) -> ScpFs {
|
fn scp_client(
|
||||||
|
params: GenericProtocolParams,
|
||||||
|
config_client: &ConfigClient,
|
||||||
|
) -> ScpFs<SshSession> {
|
||||||
Self::build_ssh_opts(params, config_client).into()
|
Self::build_ssh_opts(params, config_client).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build sftp client
|
/// Build sftp client
|
||||||
fn sftp_client(params: GenericProtocolParams, config_client: &ConfigClient) -> SftpFs {
|
fn sftp_client(
|
||||||
|
params: GenericProtocolParams,
|
||||||
|
config_client: &ConfigClient,
|
||||||
|
) -> SftpFs<SshSession> {
|
||||||
Self::build_ssh_opts(params, config_client).into()
|
Self::build_ssh_opts(params, config_client).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,8 +243,12 @@ impl RemoteFsBuilder {
|
|||||||
debug!("no username was provided, using current username");
|
debug!("no username was provided, using current username");
|
||||||
opts = opts.username(whoami::username());
|
opts = opts.username(whoami::username());
|
||||||
}
|
}
|
||||||
|
// For SSH protocols, only set password if explicitly provided and non-empty.
|
||||||
|
// This allows the SSH library to prioritize key-based and agent authentication.
|
||||||
if let Some(password) = params.password {
|
if let Some(password) = params.password {
|
||||||
opts = opts.password(password);
|
if !password.is_empty() {
|
||||||
|
opts = opts.password(password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(config_path) = config_client.get_ssh_config() {
|
if let Some(config_path) = config_client.get_ssh_config() {
|
||||||
opts = opts.config_file(
|
opts = opts.config_file(
|
||||||
@@ -262,7 +286,9 @@ mod test {
|
|||||||
.session_token(Some("gerry-scotti")),
|
.session_token(Some("gerry-scotti")),
|
||||||
);
|
);
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::AwsS3, params, &config_client);
|
assert!(
|
||||||
|
RemoteFsBuilder::build(FileTransferProtocol::AwsS3, params, &config_client).is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -275,7 +301,9 @@ mod test {
|
|||||||
.password(Some("qwerty123")),
|
.password(Some("qwerty123")),
|
||||||
);
|
);
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::Ftp(true), params, &config_client);
|
assert!(
|
||||||
|
RemoteFsBuilder::build(FileTransferProtocol::Ftp(true), params, &config_client).is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -288,7 +316,7 @@ mod test {
|
|||||||
client_key: Some("client_key".to_string()),
|
client_key: Some("client_key".to_string()),
|
||||||
});
|
});
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::Kube, params, &config_client);
|
assert!(RemoteFsBuilder::build(FileTransferProtocol::Kube, params, &config_client).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -301,7 +329,7 @@ mod test {
|
|||||||
.password(Some("qwerty123")),
|
.password(Some("qwerty123")),
|
||||||
);
|
);
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::Scp, params, &config_client);
|
assert!(RemoteFsBuilder::build(FileTransferProtocol::Scp, params, &config_client).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -314,7 +342,7 @@ mod test {
|
|||||||
.password(Some("qwerty123")),
|
.password(Some("qwerty123")),
|
||||||
);
|
);
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::Sftp, params, &config_client);
|
assert!(RemoteFsBuilder::build(FileTransferProtocol::Sftp, params, &config_client).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -322,11 +350,10 @@ mod test {
|
|||||||
fn should_build_smb_fs() {
|
fn should_build_smb_fs() {
|
||||||
let params = ProtocolParams::Smb(SmbParams::new("localhost", "share"));
|
let params = ProtocolParams::Smb(SmbParams::new("localhost", "share"));
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::Smb, params, &config_client);
|
assert!(RemoteFsBuilder::build(FileTransferProtocol::Smb, params, &config_client).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
|
||||||
fn should_not_build_fs() {
|
fn should_not_build_fs() {
|
||||||
let params = ProtocolParams::Generic(
|
let params = ProtocolParams::Generic(
|
||||||
GenericProtocolParams::default()
|
GenericProtocolParams::default()
|
||||||
@@ -336,7 +363,9 @@ mod test {
|
|||||||
.password(Some("qwerty123")),
|
.password(Some("qwerty123")),
|
||||||
);
|
);
|
||||||
let config_client = get_config_client();
|
let config_client = get_config_client();
|
||||||
let _ = RemoteFsBuilder::build(FileTransferProtocol::AwsS3, params, &config_client);
|
assert!(
|
||||||
|
RemoteFsBuilder::build(FileTransferProtocol::AwsS3, params, &config_client).is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_client() -> ConfigClient {
|
fn get_config_client() -> ConfigClient {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use remotefs::fs::{Metadata, UnixPex};
|
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
|
use remotefs::fs::{Metadata, UnixPex};
|
||||||
|
|
||||||
use super::HostResult;
|
use super::HostResult;
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use std::os::unix::fs::PermissionsExt as _;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
use remotefs::fs::{FileType, Metadata, UnixPex};
|
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
|
use remotefs::fs::{FileType, Metadata, UnixPex};
|
||||||
|
|
||||||
use super::{HostBridge, HostResult};
|
use super::{HostBridge, HostResult};
|
||||||
use crate::host::{HostError, HostErrorType};
|
use crate::host::{HostError, HostErrorType};
|
||||||
@@ -105,8 +105,8 @@ impl HostBridge for Localhost {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
let prev_dir: PathBuf = self.wrkdir.clone(); // Backup location
|
let prev_dir: PathBuf = self.wrkdir.clone(); // Backup location
|
||||||
// Update working directory
|
// Update working directory
|
||||||
// Change dir
|
// Change dir
|
||||||
self.wrkdir = new_dir;
|
self.wrkdir = new_dir;
|
||||||
// Scan new directory
|
// Scan new directory
|
||||||
let pwd = self.pwd()?;
|
let pwd = self.pwd()?;
|
||||||
@@ -135,7 +135,7 @@ impl HostBridge for Localhost {
|
|||||||
HostErrorType::FileAlreadyExists,
|
HostErrorType::FileAlreadyExists,
|
||||||
None,
|
None,
|
||||||
dir_path.as_path(),
|
dir_path.as_path(),
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,7 +559,7 @@ mod tests {
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::AddAssign;
|
use std::ops::AddAssign;
|
||||||
#[cfg(posix)]
|
#[cfg(posix)]
|
||||||
use std::os::unix::fs::{symlink, PermissionsExt};
|
use std::os::unix::fs::{PermissionsExt, symlink};
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
@@ -579,6 +579,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(posix)]
|
#[cfg(posix)]
|
||||||
|
#[cfg(not(feature = "isolated-tests"))]
|
||||||
fn test_host_localhost_new() {
|
fn test_host_localhost_new() {
|
||||||
let host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
let host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
||||||
assert_eq!(host.wrkdir, PathBuf::from("/dev"));
|
assert_eq!(host.wrkdir, PathBuf::from("/dev"));
|
||||||
@@ -622,6 +623,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(posix)]
|
#[cfg(posix)]
|
||||||
|
#[cfg(not(feature = "isolated-tests"))]
|
||||||
fn test_host_localhost_change_dir() {
|
fn test_host_localhost_change_dir() {
|
||||||
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
||||||
let new_dir: PathBuf = PathBuf::from("/dev");
|
let new_dir: PathBuf = PathBuf::from("/dev");
|
||||||
@@ -659,9 +661,10 @@ mod tests {
|
|||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_host_localhost_open_read_err_no_such_file() {
|
fn test_host_localhost_open_read_err_no_such_file() {
|
||||||
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
|
||||||
assert!(host
|
assert!(
|
||||||
.open_file(PathBuf::from("/bin/foo-bar-test-omar-123-456-789.txt").as_path())
|
host.open_file(PathBuf::from("/bin/foo-bar-test-omar-123-456-789.txt").as_path())
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -702,11 +705,13 @@ mod tests {
|
|||||||
// Create sample file
|
// Create sample file
|
||||||
assert!(StdFile::create(format!("{}/foo.txt", tmpdir.path().display()).as_str()).is_ok());
|
assert!(StdFile::create(format!("{}/foo.txt", tmpdir.path().display()).as_str()).is_ok());
|
||||||
// Create symlink
|
// Create symlink
|
||||||
assert!(symlink(
|
assert!(
|
||||||
format!("{}/foo.txt", tmpdir.path().display()),
|
symlink(
|
||||||
format!("{}/bar.txt", tmpdir.path().display())
|
format!("{}/foo.txt", tmpdir.path().display()),
|
||||||
)
|
format!("{}/bar.txt", tmpdir.path().display())
|
||||||
.is_ok());
|
)
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// Get dir
|
// Get dir
|
||||||
let host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
|
let host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
@@ -742,19 +747,21 @@ mod tests {
|
|||||||
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_ok());
|
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_ok());
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
assert_eq!(files.len(), 1); // There should be 1 file now
|
assert_eq!(files.len(), 1); // There should be 1 file now
|
||||||
// Try to re-create directory
|
// Try to re-create directory
|
||||||
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_err());
|
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_err());
|
||||||
// Try abs path
|
// Try abs path
|
||||||
assert!(host
|
assert!(
|
||||||
.mkdir_ex(PathBuf::from("/tmp/test_dir_123456789").as_path(), true)
|
host.mkdir_ex(PathBuf::from("/tmp/test_dir_123456789").as_path(), true)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
// Fail
|
// Fail
|
||||||
assert!(host
|
assert!(
|
||||||
.mkdir_ex(
|
host.mkdir_ex(
|
||||||
PathBuf::from("/aaaa/oooooo/tmp/test_dir_123456789").as_path(),
|
PathBuf::from("/aaaa/oooooo/tmp/test_dir_123456789").as_path(),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -766,24 +773,26 @@ mod tests {
|
|||||||
let mut host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
|
let mut host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
assert_eq!(files.len(), 1); // There should be 1 file now
|
assert_eq!(files.len(), 1); // There should be 1 file now
|
||||||
// Remove file
|
// Remove file
|
||||||
assert!(host.remove(files.get(0).unwrap()).is_ok());
|
assert!(host.remove(files.get(0).unwrap()).is_ok());
|
||||||
// There should be 0 files now
|
// There should be 0 files now
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
assert_eq!(files.len(), 0); // There should be 0 files now
|
assert_eq!(files.len(), 0); // There should be 0 files now
|
||||||
// Create directory
|
// Create directory
|
||||||
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_ok());
|
assert!(host.mkdir(PathBuf::from("test_dir").as_path()).is_ok());
|
||||||
// Delete directory
|
// Delete directory
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
assert_eq!(files.len(), 1); // There should be 1 file now
|
assert_eq!(files.len(), 1); // There should be 1 file now
|
||||||
assert!(host.remove(files.get(0).unwrap()).is_ok());
|
assert!(host.remove(files.get(0).unwrap()).is_ok());
|
||||||
// Remove unexisting directory
|
// Remove unexisting directory
|
||||||
assert!(host
|
assert!(
|
||||||
.remove(&make_fsentry(PathBuf::from("/a/b/c/d"), true))
|
host.remove(&make_fsentry(PathBuf::from("/a/b/c/d"), true))
|
||||||
.is_err());
|
.is_err()
|
||||||
assert!(host
|
);
|
||||||
.remove(&make_fsentry(PathBuf::from("/aaaaaaa"), false))
|
assert!(
|
||||||
.is_err());
|
host.remove(&make_fsentry(PathBuf::from("/aaaaaaa"), false))
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -801,18 +810,20 @@ mod tests {
|
|||||||
// Rename file
|
// Rename file
|
||||||
let dst_path: PathBuf =
|
let dst_path: PathBuf =
|
||||||
PathBuf::from(format!("{}/bar.txt", tmpdir.path().display()).as_str());
|
PathBuf::from(format!("{}/bar.txt", tmpdir.path().display()).as_str());
|
||||||
assert!(host
|
assert!(
|
||||||
.rename(files.get(0).unwrap(), dst_path.as_path())
|
host.rename(files.get(0).unwrap(), dst_path.as_path())
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
// There should be still 1 file now, but named bar.txt
|
// There should be still 1 file now, but named bar.txt
|
||||||
let files: Vec<File> = host.files.clone();
|
let files: Vec<File> = host.files.clone();
|
||||||
assert_eq!(files.len(), 1); // There should be 0 files now
|
assert_eq!(files.len(), 1); // There should be 0 files now
|
||||||
assert_eq!(files.get(0).unwrap().name(), "bar.txt");
|
assert_eq!(files.get(0).unwrap().name(), "bar.txt");
|
||||||
// Fail
|
// Fail
|
||||||
let bad_path: PathBuf = PathBuf::from("/asdailsjoidoewojdijow/ashdiuahu");
|
let bad_path: PathBuf = PathBuf::from("/asdailsjoidoewojdijow/ashdiuahu");
|
||||||
assert!(host
|
assert!(
|
||||||
.rename(files.get(0).unwrap(), bad_path.as_path())
|
host.rename(files.get(0).unwrap(), bad_path.as_path())
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -851,12 +862,13 @@ mod tests {
|
|||||||
// Chmod to dir
|
// Chmod to dir
|
||||||
assert!(host.chmod(tmpdir.path(), UnixPex::from(0o750)).is_ok());
|
assert!(host.chmod(tmpdir.path(), UnixPex::from(0o750)).is_ok());
|
||||||
// Error
|
// Error
|
||||||
assert!(host
|
assert!(
|
||||||
.chmod(
|
host.chmod(
|
||||||
Path::new("/tmp/krgiogoiegj/kwrgnoerig"),
|
Path::new("/tmp/krgiogoiegj/kwrgnoerig"),
|
||||||
UnixPex::from(0o777)
|
UnixPex::from(0o777)
|
||||||
)
|
)
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(posix)]
|
#[cfg(posix)]
|
||||||
@@ -881,12 +893,13 @@ mod tests {
|
|||||||
// Verify host has two files
|
// Verify host has two files
|
||||||
assert_eq!(host.files.len(), 2);
|
assert_eq!(host.files.len(), 2);
|
||||||
// Fail copy
|
// Fail copy
|
||||||
assert!(host
|
assert!(
|
||||||
.copy(
|
host.copy(
|
||||||
&make_fsentry(PathBuf::from("/a/a7/a/a7a"), false),
|
&make_fsentry(PathBuf::from("/a/a7/a/a7a"), false),
|
||||||
PathBuf::from("571k422i").as_path()
|
PathBuf::from("571k422i").as_path()
|
||||||
)
|
)
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(posix)]
|
#[cfg(posix)]
|
||||||
@@ -994,9 +1007,10 @@ mod tests {
|
|||||||
assert!(host.symlink(Path::new("link.txt"), p.as_path()).is_ok());
|
assert!(host.symlink(Path::new("link.txt"), p.as_path()).is_ok());
|
||||||
// Fail symlink
|
// Fail symlink
|
||||||
assert!(host.symlink(Path::new("link.txt"), p.as_path()).is_err());
|
assert!(host.symlink(Path::new("link.txt"), p.as_path()).is_err());
|
||||||
assert!(host
|
assert!(
|
||||||
.symlink(Path::new("/tmp/oooo/aaaa"), p.as_path())
|
host.symlink(Path::new("/tmp/oooo/aaaa"), p.as_path())
|
||||||
.is_err());
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub enum HostErrorType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// HostError is a wrapper for the error type and the exact io error
|
/// HostError is a wrapper for the error type and the exact io error
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub struct HostError {
|
pub struct HostError {
|
||||||
pub error: HostErrorType,
|
pub error: HostErrorType,
|
||||||
ioerr: Option<std::io::Error>,
|
ioerr: Option<std::io::Error>,
|
||||||
|
|||||||
67
src/main.rs
67
src/main.rs
@@ -33,24 +33,24 @@ const APP_NAME: &str = env!("CARGO_PKG_NAME");
|
|||||||
const APP_BUILD_DATE: &str = env!("VERGEN_BUILD_TIMESTAMP");
|
const APP_BUILD_DATE: &str = env!("VERGEN_BUILD_TIMESTAMP");
|
||||||
const APP_GIT_BRANCH: &str = env!("VERGEN_GIT_BRANCH");
|
const APP_GIT_BRANCH: &str = env!("VERGEN_GIT_BRANCH");
|
||||||
const APP_GIT_HASH: &str = env!("VERGEN_GIT_SHA");
|
const APP_GIT_HASH: &str = env!("VERGEN_GIT_SHA");
|
||||||
const EXIT_CODE_SUCCESS: i32 = 0;
|
|
||||||
const EXIT_CODE_ERROR: i32 = 1;
|
|
||||||
const TERMSCP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
const TERMSCP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
const TERMSCP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
const TERMSCP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
||||||
|
|
||||||
|
type MainResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn git_hash() -> &'static str {
|
fn git_hash() -> &'static str {
|
||||||
APP_GIT_HASH[0..8].as_ref()
|
APP_GIT_HASH[0..8].as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() -> MainResult<()> {
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
// Parse args
|
// Parse args
|
||||||
let run_opts: RunOpts = match parse_args(args) {
|
let run_opts: RunOpts = match parse_args(args) {
|
||||||
Ok(opts) => opts,
|
Ok(opts) => opts,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
std::process::exit(255);
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Setup logging
|
// Setup logging
|
||||||
@@ -63,10 +63,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
// Run
|
// Run
|
||||||
info!("Starting activity manager...");
|
info!("Starting activity manager...");
|
||||||
let rc = run(run_opts);
|
run(run_opts)
|
||||||
info!("termscp terminated with exitcode {}", rc);
|
|
||||||
// Then return
|
|
||||||
std::process::exit(rc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse arguments
|
/// Parse arguments
|
||||||
@@ -79,12 +76,11 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
Some(ArgsSubcommands::Config(_)) => RunOpts::config(),
|
Some(ArgsSubcommands::Config(_)) => RunOpts::config(),
|
||||||
None => {
|
None => {
|
||||||
let mut run_opts: RunOpts = RunOpts::default();
|
let mut run_opts: RunOpts = RunOpts::default();
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
if args.version {
|
if args.version {
|
||||||
return Err(format!(
|
run_opts.task = Task::Version;
|
||||||
"{APP_NAME} v{TERMSCP_VERSION} ({APP_GIT_BRANCH}, {git_hash}, {APP_BUILD_DATE}) - Developed by {TERMSCP_AUTHORS}",
|
return Ok(run_opts);
|
||||||
git_hash = git_hash()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
// Logging
|
// Logging
|
||||||
if args.debug {
|
if args.debug {
|
||||||
@@ -92,6 +88,10 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
} else if args.quiet {
|
} else if args.quiet {
|
||||||
run_opts.log_level = LogLevel::Off;
|
run_opts.log_level = LogLevel::Off;
|
||||||
}
|
}
|
||||||
|
// set keyring
|
||||||
|
if args.wno_keyring {
|
||||||
|
run_opts.keyring = false;
|
||||||
|
}
|
||||||
// Match ticks
|
// Match ticks
|
||||||
run_opts.ticks = Duration::from_millis(args.ticks);
|
run_opts.ticks = Duration::from_millis(args.ticks);
|
||||||
// Remote argument
|
// Remote argument
|
||||||
@@ -125,57 +125,74 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Run task and return rc
|
/// Run task and return rc
|
||||||
fn run(run_opts: RunOpts) -> i32 {
|
fn run(run_opts: RunOpts) -> MainResult<()> {
|
||||||
match run_opts.task {
|
match run_opts.task {
|
||||||
Task::ImportTheme(theme) => run_import_theme(&theme),
|
Task::ImportTheme(theme) => run_import_theme(&theme),
|
||||||
Task::InstallUpdate => run_install_update(),
|
Task::InstallUpdate => run_install_update(),
|
||||||
Task::Activity(activity) => run_activity(activity, run_opts.ticks, run_opts.remote),
|
Task::Activity(activity) => {
|
||||||
|
run_activity(activity, run_opts.ticks, run_opts.remote, run_opts.keyring)
|
||||||
|
}
|
||||||
|
Task::Version => print_version(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_import_theme(theme: &Path) -> i32 {
|
fn print_version() -> MainResult<()> {
|
||||||
|
println!(
|
||||||
|
"{APP_NAME} v{TERMSCP_VERSION} ({APP_GIT_BRANCH}, {git_hash}, {APP_BUILD_DATE}) - Developed by {TERMSCP_AUTHORS}",
|
||||||
|
git_hash = git_hash()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_import_theme(theme: &Path) -> MainResult<()> {
|
||||||
match support::import_theme(theme) {
|
match support::import_theme(theme) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Theme has been successfully imported!");
|
println!("Theme has been successfully imported!");
|
||||||
EXIT_CODE_ERROR
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
EXIT_CODE_ERROR
|
Err(err.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_install_update() -> i32 {
|
fn run_install_update() -> MainResult<()> {
|
||||||
match support::install_update() {
|
match support::install_update() {
|
||||||
Ok(msg) => {
|
Ok(msg) => {
|
||||||
println!("{msg}");
|
println!("{msg}");
|
||||||
EXIT_CODE_SUCCESS
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Could not install update: {err}");
|
eprintln!("Could not install update: {err}");
|
||||||
EXIT_CODE_ERROR
|
Err(err.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_activity(activity: NextActivity, ticks: Duration, remote_args: RemoteArgs) -> i32 {
|
fn run_activity(
|
||||||
|
activity: NextActivity,
|
||||||
|
ticks: Duration,
|
||||||
|
remote_args: RemoteArgs,
|
||||||
|
keyring: bool,
|
||||||
|
) -> MainResult<()> {
|
||||||
// Create activity manager (and context too)
|
// Create activity manager (and context too)
|
||||||
let mut manager: ActivityManager = match ActivityManager::new(ticks) {
|
let mut manager: ActivityManager = match ActivityManager::new(ticks, keyring) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Could not start activity manager: {err}");
|
eprintln!("Could not start activity manager: {err}");
|
||||||
return EXIT_CODE_ERROR;
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set file transfer params if set
|
// Set file transfer params if set
|
||||||
if let Err(err) = manager.configure_remote_args(remote_args) {
|
if let Err(err) = manager.configure_remote_args(remote_args) {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
return EXIT_CODE_ERROR;
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.run(activity);
|
manager.run(activity);
|
||||||
|
|
||||||
EXIT_CODE_SUCCESS
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ fn get_config_client() -> Option<ConfigClient> {
|
|||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
Ok(dir) => {
|
Ok(dir) => {
|
||||||
let (cfg_path, ssh_key_dir) = environment::get_config_paths(dir.as_path());
|
let (cfg_path, ssh_key_dir) = environment::get_config_paths(dir.as_path());
|
||||||
match ConfigClient::new(cfg_path.as_path(), ssh_key_dir.as_path()) {
|
ConfigClient::new(cfg_path.as_path(), ssh_key_dir.as_path()).ok()
|
||||||
Err(_) => None,
|
|
||||||
Ok(c) => Some(c),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +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 std::net::ToSocketAddrs as _;
|
||||||
|
|
||||||
use self_update::backends::github::Update as GithubUpdater;
|
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::update::Release as UpdRelease;
|
use self_update::update::Release as UpdRelease;
|
||||||
use self_update::{cargo_crate_version, Status};
|
use self_update::{Status, cargo_crate_version};
|
||||||
|
|
||||||
use crate::utils::parser::parse_semver;
|
use crate::utils::parser::parse_semver;
|
||||||
|
|
||||||
@@ -67,6 +69,9 @@ impl Update {
|
|||||||
/// otherwise if no version is available, return None
|
/// otherwise if no version is available, return None
|
||||||
/// In case of error returns Error with the error description
|
/// In case of error returns Error with the error description
|
||||||
pub fn is_new_version_available() -> Result<Option<Release>, UpdateError> {
|
pub fn is_new_version_available() -> Result<Option<Release>, UpdateError> {
|
||||||
|
// check if api.github.com is reachable before doing anything
|
||||||
|
Self::check_github_api_reachable()?;
|
||||||
|
|
||||||
info!("Checking whether a new version is available...");
|
info!("Checking whether a new version is available...");
|
||||||
GithubUpdater::configure()
|
GithubUpdater::configure()
|
||||||
// Set default options
|
// Set default options
|
||||||
@@ -83,6 +88,27 @@ impl Update {
|
|||||||
.map(Self::check_version)
|
.map(Self::check_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if api.github.com is reachable
|
||||||
|
/// This is useful to avoid long timeouts when the network is down
|
||||||
|
/// or the DNS is not working
|
||||||
|
fn check_github_api_reachable() -> Result<(), UpdateError> {
|
||||||
|
let Some(socket_addr) = ("api.github.com", 443)
|
||||||
|
.to_socket_addrs()
|
||||||
|
.ok()
|
||||||
|
.and_then(|mut i| i.next())
|
||||||
|
else {
|
||||||
|
error!("Could not resolve api.github.com");
|
||||||
|
return Err(UpdateError::Network(
|
||||||
|
"Could not resolve api.github.com".into(),
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
// just try to open a connection to api.github.com with a timeout of 5 seconds with tcp
|
||||||
|
std::net::TcpStream::connect_timeout(&socket_addr, std::time::Duration::from_secs(5))
|
||||||
|
.map(|_| ())
|
||||||
|
.map_err(|e| UpdateError::Network(format!("Could not reach api.github.com: {e}")))
|
||||||
|
}
|
||||||
|
|
||||||
/// In case received version is newer than current one, version as Some is returned; otherwise None
|
/// In case received version is newer than current one, version as Some is returned; otherwise None
|
||||||
fn check_version(r: Release) -> Option<Release> {
|
fn check_version(r: Release) -> Option<Release> {
|
||||||
debug!("got version from GitHub: {}", r.version);
|
debug!("got version from GitHub: {}", r.version);
|
||||||
@@ -212,4 +238,9 @@ mod test {
|
|||||||
assert!(!Update::is_new_version_higher("0.9.9", "0.10.1"));
|
assert!(!Update::is_new_version_higher("0.9.9", "0.10.1"));
|
||||||
assert!(!Update::is_new_version_higher("0.10.9", "0.11.0"));
|
assert!(!Update::is_new_version_higher("0.10.9", "0.11.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_should_check_whether_github_api_is_reachable() {
|
||||||
|
assert!(Update::check_github_api_reachable().is_ok());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ use std::string::ToString;
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::keys::filestorage::FileStorage;
|
use super::keys::filestorage::FileStorage;
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
use super::keys::keyringstorage::KeyringStorage;
|
use super::keys::keyringstorage::KeyringStorage;
|
||||||
use super::keys::{KeyStorage, KeyStorageError};
|
use super::keys::{KeyStorage, KeyStorageError};
|
||||||
// Local
|
// Local
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
bookmarks::{Bookmark, UserHosts},
|
bookmarks::{Bookmark, UserHosts},
|
||||||
serialization::{deserialize, serialize, SerializerError, SerializerErrorKind},
|
serialization::{SerializerError, SerializerErrorKind, deserialize, serialize},
|
||||||
};
|
};
|
||||||
use crate::filetransfer::FileTransferParams;
|
use crate::filetransfer::FileTransferParams;
|
||||||
use crate::utils::crypto;
|
use crate::utils::crypto;
|
||||||
@@ -39,42 +38,13 @@ impl BookmarksClient {
|
|||||||
bookmarks_file: &Path,
|
bookmarks_file: &Path,
|
||||||
storage_path: &Path,
|
storage_path: &Path,
|
||||||
recents_size: usize,
|
recents_size: usize,
|
||||||
|
keyring: bool,
|
||||||
) -> Result<BookmarksClient, SerializerError> {
|
) -> Result<BookmarksClient, SerializerError> {
|
||||||
// Create default hosts
|
// Create default hosts
|
||||||
let default_hosts: UserHosts = UserHosts::default();
|
let default_hosts: UserHosts = UserHosts::default();
|
||||||
debug!("Setting up bookmarks client...");
|
debug!("Setting up bookmarks client...");
|
||||||
// Make a key storage (with-keyring)
|
// Get key storage
|
||||||
#[cfg(feature = "with-keyring")]
|
let (key_storage, service_id) = Self::keyring(storage_path, keyring);
|
||||||
let (key_storage, service_id): (Box<dyn KeyStorage>, &str) = {
|
|
||||||
debug!("Setting up KeyStorage");
|
|
||||||
let username: String = whoami::username();
|
|
||||||
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
|
||||||
// Check if keyring storage is supported
|
|
||||||
#[cfg(not(test))]
|
|
||||||
let app_name: &str = "termscp";
|
|
||||||
#[cfg(test)] // NOTE: when running test, add -test
|
|
||||||
let app_name: &str = "termscp-test";
|
|
||||||
match storage.is_supported() {
|
|
||||||
true => {
|
|
||||||
debug!("Using KeyringStorage");
|
|
||||||
(Box::new(storage), app_name)
|
|
||||||
}
|
|
||||||
false => {
|
|
||||||
warn!("KeyringStorage is not supported; using FileStorage");
|
|
||||||
(Box::new(FileStorage::new(storage_path)), "bookmarks")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Make a key storage (wno-keyring)
|
|
||||||
#[cfg(not(feature = "with-keyring"))]
|
|
||||||
let (key_storage, service_id): (Box<dyn KeyStorage>, &str) = {
|
|
||||||
#[cfg(not(test))]
|
|
||||||
let app_name: &str = "bookmarks";
|
|
||||||
#[cfg(test)] // NOTE: when running test, add -test
|
|
||||||
let app_name: &str = "bookmarks-test";
|
|
||||||
debug!("Using FileStorage");
|
|
||||||
(Box::new(FileStorage::new(storage_path)), app_name)
|
|
||||||
};
|
|
||||||
// Load key
|
// Load key
|
||||||
let key: String = match key_storage.get_key(service_id) {
|
let key: String = match key_storage.get_key(service_id) {
|
||||||
Ok(k) => {
|
Ok(k) => {
|
||||||
@@ -130,6 +100,37 @@ impl BookmarksClient {
|
|||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the key storage
|
||||||
|
fn keyring(storage_path: &Path, keyring: bool) -> (Box<dyn KeyStorage>, &'static str) {
|
||||||
|
if keyring && cfg!(feature = "keyring") {
|
||||||
|
debug!("Setting up KeyStorage");
|
||||||
|
let username: String = whoami::username();
|
||||||
|
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
||||||
|
// Check if keyring storage is supported
|
||||||
|
#[cfg(not(test))]
|
||||||
|
let app_name: &str = "termscp";
|
||||||
|
#[cfg(test)] // NOTE: when running test, add -test
|
||||||
|
let app_name: &str = "termscp-test";
|
||||||
|
match storage.is_supported() {
|
||||||
|
true => {
|
||||||
|
debug!("Using KeyringStorage");
|
||||||
|
(Box::new(storage), app_name)
|
||||||
|
}
|
||||||
|
false => {
|
||||||
|
warn!("KeyringStorage is not supported; using FileStorage");
|
||||||
|
(Box::new(FileStorage::new(storage_path)), "bookmarks")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#[cfg(not(test))]
|
||||||
|
let app_name: &str = "bookmarks";
|
||||||
|
#[cfg(test)] // NOTE: when running test, add -test
|
||||||
|
let app_name: &str = "bookmarks-test";
|
||||||
|
debug!("Using FileStorage");
|
||||||
|
(Box::new(FileStorage::new(storage_path)), app_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Iterate over bookmarks keys
|
/// Iterate over bookmarks keys
|
||||||
pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ {
|
pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ {
|
||||||
Box::new(self.hosts.bookmarks.keys())
|
Box::new(self.hosts.bookmarks.keys())
|
||||||
@@ -389,7 +390,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let client: BookmarksClient =
|
let client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Verify client
|
// Verify client
|
||||||
assert_eq!(client.hosts.bookmarks.len(), 0);
|
assert_eq!(client.hosts.bookmarks.len(), 0);
|
||||||
assert_eq!(client.hosts.recents.len(), 0);
|
assert_eq!(client.hosts.recents.len(), 0);
|
||||||
@@ -405,7 +406,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add some bookmarks
|
// Add some bookmarks
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -430,7 +431,7 @@ mod tests {
|
|||||||
let key: String = client.key.clone();
|
let key: String = client.key.clone();
|
||||||
// Re-initialize a client
|
// Re-initialize a client
|
||||||
let client: BookmarksClient =
|
let client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Verify it loaded parameters correctly
|
// Verify it loaded parameters correctly
|
||||||
assert_eq!(client.key, key);
|
assert_eq!(client.key, key);
|
||||||
let bookmark = ftparams_to_tup(client.get_bookmark("raspberry").unwrap());
|
let bookmark = ftparams_to_tup(client.get_bookmark("raspberry").unwrap());
|
||||||
@@ -453,7 +454,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_bookmark("my-bucket", make_s3_ftparams(), true);
|
client.add_bookmark("my-bucket", make_s3_ftparams(), true);
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -473,7 +474,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_bookmark("my-bucket", make_s3_ftparams(), false);
|
client.add_bookmark("my-bucket", make_s3_ftparams(), false);
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -494,7 +495,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_recent(make_s3_ftparams());
|
client.add_recent(make_s3_ftparams());
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -517,7 +518,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -568,7 +569,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"",
|
"",
|
||||||
@@ -589,7 +590,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -617,7 +618,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
FileTransferProtocol::Sftp,
|
FileTransferProtocol::Sftp,
|
||||||
@@ -653,7 +654,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
FileTransferProtocol::Sftp,
|
FileTransferProtocol::Sftp,
|
||||||
@@ -680,7 +681,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 2).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 2, true).unwrap();
|
||||||
// Add recent, wait 1 second for each one (cause the name depends on time)
|
// Add recent, wait 1 second for each one (cause the name depends on time)
|
||||||
// 1
|
// 1
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
@@ -748,7 +749,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"",
|
"",
|
||||||
@@ -769,7 +770,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
client.key = "MYSUPERSECRETKEY".to_string();
|
client.key = "MYSUPERSECRETKEY".to_string();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client.decrypt_str("z4Z6LpcpYqBW4+bkIok+5A==").ok().unwrap(),
|
client.decrypt_str("z4Z6LpcpYqBW4+bkIok+5A==").ok().unwrap(),
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
// Locals
|
// Locals
|
||||||
// Ext
|
// Ext
|
||||||
use std::fs::{create_dir, remove_file, File, OpenOptions};
|
use std::fs::{File, OpenOptions, create_dir, remove_file};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
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 crate::config::params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD};
|
use crate::config::params::{DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD, UserConfig};
|
||||||
use crate::config::serialization::{deserialize, serialize, SerializerError, SerializerErrorKind};
|
use crate::config::serialization::{SerializerError, SerializerErrorKind, deserialize, serialize};
|
||||||
use crate::explorer::GroupDirs;
|
use crate::explorer::GroupDirs;
|
||||||
use crate::filetransfer::FileTransferProtocol;
|
use crate::filetransfer::FileTransferProtocol;
|
||||||
|
|
||||||
@@ -153,10 +153,7 @@ impl ConfigClient {
|
|||||||
// Convert string to `GroupDirs`
|
// Convert string to `GroupDirs`
|
||||||
match &self.config.user_interface.group_dirs {
|
match &self.config.user_interface.group_dirs {
|
||||||
None => None,
|
None => None,
|
||||||
Some(val) => match GroupDirs::from_str(val.as_str()) {
|
Some(val) => GroupDirs::from_str(val.as_str()).ok(),
|
||||||
Ok(val) => Some(val),
|
|
||||||
Err(_) => None,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,9 +477,11 @@ mod tests {
|
|||||||
// Change some stuff
|
// Change some stuff
|
||||||
client.set_text_editor(PathBuf::from("/usr/bin/vim"));
|
client.set_text_editor(PathBuf::from("/usr/bin/vim"));
|
||||||
client.set_default_protocol(FileTransferProtocol::Scp);
|
client.set_default_protocol(FileTransferProtocol::Scp);
|
||||||
assert!(client
|
assert!(
|
||||||
.add_ssh_key("192.168.1.31", "pi", "piroporopero")
|
client
|
||||||
.is_ok());
|
.add_ssh_key("192.168.1.31", "pi", "piroporopero")
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
assert!(client.write_config().is_ok());
|
assert!(client.write_config().is_ok());
|
||||||
// Istantiate a new client
|
// Istantiate a new client
|
||||||
let client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
let client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
||||||
@@ -678,9 +677,11 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
// Add a new key
|
// Add a new key
|
||||||
let rsa_key: String = get_sample_rsa_key();
|
let rsa_key: String = get_sample_rsa_key();
|
||||||
assert!(client
|
assert!(
|
||||||
.add_ssh_key("192.168.1.31", "pi", rsa_key.as_str())
|
client
|
||||||
.is_ok());
|
.add_ssh_key("192.168.1.31", "pi", rsa_key.as_str())
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// Iterate keys
|
// Iterate keys
|
||||||
for key in client.iter_ssh_keys() {
|
for key in client.iter_ssh_keys() {
|
||||||
let host: SshHost = client.get_ssh_key(key).ok().unwrap().unwrap();
|
let host: SshHost = client.get_ssh_key(key).ok().unwrap().unwrap();
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ impl KeyStorage for KeyringStorage {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use whoami::username;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(feature = "isolated-tests"))]
|
#[cfg(all(not(feature = "github-actions"), not(feature = "isolated-tests")))]
|
||||||
fn test_system_keys_keyringstorage() {
|
fn test_system_keys_keyringstorage() {
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use whoami::username;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
let username: String = username();
|
let username: String = username();
|
||||||
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
||||||
assert!(storage.is_supported());
|
assert!(storage.is_supported());
|
||||||
|
|||||||
@@ -4,29 +4,24 @@
|
|||||||
|
|
||||||
// Storages
|
// Storages
|
||||||
pub mod filestorage;
|
pub mod filestorage;
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
pub mod keyringstorage;
|
pub mod keyringstorage;
|
||||||
// ext
|
// ext
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
use keyring::Error as KeyringError;
|
use keyring::Error as KeyringError;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// defines the error type for the `KeyStorage`
|
/// defines the error type for the `KeyStorage`
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum KeyStorageError {
|
pub enum KeyStorageError {
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
#[error("Key has a bad syntax")]
|
#[error("Key has a bad syntax")]
|
||||||
BadSytax,
|
BadSytax,
|
||||||
#[error("Provider service error")]
|
#[error("Provider service error")]
|
||||||
ProviderError,
|
ProviderError,
|
||||||
#[error("No such key")]
|
#[error("No such key")]
|
||||||
NoSuchKey,
|
NoSuchKey,
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
#[error("keyring error: {0}")]
|
#[error("keyring error: {0}")]
|
||||||
KeyringError(KeyringError),
|
KeyringError(KeyringError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
impl From<KeyringError> for KeyStorageError {
|
impl From<KeyringError> for KeyStorageError {
|
||||||
fn from(e: KeyringError) -> Self {
|
fn from(e: KeyringError) -> Self {
|
||||||
Self::KeyringError(e)
|
Self::KeyringError(e)
|
||||||
@@ -58,7 +53,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_keys_mod_errors() {
|
fn test_system_keys_mod_errors() {
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
KeyStorageError::BadSytax.to_string(),
|
KeyStorageError::BadSytax.to_string(),
|
||||||
String::from("Key has a bad syntax")
|
String::from("Key has a bad syntax")
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init(level: LogLevel) -> Result<(), String> {
|
|||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
return Err(String::from(
|
return Err(String::from(
|
||||||
"This system doesn't seem to support CACHE_DIR",
|
"This system doesn't seem to support CACHE_DIR",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
Err(err) => return Err(err),
|
Err(err) => return Err(err),
|
||||||
};
|
};
|
||||||
@@ -29,6 +29,9 @@ pub fn init(level: LogLevel) -> Result<(), String> {
|
|||||||
.set_time_format_rfc3339()
|
.set_time_format_rfc3339()
|
||||||
.add_filter_allow_str("termscp")
|
.add_filter_allow_str("termscp")
|
||||||
.add_filter_allow_str("remotefs")
|
.add_filter_allow_str("remotefs")
|
||||||
|
.add_filter_allow_str("kube")
|
||||||
|
.add_filter_allow_str("suppaftp")
|
||||||
|
.add_filter_allow_str("pavao")
|
||||||
.build();
|
.build();
|
||||||
// Make logger
|
// Make logger
|
||||||
WriteLogger::init(level, config, file).map_err(|e| format!("Failed to initialize logger: {e}"))
|
WriteLogger::init(level, config, file).map_err(|e| format!("Failed to initialize logger: {e}"))
|
||||||
|
|||||||
@@ -44,15 +44,29 @@ impl SshKeyStorage {
|
|||||||
/// Resolve host via ssh2 configuration
|
/// Resolve host via ssh2 configuration
|
||||||
fn resolve_host_in_ssh2_configuration(&self, host: &str) -> Option<PathBuf> {
|
fn resolve_host_in_ssh2_configuration(&self, host: &str) -> Option<PathBuf> {
|
||||||
self.ssh_config.as_ref().and_then(|x| {
|
self.ssh_config.as_ref().and_then(|x| {
|
||||||
let key = x
|
x.query(host)
|
||||||
.query(host)
|
|
||||||
.identity_file
|
.identity_file
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|x| x.first().cloned());
|
.and_then(|x| x.first().cloned())
|
||||||
|
|
||||||
key
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get default SSH identity files that SSH would normally try
|
||||||
|
/// This mirrors the behavior of OpenSSH client
|
||||||
|
fn get_default_identity_files(&self) -> Vec<PathBuf> {
|
||||||
|
let Some(home_dir) = dirs::home_dir() else {
|
||||||
|
return Vec::new();
|
||||||
|
};
|
||||||
|
|
||||||
|
let ssh_dir = home_dir.join(".ssh");
|
||||||
|
|
||||||
|
// Standard SSH identity files in order of preference (matches OpenSSH)
|
||||||
|
["id_ed25519", "id_ecdsa", "id_rsa", "id_dsa"]
|
||||||
|
.iter()
|
||||||
|
.map(|key_name| ssh_dir.join(key_name))
|
||||||
|
.filter(|key_path| key_path.exists())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SshKeyStorageTrait for SshKeyStorage {
|
impl SshKeyStorageTrait for SshKeyStorage {
|
||||||
@@ -66,9 +80,13 @@ impl SshKeyStorageTrait for SshKeyStorage {
|
|||||||
username, host
|
username, host
|
||||||
);
|
);
|
||||||
// otherwise search in configuration
|
// otherwise search in configuration
|
||||||
let key = self.resolve_host_in_ssh2_configuration(host)?;
|
if let Some(key) = self.resolve_host_in_ssh2_configuration(host) {
|
||||||
debug!("Found key in SSH config for {host}: {}", key.display());
|
debug!("Found key in SSH config for {host}: {}", key.display());
|
||||||
Some(key)
|
return Some(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// As a final fallback, try default SSH identity files (like regular ssh does)
|
||||||
|
self.get_default_identity_files().into_iter().next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +141,11 @@ mod tests {
|
|||||||
.ok()
|
.ok()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// Add ssh key
|
// Add ssh key
|
||||||
assert!(client
|
assert!(
|
||||||
.add_ssh_key("192.168.1.31", "pi", "piroporopero")
|
client
|
||||||
.is_ok());
|
.add_ssh_key("192.168.1.31", "pi", "piroporopero")
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// Create ssh key storage
|
// Create ssh key storage
|
||||||
let storage: SshKeyStorage = SshKeyStorage::from(&client);
|
let storage: SshKeyStorage = SshKeyStorage::from(&client);
|
||||||
// Verify key exists
|
// Verify key exists
|
||||||
@@ -135,13 +155,21 @@ mod tests {
|
|||||||
*storage.resolve("192.168.1.31", "pi").unwrap(),
|
*storage.resolve("192.168.1.31", "pi").unwrap(),
|
||||||
exp_key_path
|
exp_key_path
|
||||||
);
|
);
|
||||||
// Verify unexisting key
|
// Verify key is a default key or none
|
||||||
assert!(storage.resolve("deskichup", "veeso").is_none());
|
let default_keys: Vec<PathBuf> = storage.get_default_identity_files().into_iter().collect();
|
||||||
|
|
||||||
|
if let Some(key) = storage.resolve("deskichup", "veeso") {
|
||||||
|
assert!(default_keys.contains(&key));
|
||||||
|
} else {
|
||||||
|
assert!(default_keys.is_empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sould_resolve_key_from_ssh2_config() {
|
fn sould_resolve_key_from_ssh2_config() {
|
||||||
let rsa_key = test_helpers::create_sample_file_with_content("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDErJhQxEI0+VvhlXVUyh+vMCm7aXfCA/g633AG8ezD/5EylwchtAr2JCoBWnxn4zV8nI9dMqOgm0jO4IsXpKOjQojv+0VOH7I+cDlBg0tk4hFlvyyS6YviDAfDDln3jYUM+5QNDfQLaZlH2WvcJ3mkDxLVlI9MBX1BAeSmChLxwAvxALp2ncImNQLzDO9eHcig3dtMrEKkzXQowRW5Y7eUzg2+vvVq4H2DOjWwUndvB5sJkhEfTUVE7ID8ZdGJo60kUb/02dZYj+IbkAnMCsqktk0cg/4XFX82hEfRYFeb1arkysFisPU1DOb6QielL/axeTebVplaouYcXY0pFdJt root@8c50fd4c345a");
|
let rsa_key = test_helpers::create_sample_file_with_content(
|
||||||
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDErJhQxEI0+VvhlXVUyh+vMCm7aXfCA/g633AG8ezD/5EylwchtAr2JCoBWnxn4zV8nI9dMqOgm0jO4IsXpKOjQojv+0VOH7I+cDlBg0tk4hFlvyyS6YviDAfDDln3jYUM+5QNDfQLaZlH2WvcJ3mkDxLVlI9MBX1BAeSmChLxwAvxALp2ncImNQLzDO9eHcig3dtMrEKkzXQowRW5Y7eUzg2+vvVq4H2DOjWwUndvB5sJkhEfTUVE7ID8ZdGJo60kUb/02dZYj+IbkAnMCsqktk0cg/4XFX82hEfRYFeb1arkysFisPU1DOb6QielL/axeTebVplaouYcXY0pFdJt root@8c50fd4c345a",
|
||||||
|
);
|
||||||
let ssh_config_file = test_helpers::create_sample_file_with_content(format!(
|
let ssh_config_file = test_helpers::create_sample_file_with_content(format!(
|
||||||
r#"
|
r#"
|
||||||
Host test
|
Host test
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ 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::serialization::{SerializerError, SerializerErrorKind, deserialize, serialize};
|
||||||
use crate::config::themes::Theme;
|
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
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ mod change;
|
|||||||
// -- export
|
// -- export
|
||||||
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::{Receiver, RecvTimeoutError, channel};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub use change::FsChange;
|
pub use change::FsChange;
|
||||||
@@ -245,9 +245,11 @@ mod test {
|
|||||||
fn should_watch_path() {
|
fn should_watch_path() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// check if in paths
|
// check if in paths
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
watcher.paths.get(tempdir.path()).unwrap(),
|
watcher.paths.get(tempdir.path()).unwrap(),
|
||||||
@@ -261,16 +263,20 @@ mod test {
|
|||||||
fn should_not_watch_path_if_subdir_of_watched_path() {
|
fn should_not_watch_path_if_subdir_of_watched_path() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// watch subdir
|
// watch subdir
|
||||||
let mut subdir = tempdir.path().to_path_buf();
|
let mut subdir = tempdir.path().to_path_buf();
|
||||||
subdir.push("abc/def");
|
subdir.push("abc/def");
|
||||||
// should return already watched
|
// should return already watched
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(subdir.as_path(), Path::new("/tmp/test/abc/def"))
|
watcher
|
||||||
.is_err());
|
.watch(subdir.as_path(), Path::new("/tmp/test/abc/def"))
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
// close tempdir
|
// close tempdir
|
||||||
assert!(tempdir.close().is_ok());
|
assert!(tempdir.close().is_ok());
|
||||||
}
|
}
|
||||||
@@ -279,9 +285,11 @@ mod test {
|
|||||||
fn should_unwatch_path() {
|
fn should_unwatch_path() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// unwatch
|
// unwatch
|
||||||
assert!(watcher.unwatch(tempdir.path()).is_ok());
|
assert!(watcher.unwatch(tempdir.path()).is_ok());
|
||||||
assert!(watcher.paths.get(tempdir.path()).is_none());
|
assert!(watcher.paths.get(tempdir.path()).is_none());
|
||||||
@@ -293,9 +301,11 @@ mod test {
|
|||||||
fn should_unwatch_path_when_subdir() {
|
fn should_unwatch_path_when_subdir() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// unwatch
|
// unwatch
|
||||||
let mut subdir = tempdir.path().to_path_buf();
|
let mut subdir = tempdir.path().to_path_buf();
|
||||||
subdir.push("abc/def");
|
subdir.push("abc/def");
|
||||||
@@ -318,9 +328,11 @@ mod test {
|
|||||||
fn should_tell_whether_path_is_watched() {
|
fn should_tell_whether_path_is_watched() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
assert_eq!(watcher.watched(tempdir.path()), true);
|
assert_eq!(watcher.watched(tempdir.path()), true);
|
||||||
let mut subdir = tempdir.path().to_path_buf();
|
let mut subdir = tempdir.path().to_path_buf();
|
||||||
subdir.push("abc/def");
|
subdir.push("abc/def");
|
||||||
@@ -336,9 +348,11 @@ mod test {
|
|||||||
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
|
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// create file
|
// create file
|
||||||
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
|
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
|
||||||
// wait
|
// wait
|
||||||
@@ -362,9 +376,11 @@ mod test {
|
|||||||
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
|
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
// create file
|
// create file
|
||||||
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
|
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
|
||||||
std::thread::sleep(Duration::from_millis(500));
|
std::thread::sleep(Duration::from_millis(500));
|
||||||
@@ -424,9 +440,11 @@ mod test {
|
|||||||
fn should_poll_nothing() {
|
fn should_poll_nothing() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
let tempdir = TempDir::new().unwrap();
|
let tempdir = TempDir::new().unwrap();
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(tempdir.path(), Path::new("/tmp/test"))
|
watcher
|
||||||
.is_ok());
|
.watch(tempdir.path(), Path::new("/tmp/test"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
assert!(watcher.poll().ok().unwrap().is_none());
|
assert!(watcher.poll().ok().unwrap().is_none());
|
||||||
// close tempdir
|
// close tempdir
|
||||||
assert!(tempdir.close().is_ok());
|
assert!(tempdir.close().is_ok());
|
||||||
@@ -437,9 +455,11 @@ mod test {
|
|||||||
fn should_get_watched_paths() {
|
fn should_get_watched_paths() {
|
||||||
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
|
||||||
assert!(watcher.watch(Path::new("/tmp"), Path::new("/tmp")).is_ok());
|
assert!(watcher.watch(Path::new("/tmp"), Path::new("/tmp")).is_ok());
|
||||||
assert!(watcher
|
assert!(
|
||||||
.watch(Path::new("/home"), Path::new("/home"))
|
watcher
|
||||||
.is_ok());
|
.watch(Path::new("/home"), Path::new("/home"))
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
let mut watched_paths = watcher.watched_paths();
|
let mut watched_paths = watcher.watched_paths();
|
||||||
watched_paths.sort();
|
watched_paths.sort();
|
||||||
assert_eq!(watched_paths, vec![Path::new("/home"), Path::new("/tmp")]);
|
assert_eq!(watched_paths, vec![Path::new("/home"), Path::new("/tmp")]);
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
// Locals
|
// Locals
|
||||||
use super::{AuthActivity, FileTransferParams, FormTab, HostBridgeProtocol};
|
use super::{AuthActivity, FileTransferParams, FormTab, HostBridgeProtocol};
|
||||||
|
use crate::filetransfer::HostBridgeParams;
|
||||||
use crate::filetransfer::params::{
|
use crate::filetransfer::params::{
|
||||||
AwsS3Params, GenericProtocolParams, KubeProtocolParams, ProtocolParams, SmbParams,
|
AwsS3Params, GenericProtocolParams, KubeProtocolParams, ProtocolParams, SmbParams,
|
||||||
WebDAVProtocolParams,
|
WebDAVProtocolParams,
|
||||||
};
|
};
|
||||||
use crate::filetransfer::HostBridgeParams;
|
|
||||||
|
|
||||||
impl AuthActivity {
|
impl AuthActivity {
|
||||||
/// Delete bookmark
|
/// Delete bookmark
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ impl DeleteBookmarkPopup {
|
|||||||
.color(color)
|
.color(color)
|
||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.value(1)
|
.value(1)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
@@ -265,7 +265,7 @@ impl DeleteRecentPopup {
|
|||||||
.color(color)
|
.color(color)
|
||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.value(1)
|
.value(1)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
@@ -337,7 +337,7 @@ impl BookmarkSavePassword {
|
|||||||
.sides(BorderSides::BOTTOM | BorderSides::LEFT | BorderSides::RIGHT)
|
.sides(BorderSides::BOTTOM | BorderSides::LEFT | BorderSides::RIGHT)
|
||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.value(0)
|
.value(0)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
|
|||||||
@@ -10,14 +10,13 @@ use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
|
|||||||
|
|
||||||
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
|
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
|
||||||
use crate::ui::activities::auth::{
|
use crate::ui::activities::auth::{
|
||||||
FormTab, HostBridgeProtocol, UiAuthFormMsg, HOST_BRIDGE_RADIO_PROTOCOL_FTP,
|
FormTab, HOST_BRIDGE_RADIO_PROTOCOL_FTP, HOST_BRIDGE_RADIO_PROTOCOL_FTPS,
|
||||||
HOST_BRIDGE_RADIO_PROTOCOL_FTPS, HOST_BRIDGE_RADIO_PROTOCOL_KUBE,
|
HOST_BRIDGE_RADIO_PROTOCOL_KUBE, HOST_BRIDGE_RADIO_PROTOCOL_LOCALHOST,
|
||||||
HOST_BRIDGE_RADIO_PROTOCOL_LOCALHOST, HOST_BRIDGE_RADIO_PROTOCOL_S3,
|
HOST_BRIDGE_RADIO_PROTOCOL_S3, HOST_BRIDGE_RADIO_PROTOCOL_SCP, HOST_BRIDGE_RADIO_PROTOCOL_SFTP,
|
||||||
HOST_BRIDGE_RADIO_PROTOCOL_SCP, HOST_BRIDGE_RADIO_PROTOCOL_SFTP,
|
HOST_BRIDGE_RADIO_PROTOCOL_SMB, HOST_BRIDGE_RADIO_PROTOCOL_WEBDAV, HostBridgeProtocol,
|
||||||
HOST_BRIDGE_RADIO_PROTOCOL_SMB, HOST_BRIDGE_RADIO_PROTOCOL_WEBDAV, REMOTE_RADIO_PROTOCOL_FTP,
|
REMOTE_RADIO_PROTOCOL_FTP, REMOTE_RADIO_PROTOCOL_FTPS, REMOTE_RADIO_PROTOCOL_KUBE,
|
||||||
REMOTE_RADIO_PROTOCOL_FTPS, REMOTE_RADIO_PROTOCOL_KUBE, REMOTE_RADIO_PROTOCOL_S3,
|
REMOTE_RADIO_PROTOCOL_S3, REMOTE_RADIO_PROTOCOL_SCP, REMOTE_RADIO_PROTOCOL_SFTP,
|
||||||
REMOTE_RADIO_PROTOCOL_SCP, REMOTE_RADIO_PROTOCOL_SFTP, REMOTE_RADIO_PROTOCOL_SMB,
|
REMOTE_RADIO_PROTOCOL_SMB, REMOTE_RADIO_PROTOCOL_WEBDAV, UiAuthFormMsg,
|
||||||
REMOTE_RADIO_PROTOCOL_WEBDAV,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// -- protocol
|
// -- protocol
|
||||||
@@ -37,9 +36,9 @@ impl RemoteProtocolRadio {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(if cfg!(smb) {
|
.choices(if cfg!(smb) {
|
||||||
&["SFTP", "SCP", "FTP", "FTPS", "S3", "Kube", "WebDAV", "SMB"]
|
vec!["SFTP", "SCP", "FTP", "FTPS", "S3", "Kube", "WebDAV", "SMB"].into_iter()
|
||||||
} else {
|
} else {
|
||||||
&["SFTP", "SCP", "FTP", "FTPS", "S3", "Kube", "WebDAV"]
|
vec!["SFTP", "SCP", "FTP", "FTPS", "S3", "Kube", "WebDAV"].into_iter()
|
||||||
})
|
})
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
@@ -93,10 +92,10 @@ impl Component<Msg, NoUserEvent> for RemoteProtocolRadio {
|
|||||||
code: Key::Down, ..
|
code: Key::Down, ..
|
||||||
}) => return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ProtocolBlurDown))),
|
}) => return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ProtocolBlurDown))),
|
||||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||||
return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ProtocolBlurUp)))
|
return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ProtocolBlurUp)));
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||||
return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ParamsFormBlur)))
|
return Some(Msg::Ui(UiMsg::Remote(UiAuthFormMsg::ParamsFormBlur)));
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::BackTab, ..
|
code: Key::BackTab, ..
|
||||||
@@ -127,7 +126,7 @@ impl HostBridgeProtocolRadio {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(if cfg!(smb) {
|
.choices(if cfg!(smb) {
|
||||||
&[
|
vec![
|
||||||
"Localhost",
|
"Localhost",
|
||||||
"SFTP",
|
"SFTP",
|
||||||
"SCP",
|
"SCP",
|
||||||
@@ -138,8 +137,9 @@ impl HostBridgeProtocolRadio {
|
|||||||
"WebDAV",
|
"WebDAV",
|
||||||
"SMB",
|
"SMB",
|
||||||
]
|
]
|
||||||
|
.into_iter()
|
||||||
} else {
|
} else {
|
||||||
&[
|
vec![
|
||||||
"Localhost",
|
"Localhost",
|
||||||
"SFTP",
|
"SFTP",
|
||||||
"SCP",
|
"SCP",
|
||||||
@@ -149,6 +149,7 @@ impl HostBridgeProtocolRadio {
|
|||||||
"Kube",
|
"Kube",
|
||||||
"WebDAV",
|
"WebDAV",
|
||||||
]
|
]
|
||||||
|
.into_iter()
|
||||||
})
|
})
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
@@ -228,10 +229,10 @@ impl Component<Msg, NoUserEvent> for HostBridgeProtocolRadio {
|
|||||||
code: Key::Down, ..
|
code: Key::Down, ..
|
||||||
}) => return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurDown))),
|
}) => return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurDown))),
|
||||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||||
return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurUp)))
|
return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurUp)));
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||||
return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ParamsFormBlur)))
|
return Some(Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::ParamsFormBlur)));
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::BackTab, ..
|
code: Key::BackTab, ..
|
||||||
@@ -650,7 +651,7 @@ impl RadioS3NewPathStyle {
|
|||||||
.color(color)
|
.color(color)
|
||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.title("New path style", Alignment::Left)
|
.title("New path style", Alignment::Left)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ impl ErrorPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ impl InfoPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ impl WaitPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ impl WindowSizeError {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(
|
.text([TextSpan::from(
|
||||||
"termscp requires at least 24 lines of height to run",
|
"termscp requires at least 24 lines of height to run",
|
||||||
)])
|
)])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
@@ -163,7 +163,7 @@ impl QuitPopup {
|
|||||||
.foreground(color)
|
.foreground(color)
|
||||||
.title("Quit termscp?", Alignment::Center)
|
.title("Quit termscp?", Alignment::Center)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.choices(&["Yes", "No"]),
|
.choices(["Yes", "No"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ impl InstallUpdatePopup {
|
|||||||
.foreground(color)
|
.foreground(color)
|
||||||
.title("Install update?", Alignment::Center)
|
.title("Install update?", Alignment::Center)
|
||||||
.rewind(true)
|
.rewind(true)
|
||||||
.choices(&["Yes", "No"]),
|
.choices(["Yes", "No"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,13 +296,7 @@ impl ReleaseNotes {
|
|||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.title("Release notes", Alignment::Center)
|
.title("Release notes", Alignment::Center)
|
||||||
.text_rows(
|
.text_rows(notes.lines().map(TextSpan::from)),
|
||||||
notes
|
|
||||||
.lines()
|
|
||||||
.map(TextSpan::from)
|
|
||||||
.collect::<Vec<TextSpan>>()
|
|
||||||
.as_slice(),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub struct NewVersionDisclaimer {
|
|||||||
impl NewVersionDisclaimer {
|
impl NewVersionDisclaimer {
|
||||||
pub fn new(new_version: &str, color: Color) -> Self {
|
pub fn new(new_version: &str, color: Color) -> Self {
|
||||||
Self {
|
Self {
|
||||||
component: Span::default().foreground(color).spans(&[
|
component: Span::default().foreground(color).spans([
|
||||||
TextSpan::from("termscp "),
|
TextSpan::from("termscp "),
|
||||||
TextSpan::new(new_version).underlined().bold(),
|
TextSpan::new(new_version).underlined().bold(),
|
||||||
TextSpan::from(
|
TextSpan::from(
|
||||||
@@ -91,7 +91,7 @@ pub struct HelpFooter {
|
|||||||
impl HelpFooter {
|
impl HelpFooter {
|
||||||
pub fn new(key_color: Color) -> Self {
|
pub fn new(key_color: Color) -> Self {
|
||||||
Self {
|
Self {
|
||||||
component: Span::default().spans(&[
|
component: Span::default().spans([
|
||||||
TextSpan::from("<F1|CTRL+H>").bold().fg(key_color),
|
TextSpan::from("<F1|CTRL+H>").bold().fg(key_color),
|
||||||
TextSpan::from(" Help "),
|
TextSpan::from(" Help "),
|
||||||
TextSpan::from("<CTRL+C>").bold().fg(key_color),
|
TextSpan::from("<CTRL+C>").bold().fg(key_color),
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use super::{AuthActivity, FileTransferParams, FileTransferProtocol, FormTab, HostBridgeProtocol};
|
use super::{AuthActivity, FileTransferParams, FileTransferProtocol, FormTab, HostBridgeProtocol};
|
||||||
use crate::filetransfer::params::ProtocolParams;
|
|
||||||
use crate::filetransfer::HostBridgeParams;
|
use crate::filetransfer::HostBridgeParams;
|
||||||
|
use crate::filetransfer::params::ProtocolParams;
|
||||||
use crate::system::auto_update::{Release, Update, UpdateStatus};
|
use crate::system::auto_update::{Release, Update, UpdateStatus};
|
||||||
use crate::system::notifications::Notification;
|
use crate::system::notifications::Notification;
|
||||||
|
|
||||||
@@ -83,8 +83,16 @@ impl AuthActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn collect_localhost_host_params(&self) -> Result<HostBridgeParams, &'static str> {
|
fn collect_localhost_host_params(&self) -> Result<HostBridgeParams, &'static str> {
|
||||||
|
// get remote local path
|
||||||
|
let remote_local_path = self.get_input_local_directory(FormTab::Remote);
|
||||||
|
|
||||||
|
// Local path is:
|
||||||
|
// - the input local path if set
|
||||||
|
// - the remote local path if set
|
||||||
|
// - the current directory if neither is set
|
||||||
let path = self
|
let path = self
|
||||||
.get_input_local_directory(FormTab::HostBridge)
|
.get_input_local_directory(FormTab::HostBridge)
|
||||||
|
.or(remote_local_path)
|
||||||
.unwrap_or_else(|| env::current_dir().unwrap_or_default());
|
.unwrap_or_else(|| env::current_dir().unwrap_or_default());
|
||||||
|
|
||||||
Ok(HostBridgeParams::Localhost(path))
|
Ok(HostBridgeParams::Localhost(path))
|
||||||
@@ -215,10 +223,7 @@ impl AuthActivity {
|
|||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report error
|
// Report error
|
||||||
error!("Failed to get latest version: {}", err);
|
error!("Failed to get latest version: {err}",);
|
||||||
self.mount_error(
|
|
||||||
format!("Could not check for new updates: {err}").as_str(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use tuirealm::application::PollStrategy;
|
|||||||
use tuirealm::listener::EventListenerCfg;
|
use tuirealm::listener::EventListenerCfg;
|
||||||
use tuirealm::{Application, NoUserEvent, Update};
|
use tuirealm::{Application, NoUserEvent, Update};
|
||||||
|
|
||||||
use super::{Activity, Context, ExitReason, CROSSTERM_MAX_POLL};
|
use super::{Activity, CROSSTERM_MAX_POLL, 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;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -167,7 +167,9 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Do not synchronize, disable sync browsing and return
|
// Do not synchronize, disable sync browsing and return
|
||||||
trace!("The user doesn't want to create the directory; disabling synchronized browsing");
|
trace!(
|
||||||
|
"The user doesn't want to create the directory; disabling synchronized browsing"
|
||||||
|
);
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!("Refused to create '{name}'; synchronized browsing disabled"),
|
format!("Refused to create '{name}'; synchronized browsing disabled"),
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ impl FileTransferActivity {
|
|||||||
self.local_copy_file(&entry, dest_path.as_path());
|
self.local_copy_file(&entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Try to copy each file to Input/{FILE_NAME}
|
|
||||||
let base_path: PathBuf = PathBuf::from(input);
|
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, mut dest_path) in entries.into_iter() {
|
||||||
let mut dest_path: PathBuf = base_path.clone();
|
|
||||||
dest_path.push(entry.name());
|
dest_path.push(entry.name());
|
||||||
self.local_copy_file(entry, dest_path.as_path());
|
self.local_copy_file(&entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
@@ -39,14 +40,15 @@ impl FileTransferActivity {
|
|||||||
self.remote_copy_file(entry, dest_path.as_path());
|
self.remote_copy_file(entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Try to copy each file to Input/{FILE_NAME}
|
|
||||||
let base_path: PathBuf = PathBuf::from(input);
|
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.into_iter() {
|
for (entry, mut dest_path) in entries.into_iter() {
|
||||||
let mut dest_path: PathBuf = base_path.clone();
|
|
||||||
dest_path.push(entry.name());
|
dest_path.push(entry.name());
|
||||||
self.remote_copy_file(entry, dest_path.as_path());
|
self.remote_copy_file(entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, _) in entries.iter() {
|
||||||
// Delete file
|
// Delete file
|
||||||
self.local_remove_file(entry);
|
self.local_remove_file(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
@@ -33,10 +37,14 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, _) in entries.iter() {
|
||||||
// Delete file
|
// Delete file
|
||||||
self.remote_remove_file(entry);
|
self.remote_remove_file(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use std::io::Read;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use remotefs::fs::Metadata;
|
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
|
use remotefs::fs::Metadata;
|
||||||
|
|
||||||
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
|
use super::{FileTransferActivity, LogLevel, SelectedFile, TransferPayload};
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ 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() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
// Edit all entries
|
// Edit all entries
|
||||||
@@ -38,12 +38,16 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn action_edit_remote_file(&mut self) {
|
pub(crate) fn action_edit_remote_file(&mut self) {
|
||||||
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
// Edit all entries
|
// Edit all entries
|
||||||
@@ -60,6 +64,10 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Edit a file on localhost
|
/// Edit a file on localhost
|
||||||
@@ -221,10 +229,7 @@ impl FileTransferActivity {
|
|||||||
/// Edit file on remote host
|
/// Edit file on remote host
|
||||||
fn edit_remote_file(&mut self, file: File) -> Result<(), String> {
|
fn edit_remote_file(&mut self, file: File) -> Result<(), String> {
|
||||||
// Create temp file
|
// Create temp file
|
||||||
let tmpfile: PathBuf = match self.download_file_as_temp(&file) {
|
let tmpfile = self.download_file_as_temp(&file)?;
|
||||||
Ok(p) => p,
|
|
||||||
Err(err) => return Err(err),
|
|
||||||
};
|
|
||||||
// Download file
|
// Download file
|
||||||
let file_name = file.name();
|
let file_name = file.name();
|
||||||
let file_path = file.path().to_path_buf();
|
let file_path = file.path().to_path_buf();
|
||||||
@@ -243,7 +248,7 @@ impl FileTransferActivity {
|
|||||||
"Could not stat \"{}\": {}",
|
"Could not stat \"{}\": {}",
|
||||||
tmpfile.as_path().display(),
|
tmpfile.as_path().display(),
|
||||||
err
|
err
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Edit file
|
// Edit file
|
||||||
@@ -256,7 +261,7 @@ impl FileTransferActivity {
|
|||||||
"Could not stat \"{}\": {}",
|
"Could not stat \"{}\": {}",
|
||||||
tmpfile.as_path().display(),
|
tmpfile.as_path().display(),
|
||||||
err
|
err
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Check if file has changed
|
// Check if file has changed
|
||||||
@@ -282,7 +287,7 @@ impl FileTransferActivity {
|
|||||||
"Could not stat \"{}\": {}",
|
"Could not stat \"{}\": {}",
|
||||||
tmpfile.as_path().display(),
|
tmpfile.as_path().display(),
|
||||||
err
|
err
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Send file
|
// Send file
|
||||||
|
|||||||
@@ -2,41 +2,127 @@
|
|||||||
//!
|
//!
|
||||||
//! `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 std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
// locals
|
// locals
|
||||||
use super::{FileTransferActivity, LogLevel};
|
use super::{FileTransferActivity, LogLevel};
|
||||||
|
|
||||||
|
/// Terminal command
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
enum Command {
|
||||||
|
Cd(String),
|
||||||
|
Exec(String),
|
||||||
|
Exit,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for Command {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
let mut parts = s.split_whitespace();
|
||||||
|
match parts.next() {
|
||||||
|
Some("cd") => {
|
||||||
|
if let Some(path) = parts.next() {
|
||||||
|
Ok(Command::Cd(path.to_string()))
|
||||||
|
} else {
|
||||||
|
Err("cd command requires a path".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some("exit") | Some("logout") => Ok(Command::Exit),
|
||||||
|
Some(cmd) => Ok(Command::Exec(cmd.to_string())),
|
||||||
|
None => Err("".to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FileTransferActivity {
|
impl FileTransferActivity {
|
||||||
pub(crate) fn action_local_exec(&mut self, input: String) {
|
pub(crate) fn action_local_exec(&mut self, input: String) {
|
||||||
match self.host_bridge.exec(input.as_str()) {
|
self.action_exec(false, input);
|
||||||
Ok(output) => {
|
}
|
||||||
// Reload files
|
|
||||||
self.log(LogLevel::Info, format!("\"{input}\": {output}"));
|
pub(crate) fn action_remote_exec(&mut self, input: String) {
|
||||||
}
|
self.action_exec(true, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn action_exec(&mut self, remote: bool, cmd: String) {
|
||||||
|
if cmd.is_empty() {
|
||||||
|
self.print_terminal("".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
let cmd = match Command::from_str(&cmd) {
|
||||||
|
Ok(cmd) => cmd,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
self.log(LogLevel::Error, format!("Invalid command: {err}"));
|
||||||
self.log_and_alert(
|
self.print_terminal(err);
|
||||||
LogLevel::Error,
|
return;
|
||||||
format!("Could not execute command \"{input}\": {err}"),
|
}
|
||||||
);
|
};
|
||||||
|
|
||||||
|
match cmd {
|
||||||
|
Command::Cd(path) => {
|
||||||
|
self.action_exec_cd(remote, path);
|
||||||
|
}
|
||||||
|
Command::Exec(executable) => {
|
||||||
|
self.action_exec_executable(remote, executable);
|
||||||
|
}
|
||||||
|
Command::Exit => {
|
||||||
|
self.action_exec_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn action_remote_exec(&mut self, input: String) {
|
fn action_exec_exit(&mut self) {
|
||||||
match self.client.as_mut().exec(input.as_str()) {
|
self.browser.toggle_terminal(false);
|
||||||
Ok((rc, output)) => {
|
self.umount_exec();
|
||||||
// Reload files
|
}
|
||||||
self.log(
|
|
||||||
LogLevel::Info,
|
fn action_exec_cd(&mut self, remote: bool, input: String) {
|
||||||
format!("\"{input}\" (exitcode: {rc}): {output}"),
|
let new_dir = if remote {
|
||||||
);
|
let dir_path: PathBuf =
|
||||||
|
self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path());
|
||||||
|
self.remote_changedir(dir_path.as_path(), true);
|
||||||
|
|
||||||
|
dir_path
|
||||||
|
} else {
|
||||||
|
let dir_path: PathBuf =
|
||||||
|
self.host_bridge_to_abs_path(PathBuf::from(input.as_str()).as_path());
|
||||||
|
self.host_bridge_changedir(dir_path.as_path(), true);
|
||||||
|
|
||||||
|
dir_path
|
||||||
|
};
|
||||||
|
|
||||||
|
self.update_browser_file_list();
|
||||||
|
|
||||||
|
// update prompt and print the new directory
|
||||||
|
self.update_terminal_prompt();
|
||||||
|
self.print_terminal(new_dir.display().to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Execute a [`Command::Exec`] command
|
||||||
|
fn action_exec_executable(&mut self, remote: bool, cmd: String) {
|
||||||
|
let res = if remote {
|
||||||
|
self.client
|
||||||
|
.as_mut()
|
||||||
|
.exec(cmd.as_str())
|
||||||
|
.map(|(_, output)| output)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
} else {
|
||||||
|
self.host_bridge
|
||||||
|
.exec(cmd.as_str())
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
};
|
||||||
|
|
||||||
|
match res {
|
||||||
|
Ok(output) => {
|
||||||
|
self.print_terminal(output);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
self.log(
|
||||||
self.log_and_alert(
|
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not execute command \"{input}\": {err}"),
|
format!("Could not execute command \"{cmd}\": {err}"),
|
||||||
);
|
);
|
||||||
|
self.print_terminal(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use regex::Regex;
|
|||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
use wildmatch::WildMatch;
|
use wildmatch::WildMatch;
|
||||||
|
|
||||||
use crate::ui::activities::filetransfer::lib::browser::FileExplorerTab;
|
|
||||||
use crate::ui::activities::filetransfer::FileTransferActivity;
|
use crate::ui::activities::filetransfer::FileTransferActivity;
|
||||||
|
use crate::ui::activities::filetransfer::lib::browser::FileExplorerTab;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Filter {
|
pub enum Filter {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use super::{File, FileTransferActivity, LogLevel, SelectedFile, TransferOpts, Tr
|
|||||||
impl FileTransferActivity {
|
impl FileTransferActivity {
|
||||||
pub(crate) fn action_find_changedir(&mut self) {
|
pub(crate) fn action_find_changedir(&mut self) {
|
||||||
// Match entry
|
// Match entry
|
||||||
if let SelectedFile::One(entry) = self.get_found_selected_entries() {
|
if let Some(entry) = self.get_found_selected_file() {
|
||||||
debug!("Changedir to: {}", entry.name());
|
debug!("Changedir to: {}", entry.name());
|
||||||
// Get path: if a directory, use directory path; if it is a File, get parent path
|
// Get path: if a directory, use directory path; if it is a File, get parent path
|
||||||
let path = if entry.is_dir() {
|
let path = if entry.is_dir() {
|
||||||
@@ -103,11 +103,12 @@ impl FileTransferActivity {
|
|||||||
// Check which file would be replaced
|
// Check which file would be replaced
|
||||||
let existing_files: Vec<&File> = entries
|
let existing_files: Vec<&File> = entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| {
|
.filter(|(x, dest_path)| {
|
||||||
self.remote_file_exists(
|
self.remote_file_exists(
|
||||||
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.map(|(x, _)| x)
|
||||||
.collect();
|
.collect();
|
||||||
// Check whether to replace files
|
// Check whether to replace files
|
||||||
if !existing_files.is_empty()
|
if !existing_files.is_empty()
|
||||||
@@ -117,7 +118,7 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(err) = self.filetransfer_send(
|
if let Err(err) = self.filetransfer_send(
|
||||||
TransferPayload::Many(entries),
|
TransferPayload::TransferQueue(entries),
|
||||||
dest_path.as_path(),
|
dest_path.as_path(),
|
||||||
None,
|
None,
|
||||||
) {
|
) {
|
||||||
@@ -134,11 +135,12 @@ impl FileTransferActivity {
|
|||||||
// Check which file would be replaced
|
// Check which file would be replaced
|
||||||
let existing_files: Vec<&File> = entries
|
let existing_files: Vec<&File> = entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| {
|
.filter(|(x, dest_path)| {
|
||||||
self.host_bridge_file_exists(
|
self.host_bridge_file_exists(
|
||||||
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.map(|(x, _)| x)
|
||||||
.collect();
|
.collect();
|
||||||
// Check whether to replace files
|
// Check whether to replace files
|
||||||
if !existing_files.is_empty()
|
if !existing_files.is_empty()
|
||||||
@@ -148,7 +150,7 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(err) = self.filetransfer_recv(
|
if let Err(err) = self.filetransfer_recv(
|
||||||
TransferPayload::Many(entries),
|
TransferPayload::TransferQueue(entries),
|
||||||
dest_path.as_path(),
|
dest_path.as_path(),
|
||||||
None,
|
None,
|
||||||
) {
|
) {
|
||||||
@@ -157,6 +159,12 @@ impl FileTransferActivity {
|
|||||||
format!("Could not download file: {err}"),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
if let Some(f) = self.found_mut() {
|
||||||
|
f.clear_queue();
|
||||||
|
self.update_find_list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,10 +180,16 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, _) in entries.iter() {
|
||||||
// Delete file
|
// Delete file
|
||||||
self.remove_found_file(entry);
|
self.remove_found_file(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
if let Some(f) = self.found_mut() {
|
||||||
|
f.clear_queue();
|
||||||
|
self.update_find_list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
@@ -200,10 +214,15 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, _) in entries.iter() {
|
||||||
// Open file
|
// Open file
|
||||||
self.open_found_file(entry, None);
|
self.open_found_file(entry, None);
|
||||||
}
|
}
|
||||||
|
// clear selection
|
||||||
|
if let Some(f) = self.found_mut() {
|
||||||
|
f.clear_queue();
|
||||||
|
self.update_find_list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
@@ -217,10 +236,15 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, _) in entries.iter() {
|
||||||
// Open file
|
// Open file
|
||||||
self.open_found_file(entry, Some(with));
|
self.open_found_file(entry, Some(with));
|
||||||
}
|
}
|
||||||
|
// clear selection
|
||||||
|
if let Some(f) = self.found_mut() {
|
||||||
|
f.clear_queue();
|
||||||
|
self.update_find_list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/ui/activities/filetransfer/actions/mark.rs
Normal file
19
src/ui/activities/filetransfer/actions/mark.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//! ## FileTransferActivity
|
||||||
|
//!
|
||||||
|
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
|
||||||
|
|
||||||
|
use super::FileTransferActivity;
|
||||||
|
|
||||||
|
impl FileTransferActivity {
|
||||||
|
pub(crate) fn action_mark_file(&mut self, index: usize) {
|
||||||
|
self.enqueue_file(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn action_mark_all(&mut self) {
|
||||||
|
self.enqueue_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn action_mark_clear(&mut self) {
|
||||||
|
self.clear_queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,19 @@
|
|||||||
//!
|
//!
|
||||||
//! `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 remotefs::fs::UnixPex;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
|
use remotefs::fs::UnixPex;
|
||||||
use tuirealm::{State, StateValue};
|
use tuirealm::{State, StateValue};
|
||||||
|
|
||||||
use super::browser::FileExplorerTab;
|
use super::browser::FileExplorerTab;
|
||||||
|
use super::lib::browser::FoundExplorerTab;
|
||||||
use super::{
|
use super::{
|
||||||
FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts,
|
FileTransferActivity, Id, LogLevel, Msg, PendingActionMsg, TransferMsg, TransferOpts,
|
||||||
TransferPayload, UiMsg,
|
TransferPayload, UiMsg,
|
||||||
};
|
};
|
||||||
|
use crate::explorer::FileExplorer;
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
pub(crate) mod change_dir;
|
pub(crate) mod change_dir;
|
||||||
@@ -21,6 +25,7 @@ pub(crate) mod edit;
|
|||||||
pub(crate) mod exec;
|
pub(crate) mod exec;
|
||||||
pub(crate) mod filter;
|
pub(crate) mod filter;
|
||||||
pub(crate) mod find;
|
pub(crate) mod find;
|
||||||
|
pub(crate) mod mark;
|
||||||
pub(crate) mod mkdir;
|
pub(crate) mod mkdir;
|
||||||
pub(crate) mod newfile;
|
pub(crate) mod newfile;
|
||||||
pub(crate) mod open;
|
pub(crate) mod open;
|
||||||
@@ -36,7 +41,8 @@ pub(crate) mod watcher;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum SelectedFile {
|
pub(crate) enum SelectedFile {
|
||||||
One(File),
|
One(File),
|
||||||
Many(Vec<File>),
|
/// List of file with their destination path
|
||||||
|
Many(Vec<(File, PathBuf)>),
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +51,10 @@ impl SelectedFile {
|
|||||||
/// In case is `Many` the first item mode is returned
|
/// In case is `Many` the first item mode is returned
|
||||||
pub fn unix_pex(&self) -> Option<UnixPex> {
|
pub fn unix_pex(&self) -> Option<UnixPex> {
|
||||||
match self {
|
match self {
|
||||||
Self::Many(files) => files.iter().next().and_then(|file| file.metadata().mode),
|
Self::Many(files) => files
|
||||||
|
.iter()
|
||||||
|
.next()
|
||||||
|
.and_then(|(file, _)| file.metadata().mode),
|
||||||
Self::One(file) => file.metadata().mode,
|
Self::One(file) => file.metadata().mode,
|
||||||
Self::None => None,
|
Self::None => None,
|
||||||
}
|
}
|
||||||
@@ -55,7 +64,7 @@ impl SelectedFile {
|
|||||||
pub fn get_files(self) -> Vec<File> {
|
pub fn get_files(self) -> Vec<File> {
|
||||||
match self {
|
match self {
|
||||||
Self::One(file) => vec![file],
|
Self::One(file) => vec![file],
|
||||||
Self::Many(files) => files,
|
Self::Many(files) => files.into_iter().map(|(f, _)| f).collect(),
|
||||||
Self::None => vec![],
|
Self::None => vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +73,6 @@ impl SelectedFile {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum SelectedFileIndex {
|
enum SelectedFileIndex {
|
||||||
One(usize),
|
One(usize),
|
||||||
Many(Vec<usize>),
|
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,68 +85,42 @@ impl From<Option<&File>> for SelectedFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<&File>> for SelectedFile {
|
|
||||||
fn from(files: Vec<&File>) -> Self {
|
|
||||||
SelectedFile::Many(files.into_iter().cloned().collect())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FileTransferActivity {
|
impl FileTransferActivity {
|
||||||
/// Get local file entry
|
/// Get local file entry
|
||||||
pub(crate) fn get_local_selected_entries(&self) -> SelectedFile {
|
pub(crate) fn get_local_selected_entries(&mut self) -> SelectedFile {
|
||||||
match self.get_selected_index(&Id::ExplorerHostBridge) {
|
self.get_selected_files(&Id::ExplorerHostBridge)
|
||||||
SelectedFileIndex::One(idx) => SelectedFile::from(self.host_bridge().get(idx)),
|
}
|
||||||
SelectedFileIndex::Many(files) => {
|
|
||||||
let files: Vec<&File> = files
|
pub(crate) fn get_local_selected_file(&self) -> Option<File> {
|
||||||
.iter()
|
self.get_selected_file(&Id::ExplorerHostBridge)
|
||||||
.filter_map(|x| self.host_bridge().get(*x)) // Usize to Option<File>
|
|
||||||
.collect();
|
|
||||||
SelectedFile::from(files)
|
|
||||||
}
|
|
||||||
SelectedFileIndex::None => SelectedFile::None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get remote file entry
|
/// Get remote file entry
|
||||||
pub(crate) fn get_remote_selected_entries(&self) -> SelectedFile {
|
pub(crate) fn get_remote_selected_entries(&mut self) -> SelectedFile {
|
||||||
match self.get_selected_index(&Id::ExplorerRemote) {
|
self.get_selected_files(&Id::ExplorerRemote)
|
||||||
SelectedFileIndex::One(idx) => SelectedFile::from(self.remote().get(idx)),
|
}
|
||||||
SelectedFileIndex::Many(files) => {
|
|
||||||
let files: Vec<&File> = files
|
pub(crate) fn get_remote_selected_file(&self) -> Option<File> {
|
||||||
.iter()
|
self.get_selected_file(&Id::ExplorerRemote)
|
||||||
.filter_map(|x| self.remote().get(*x)) // Usize to Option<File>
|
|
||||||
.collect();
|
|
||||||
SelectedFile::from(files)
|
|
||||||
}
|
|
||||||
SelectedFileIndex::None => SelectedFile::None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether only one entry is selected on local host
|
/// Returns whether only one entry is selected on local host
|
||||||
pub(crate) fn is_local_selected_one(&self) -> bool {
|
pub(crate) fn is_local_selected_one(&mut self) -> bool {
|
||||||
matches!(self.get_local_selected_entries(), SelectedFile::One(_))
|
matches!(self.get_local_selected_entries(), SelectedFile::One(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether only one entry is selected on remote host
|
/// Returns whether only one entry is selected on remote host
|
||||||
pub(crate) fn is_remote_selected_one(&self) -> bool {
|
pub(crate) fn is_remote_selected_one(&mut self) -> bool {
|
||||||
matches!(self.get_remote_selected_entries(), SelectedFile::One(_))
|
matches!(self.get_remote_selected_entries(), SelectedFile::One(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get remote file entry
|
/// Get remote file entry
|
||||||
pub(crate) fn get_found_selected_entries(&self) -> SelectedFile {
|
pub(crate) fn get_found_selected_entries(&mut self) -> SelectedFile {
|
||||||
match self.get_selected_index(&Id::ExplorerFind) {
|
self.get_selected_files(&Id::ExplorerFind)
|
||||||
SelectedFileIndex::One(idx) => {
|
}
|
||||||
SelectedFile::from(self.found().as_ref().unwrap().get(idx))
|
|
||||||
}
|
pub(crate) fn get_found_selected_file(&self) -> Option<File> {
|
||||||
SelectedFileIndex::Many(files) => {
|
self.get_selected_file(&Id::ExplorerFind)
|
||||||
let files: Vec<&File> = files
|
|
||||||
.iter()
|
|
||||||
.filter_map(|x| self.found().as_ref().unwrap().get(*x)) // Usize to Option<File>
|
|
||||||
.collect();
|
|
||||||
SelectedFile::from(files)
|
|
||||||
}
|
|
||||||
SelectedFileIndex::None => SelectedFile::None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- private
|
// -- private
|
||||||
@@ -146,17 +128,69 @@ impl FileTransferActivity {
|
|||||||
fn get_selected_index(&self, id: &Id) -> SelectedFileIndex {
|
fn get_selected_index(&self, id: &Id) -> SelectedFileIndex {
|
||||||
match self.app.state(id) {
|
match self.app.state(id) {
|
||||||
Ok(State::One(StateValue::Usize(idx))) => SelectedFileIndex::One(idx),
|
Ok(State::One(StateValue::Usize(idx))) => SelectedFileIndex::One(idx),
|
||||||
Ok(State::Vec(files)) => {
|
|
||||||
let list: Vec<usize> = files
|
|
||||||
.iter()
|
|
||||||
.map(|x| match x {
|
|
||||||
StateValue::Usize(v) => *v,
|
|
||||||
_ => 0,
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
SelectedFileIndex::Many(list)
|
|
||||||
}
|
|
||||||
_ => SelectedFileIndex::None,
|
_ => SelectedFileIndex::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_selected_files(&mut self, id: &Id) -> SelectedFile {
|
||||||
|
let browser = self.browser_by_id(id);
|
||||||
|
// if transfer queue is not empty, return that
|
||||||
|
let transfer_queue = browser.enqueued().clone();
|
||||||
|
if !transfer_queue.is_empty() {
|
||||||
|
return SelectedFile::Many(
|
||||||
|
transfer_queue
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(src, dest)| {
|
||||||
|
let src_file = self.get_file_from_path(id, src)?;
|
||||||
|
Some((src_file, dest.clone()))
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let browser = self.browser_by_id(id);
|
||||||
|
// if no transfer queue, return selected files
|
||||||
|
match self.get_selected_index(id) {
|
||||||
|
SelectedFileIndex::One(idx) => {
|
||||||
|
let Some(f) = browser.get(idx) else {
|
||||||
|
return SelectedFile::None;
|
||||||
|
};
|
||||||
|
SelectedFile::One(f.clone())
|
||||||
|
}
|
||||||
|
SelectedFileIndex::None => SelectedFile::None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_file_from_path(&mut self, id: &Id, path: &Path) -> Option<File> {
|
||||||
|
match *id {
|
||||||
|
Id::ExplorerHostBridge => self.host_bridge.stat(path).ok(),
|
||||||
|
Id::ExplorerRemote => self.client.stat(path).ok(),
|
||||||
|
Id::ExplorerFind => {
|
||||||
|
let found = self.browser.found_tab().unwrap();
|
||||||
|
match found {
|
||||||
|
FoundExplorerTab::Local => self.host_bridge.stat(path).ok(),
|
||||||
|
FoundExplorerTab::Remote => self.client.stat(path).ok(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn browser_by_id(&self, id: &Id) -> &FileExplorer {
|
||||||
|
match *id {
|
||||||
|
Id::ExplorerHostBridge => self.host_bridge(),
|
||||||
|
Id::ExplorerRemote => self.remote(),
|
||||||
|
Id::ExplorerFind => self.found().as_ref().unwrap(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_selected_file(&self, id: &Id) -> Option<File> {
|
||||||
|
let browser = self.browser_by_id(id);
|
||||||
|
// if no transfer queue, return selected files
|
||||||
|
match self.get_selected_index(id) {
|
||||||
|
SelectedFileIndex::One(idx) => browser.get(idx).cloned(),
|
||||||
|
SelectedFileIndex::None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,32 @@ impl FileTransferActivity {
|
|||||||
pub(crate) fn action_open_local(&mut self) {
|
pub(crate) fn action_open_local(&mut self) {
|
||||||
let entries: Vec<File> = match self.get_local_selected_entries() {
|
let entries: Vec<File> = match self.get_local_selected_entries() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
entries
|
entries
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|x| self.action_open_local_file(x, None));
|
.for_each(|x| self.action_open_local_file(x, None));
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open local file
|
/// Open local file
|
||||||
pub(crate) fn action_open_remote(&mut self) {
|
pub(crate) fn action_open_remote(&mut self) {
|
||||||
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
entries
|
entries
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|x| self.action_open_remote_file(x, None));
|
.for_each(|x| self.action_open_remote_file(x, None));
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform open lopcal file
|
/// Perform open lopcal file
|
||||||
@@ -86,26 +94,33 @@ impl FileTransferActivity {
|
|||||||
pub(crate) fn action_local_open_with(&mut self, with: &str) {
|
pub(crate) fn action_local_open_with(&mut self, with: &str) {
|
||||||
let entries: Vec<File> = match self.get_local_selected_entries() {
|
let entries: Vec<File> = match self.get_local_selected_entries() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
// Open all entries
|
// Open all entries
|
||||||
entries
|
entries
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|x| self.action_open_local_file(x, Some(with)));
|
.for_each(|x| self.action_open_local_file(x, Some(with)));
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open selected file with provided application
|
/// Open selected file with provided application
|
||||||
pub(crate) fn action_remote_open_with(&mut self, with: &str) {
|
pub(crate) fn action_remote_open_with(&mut self, with: &str) {
|
||||||
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
let entries: Vec<File> = match self.get_remote_selected_entries() {
|
||||||
SelectedFile::One(entry) => vec![entry],
|
SelectedFile::One(entry) => vec![entry],
|
||||||
SelectedFile::Many(entries) => entries,
|
SelectedFile::Many(entries) => entries.into_iter().map(|(f, _)| f).collect(),
|
||||||
SelectedFile::None => vec![],
|
SelectedFile::None => vec![],
|
||||||
};
|
};
|
||||||
// Open all entries
|
// Open all entries
|
||||||
entries
|
entries
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|x| self.action_open_remote_file(x, Some(with)));
|
.for_each(|x| self.action_open_remote_file(x, Some(with)));
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_bridged_file(&mut self, entry: &File, open_with: Option<&str>) {
|
fn open_bridged_file(&mut self, entry: &File, open_with: Option<&str>) {
|
||||||
@@ -171,7 +186,7 @@ impl FileTransferActivity {
|
|||||||
Ok(_) => self.log(LogLevel::Info, format!("Opened file `{}`", p.display())),
|
Ok(_) => self.log(LogLevel::Info, format!("Opened file `{}`", p.display())),
|
||||||
Err(err) => self.log(
|
Err(err) => self.log(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Failed to open filoe `{}`: {}", p.display(), err),
|
format!("Failed to open file `{}`: {}", p.display(), err),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
// NOTE: clear screen in order to prevent crap on stderr
|
// NOTE: clear screen in order to prevent crap on stderr
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Try to copy each file to Input/{FILE_NAME}
|
// Try to copy each file to Input/{FILE_NAME}
|
||||||
let base_path: PathBuf = PathBuf::from(input);
|
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, mut dest_path) in entries.into_iter() {
|
||||||
let mut dest_path: PathBuf = base_path.clone();
|
|
||||||
dest_path.push(entry.name());
|
dest_path.push(entry.name());
|
||||||
self.local_rename_file(entry, dest_path.as_path());
|
self.local_rename_file(&entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
@@ -38,13 +40,16 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
SelectedFile::Many(entries) => {
|
SelectedFile::Many(entries) => {
|
||||||
// Try to copy each file to Input/{FILE_NAME}
|
// Try to copy each file to Input/{FILE_NAME}
|
||||||
let base_path: PathBuf = PathBuf::from(input);
|
|
||||||
// Iter files
|
// Iter files
|
||||||
for entry in entries.iter() {
|
for (entry, mut dest_path) in entries.into_iter() {
|
||||||
let mut dest_path: PathBuf = base_path.clone();
|
|
||||||
dest_path.push(entry.name());
|
dest_path.push(entry.name());
|
||||||
self.remote_rename_file(entry, dest_path.as_path());
|
self.remote_rename_file(&entry, dest_path.as_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
// reload remote
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,11 +64,12 @@ impl FileTransferActivity {
|
|||||||
// Check which file would be replaced
|
// Check which file would be replaced
|
||||||
let existing_files: Vec<&File> = entries
|
let existing_files: Vec<&File> = entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| {
|
.filter(|(x, dest_path)| {
|
||||||
self.remote_file_exists(
|
self.remote_file_exists(
|
||||||
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.map(|(x, _)| x)
|
||||||
.collect();
|
.collect();
|
||||||
// Check whether to replace files
|
// Check whether to replace files
|
||||||
if !existing_files.is_empty() && !self.should_replace_files(existing_files) {
|
if !existing_files.is_empty() && !self.should_replace_files(existing_files) {
|
||||||
@@ -76,7 +77,7 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(err) = self.filetransfer_send(
|
if let Err(err) = self.filetransfer_send(
|
||||||
TransferPayload::Many(entries),
|
TransferPayload::TransferQueue(entries),
|
||||||
dest_path.as_path(),
|
dest_path.as_path(),
|
||||||
None,
|
None,
|
||||||
) {
|
) {
|
||||||
@@ -86,6 +87,10 @@ impl FileTransferActivity {
|
|||||||
format!("Could not upload file: {err}"),
|
format!("Could not upload file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// clear selection
|
||||||
|
self.host_bridge_mut().clear_queue();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
@@ -128,11 +133,12 @@ impl FileTransferActivity {
|
|||||||
// Check which file would be replaced
|
// Check which file would be replaced
|
||||||
let existing_files: Vec<&File> = entries
|
let existing_files: Vec<&File> = entries
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| {
|
.filter(|(x, dest_path)| {
|
||||||
self.host_bridge_file_exists(
|
self.host_bridge_file_exists(
|
||||||
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
Self::file_to_check_many(x, dest_path.as_path()).as_path(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.map(|(x, _)| x)
|
||||||
.collect();
|
.collect();
|
||||||
// Check whether to replace files
|
// Check whether to replace files
|
||||||
if !existing_files.is_empty() && !self.should_replace_files(existing_files) {
|
if !existing_files.is_empty() && !self.should_replace_files(existing_files) {
|
||||||
@@ -140,7 +146,7 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(err) = self.filetransfer_recv(
|
if let Err(err) = self.filetransfer_recv(
|
||||||
TransferPayload::Many(entries),
|
TransferPayload::TransferQueue(entries),
|
||||||
dest_path.as_path(),
|
dest_path.as_path(),
|
||||||
None,
|
None,
|
||||||
) {
|
) {
|
||||||
@@ -150,6 +156,11 @@ impl FileTransferActivity {
|
|||||||
format!("Could not download file: {err}"),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// clear selection
|
||||||
|
self.remote_mut().clear_queue();
|
||||||
|
// reload remote
|
||||||
|
self.reload_remote_filelist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SelectedFile::None => {}
|
SelectedFile::None => {}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
// locals
|
// locals
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use super::{FileTransferActivity, LogLevel, SelectedFile};
|
use super::{FileTransferActivity, LogLevel};
|
||||||
|
|
||||||
impl FileTransferActivity {
|
impl FileTransferActivity {
|
||||||
/// Create symlink on localhost
|
/// Create symlink on localhost
|
||||||
pub(crate) fn action_local_symlink(&mut self, name: String) {
|
pub(crate) fn action_local_symlink(&mut self, name: String) {
|
||||||
if let SelectedFile::One(entry) = self.get_local_selected_entries() {
|
if let Some(entry) = self.get_local_selected_file() {
|
||||||
match self
|
match self
|
||||||
.host_bridge
|
.host_bridge
|
||||||
.symlink(PathBuf::from(name.as_str()).as_path(), entry.path())
|
.symlink(PathBuf::from(name.as_str()).as_path(), entry.path())
|
||||||
@@ -34,7 +34,7 @@ impl FileTransferActivity {
|
|||||||
|
|
||||||
/// Copy file on remote
|
/// Copy file on remote
|
||||||
pub(crate) fn action_remote_symlink(&mut self, name: String) {
|
pub(crate) fn action_remote_symlink(&mut self, name: String) {
|
||||||
if let SelectedFile::One(entry) = self.get_remote_selected_entries() {
|
if let Some(entry) = self.get_remote_selected_file() {
|
||||||
match self
|
match self
|
||||||
.client
|
.client
|
||||||
.symlink(PathBuf::from(name.as_str()).as_path(), entry.path())
|
.symlink(PathBuf::from(name.as_str()).as_path(), entry.path())
|
||||||
|
|||||||
@@ -53,12 +53,20 @@ impl MockComponent for Log {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap_table()
|
.unwrap_table()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|row| ListItem::new(tui_realm_stdlib::utils::wrap_spans(row, width, &self.props)))
|
.map(|row| {
|
||||||
|
let row_refs = row.iter().collect::<Vec<_>>();
|
||||||
|
ListItem::new(tui_realm_stdlib::utils::wrap_spans(
|
||||||
|
row_refs.as_slice(),
|
||||||
|
width,
|
||||||
|
&self.props,
|
||||||
|
))
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let title = ("Log".to_string(), Alignment::Left);
|
||||||
let w = TuiList::new(list_items)
|
let w = TuiList::new(list_items)
|
||||||
.block(tui_realm_stdlib::utils::get_block(
|
.block(tui_realm_stdlib::utils::get_block(
|
||||||
borders,
|
borders,
|
||||||
Some(("Log".to_string(), Alignment::Left)),
|
Some(&title),
|
||||||
focus,
|
focus,
|
||||||
None,
|
None,
|
||||||
))
|
))
|
||||||
@@ -166,6 +174,12 @@ impl Component<Msg, NoUserEvent> for Log {
|
|||||||
self.perform(Cmd::Move(Direction::Up));
|
self.perform(Cmd::Move(Direction::Up));
|
||||||
Some(Msg::None)
|
Some(Msg::None)
|
||||||
}
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Right, ..
|
||||||
|
}) => Some(Msg::Ui(UiMsg::BottomPanelRight)),
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Left, ..
|
||||||
|
}) => Some(Msg::Ui(UiMsg::BottomPanelLeft)),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::PageUp, ..
|
code: Key::PageUp, ..
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub struct FooterBar {
|
|||||||
impl FooterBar {
|
impl FooterBar {
|
||||||
pub fn new(key_color: Color) -> Self {
|
pub fn new(key_color: Color) -> Self {
|
||||||
Self {
|
Self {
|
||||||
component: Span::default().spans(&[
|
component: Span::default().spans([
|
||||||
TextSpan::from("<F1|H>").bold().fg(key_color),
|
TextSpan::from("<F1|H>").bold().fg(key_color),
|
||||||
TextSpan::from(" Help "),
|
TextSpan::from(" Help "),
|
||||||
TextSpan::from("<TAB>").bold().fg(key_color),
|
TextSpan::from("<TAB>").bold().fg(key_color),
|
||||||
|
|||||||
@@ -12,20 +12,24 @@ use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
|
|||||||
mod log;
|
mod log;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod popups;
|
mod popups;
|
||||||
|
mod selected_files;
|
||||||
|
mod terminal;
|
||||||
mod transfer;
|
mod transfer;
|
||||||
|
|
||||||
pub use misc::FooterBar;
|
pub use misc::FooterBar;
|
||||||
pub use popups::{
|
pub use popups::{
|
||||||
ChmodPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, ExecPopup, FatalPopup,
|
ATTR_FILES, ChmodPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, FatalPopup,
|
||||||
FileInfoPopup, FilterPopup, GotoPopup, KeybindingsPopup, MkdirPopup, NewfilePopup,
|
FileInfoPopup, FilterPopup, GotoPopup, KeybindingsPopup, MkdirPopup, NewfilePopup,
|
||||||
OpenWithPopup, ProgressBarFull, ProgressBarPartial, QuitPopup, RenamePopup, ReplacePopup,
|
OpenWithPopup, ProgressBarFull, ProgressBarPartial, QuitPopup, RenamePopup, ReplacePopup,
|
||||||
ReplacingFilesListPopup, SaveAsPopup, SortingPopup, StatusBarLocal, StatusBarRemote,
|
ReplacingFilesListPopup, SaveAsPopup, SortingPopup, StatusBarLocal, StatusBarRemote,
|
||||||
SymlinkPopup, SyncBrowsingMkdirPopup, WaitPopup, WalkdirWaitPopup, WatchedPathsList,
|
SymlinkPopup, SyncBrowsingMkdirPopup, WaitPopup, WalkdirWaitPopup, WatchedPathsList,
|
||||||
WatcherPopup, ATTR_FILES,
|
WatcherPopup,
|
||||||
};
|
};
|
||||||
pub use transfer::{ExplorerFind, ExplorerFuzzy, ExplorerLocal, ExplorerRemote};
|
pub use transfer::{ExplorerFind, ExplorerFuzzy, ExplorerLocal, ExplorerRemote};
|
||||||
|
|
||||||
pub use self::log::Log;
|
pub use self::log::Log;
|
||||||
|
pub use self::selected_files::SelectedFilesList;
|
||||||
|
pub use self::terminal::Terminal;
|
||||||
|
|
||||||
#[derive(Default, MockComponent)]
|
#[derive(Default, MockComponent)]
|
||||||
pub struct GlobalListener {
|
pub struct GlobalListener {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
|
|||||||
use uzers::{get_group_by_gid, get_user_by_uid};
|
use uzers::{get_group_by_gid, get_user_by_uid};
|
||||||
|
|
||||||
pub use self::chmod::ChmodPopup;
|
pub use self::chmod::ChmodPopup;
|
||||||
pub use self::goto::{GotoPopup, ATTR_FILES};
|
pub use self::goto::{ATTR_FILES, GotoPopup};
|
||||||
use super::super::Browser;
|
use super::super::Browser;
|
||||||
use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
|
use super::{Msg, PendingActionMsg, TransferMsg, UiMsg};
|
||||||
use crate::explorer::FileSorting;
|
use crate::explorer::FileSorting;
|
||||||
@@ -214,7 +214,7 @@ impl DeletePopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.value(1)
|
.value(1)
|
||||||
.title("Delete file(s)?", Alignment::Center),
|
.title("Delete file(s)?", Alignment::Center),
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ impl DisconnectPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.title("Are you sure you want to disconnect?", Alignment::Center),
|
.title("Are you sure you want to disconnect?", Alignment::Center),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ impl ErrorPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,89 +362,6 @@ impl Component<Msg, NoUserEvent> for ErrorPopup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(MockComponent)]
|
|
||||||
pub struct ExecPopup {
|
|
||||||
component: Input,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ExecPopup {
|
|
||||||
pub fn new(color: Color) -> Self {
|
|
||||||
Self {
|
|
||||||
component: Input::default()
|
|
||||||
.borders(
|
|
||||||
Borders::default()
|
|
||||||
.color(color)
|
|
||||||
.modifiers(BorderType::Rounded),
|
|
||||||
)
|
|
||||||
.foreground(color)
|
|
||||||
.input_type(InputType::Text)
|
|
||||||
.placeholder("ps a", Style::default().fg(Color::Rgb(128, 128, 128)))
|
|
||||||
.title("Execute command", Alignment::Center),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Component<Msg, NoUserEvent> for ExecPopup {
|
|
||||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
|
||||||
match ev {
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Left, ..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::Move(Direction::Left));
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Right, ..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::Move(Direction::Right));
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Home, ..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::GoTo(Position::Begin));
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent { code: Key::End, .. }) => {
|
|
||||||
self.perform(Cmd::GoTo(Position::End));
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Delete, ..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::Cancel);
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Backspace,
|
|
||||||
..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::Delete);
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Char(ch),
|
|
||||||
..
|
|
||||||
}) => {
|
|
||||||
self.perform(Cmd::Type(ch));
|
|
||||||
Some(Msg::None)
|
|
||||||
}
|
|
||||||
Event::Keyboard(KeyEvent {
|
|
||||||
code: Key::Enter, ..
|
|
||||||
}) => match self.state() {
|
|
||||||
State::One(StateValue::String(i)) => {
|
|
||||||
Some(Msg::Transfer(TransferMsg::ExecuteCmd(i)))
|
|
||||||
}
|
|
||||||
_ => Some(Msg::None),
|
|
||||||
},
|
|
||||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
|
||||||
Some(Msg::Ui(UiMsg::CloseExecPopup))
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(MockComponent)]
|
#[derive(MockComponent)]
|
||||||
pub struct FatalPopup {
|
pub struct FatalPopup {
|
||||||
component: Paragraph,
|
component: Paragraph,
|
||||||
@@ -461,7 +378,7 @@ impl FatalPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,6 +414,10 @@ impl FileInfoPopup {
|
|||||||
texts
|
texts
|
||||||
.add_col(TextSpan::from("Path: "))
|
.add_col(TextSpan::from("Path: "))
|
||||||
.add_col(TextSpan::new(path.as_str()).fg(Color::Yellow));
|
.add_col(TextSpan::new(path.as_str()).fg(Color::Yellow));
|
||||||
|
texts
|
||||||
|
.add_row()
|
||||||
|
.add_col(TextSpan::from("Name: "))
|
||||||
|
.add_col(TextSpan::new(file.name()).fg(Color::Yellow));
|
||||||
if let Some(filetype) = file.extension() {
|
if let Some(filetype) = file.extension() {
|
||||||
texts
|
texts
|
||||||
.add_row()
|
.add_row()
|
||||||
@@ -670,7 +591,7 @@ impl KeybindingsPopup {
|
|||||||
))
|
))
|
||||||
.add_row()
|
.add_row()
|
||||||
.add_col(TextSpan::new("<P>").bold().fg(key_color))
|
.add_col(TextSpan::new("<P>").bold().fg(key_color))
|
||||||
.add_col(TextSpan::from(" Toggle log panel"))
|
.add_col(TextSpan::from(" Toggle bottom panel"))
|
||||||
.add_row()
|
.add_row()
|
||||||
.add_col(TextSpan::new("<Q|F10>").bold().fg(key_color))
|
.add_col(TextSpan::new("<Q|F10>").bold().fg(key_color))
|
||||||
.add_col(TextSpan::from(" Quit termscp"))
|
.add_col(TextSpan::from(" Quit termscp"))
|
||||||
@@ -1121,7 +1042,7 @@ impl QuitPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.title("Are you sure you want to quit termscp?", Alignment::Center),
|
.title("Are you sure you want to quit termscp?", Alignment::Center),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1275,7 +1196,7 @@ impl ReplacePopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.title(text, Alignment::Center),
|
.title(text, Alignment::Center),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1502,7 +1423,7 @@ impl SortingPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Name", "Modify time", "Creation time", "Size"])
|
.choices(["Name", "Modify time", "Creation time", "Size"])
|
||||||
.title("Sort files by…", Alignment::Center)
|
.title("Sort files by…", Alignment::Center)
|
||||||
.value(match value {
|
.value(match value {
|
||||||
FileSorting::CreationTime => 2,
|
FileSorting::CreationTime => 2,
|
||||||
@@ -1554,7 +1475,7 @@ impl StatusBarLocal {
|
|||||||
let file_sorting = file_sorting_label(browser.host_bridge().file_sorting);
|
let file_sorting = file_sorting_label(browser.host_bridge().file_sorting);
|
||||||
let hidden_files = hidden_files_label(browser.host_bridge().hidden_files_visible());
|
let hidden_files = hidden_files_label(browser.host_bridge().hidden_files_visible());
|
||||||
Self {
|
Self {
|
||||||
component: Span::default().spans(&[
|
component: Span::default().spans([
|
||||||
TextSpan::new("File sorting: ").fg(sorting_color),
|
TextSpan::new("File sorting: ").fg(sorting_color),
|
||||||
TextSpan::new(file_sorting).fg(sorting_color).reversed(),
|
TextSpan::new(file_sorting).fg(sorting_color).reversed(),
|
||||||
TextSpan::new(" Hidden files: ").fg(hidden_color),
|
TextSpan::new(" Hidden files: ").fg(hidden_color),
|
||||||
@@ -1589,7 +1510,7 @@ impl StatusBarRemote {
|
|||||||
false => "OFF",
|
false => "OFF",
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
component: Span::default().spans(&[
|
component: Span::default().spans([
|
||||||
TextSpan::new("File sorting: ").fg(sorting_color),
|
TextSpan::new("File sorting: ").fg(sorting_color),
|
||||||
TextSpan::new(file_sorting).fg(sorting_color).reversed(),
|
TextSpan::new(file_sorting).fg(sorting_color).reversed(),
|
||||||
TextSpan::new(" Hidden files: ").fg(hidden_color),
|
TextSpan::new(" Hidden files: ").fg(hidden_color),
|
||||||
@@ -1728,7 +1649,7 @@ impl SyncBrowsingMkdirPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.title(
|
.title(
|
||||||
format!(
|
format!(
|
||||||
r#"Sync browsing: directory "{dir_name}" doesn't exist. Do you want to create it?"#
|
r#"Sync browsing: directory "{dir_name}" doesn't exist. Do you want to create it?"#
|
||||||
@@ -1802,7 +1723,7 @@ impl WaitPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[TextSpan::from(text.as_ref())])
|
.text([TextSpan::from(text.as_ref())])
|
||||||
.wrap(true),
|
.wrap(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1830,7 +1751,7 @@ impl WalkdirWaitPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.text(&[
|
.text([
|
||||||
TextSpan::from(text.as_ref()),
|
TextSpan::from(text.as_ref()),
|
||||||
TextSpan::from("Press 'CTRL+C' to abort"),
|
TextSpan::from("Press 'CTRL+C' to abort"),
|
||||||
])
|
])
|
||||||
@@ -1961,7 +1882,7 @@ impl WatcherPopup {
|
|||||||
.modifiers(BorderType::Rounded),
|
.modifiers(BorderType::Rounded),
|
||||||
)
|
)
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Yes", "No"])
|
.choices(["Yes", "No"])
|
||||||
.title(text, Alignment::Center),
|
.title(text, Alignment::Center),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,21 +59,21 @@ impl ChmodPopup {
|
|||||||
},
|
},
|
||||||
user: Checkbox::default()
|
user: Checkbox::default()
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Read", "Write", "Execute"])
|
.choices(["Read", "Write", "Execute"])
|
||||||
.title("User", Alignment::Left)
|
.title("User", Alignment::Left)
|
||||||
.borders(Borders::default().sides(BorderSides::NONE))
|
.borders(Borders::default().sides(BorderSides::NONE))
|
||||||
.values(&make_pex_values(pex.user()))
|
.values(&make_pex_values(pex.user()))
|
||||||
.rewind(true),
|
.rewind(true),
|
||||||
group: Checkbox::default()
|
group: Checkbox::default()
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Read", "Write", "Execute"])
|
.choices(["Read", "Write", "Execute"])
|
||||||
.title("Group", Alignment::Left)
|
.title("Group", Alignment::Left)
|
||||||
.borders(Borders::default().sides(BorderSides::NONE))
|
.borders(Borders::default().sides(BorderSides::NONE))
|
||||||
.values(&make_pex_values(pex.group()))
|
.values(&make_pex_values(pex.group()))
|
||||||
.rewind(true),
|
.rewind(true),
|
||||||
others: Checkbox::default()
|
others: Checkbox::default()
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.choices(&["Read", "Write", "Execute"])
|
.choices(["Read", "Write", "Execute"])
|
||||||
.title("Others", Alignment::Left)
|
.title("Others", Alignment::Left)
|
||||||
.borders(Borders::default().sides(BorderSides::NONE))
|
.borders(Borders::default().sides(BorderSides::NONE))
|
||||||
.values(&make_pex_values(pex.others()))
|
.values(&make_pex_values(pex.others()))
|
||||||
@@ -208,9 +208,11 @@ impl MockComponent for ChmodPopup {
|
|||||||
.get_or(Attribute::Focus, AttrValue::Flag(false))
|
.get_or(Attribute::Focus, AttrValue::Flag(false))
|
||||||
.unwrap_flag();
|
.unwrap_flag();
|
||||||
|
|
||||||
|
let div_title = (self.title.clone(), Alignment::Center);
|
||||||
|
|
||||||
let div = tui_realm_stdlib::utils::get_block(
|
let div = tui_realm_stdlib::utils::get_block(
|
||||||
Borders::default().color(self.color),
|
Borders::default().color(self.color),
|
||||||
Some((self.title.clone(), Alignment::Center)),
|
Some(&div_title),
|
||||||
focus,
|
focus,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|||||||
126
src/ui/activities/filetransfer/components/selected_files.rs
Normal file
126
src/ui/activities/filetransfer/components/selected_files.rs
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use tui_realm_stdlib::List;
|
||||||
|
use tuirealm::command::{Cmd, Direction, Position};
|
||||||
|
use tuirealm::event::{Key, KeyEvent};
|
||||||
|
use tuirealm::props::{Alignment, BorderType, Borders, Color, TextSpan};
|
||||||
|
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
|
||||||
|
|
||||||
|
use crate::ui::activities::filetransfer::{MarkQueue, Msg, UiMsg};
|
||||||
|
|
||||||
|
#[derive(MockComponent)]
|
||||||
|
pub struct SelectedFilesList {
|
||||||
|
component: List,
|
||||||
|
paths: Vec<PathBuf>,
|
||||||
|
queue: MarkQueue,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SelectedFilesList {
|
||||||
|
pub fn new(
|
||||||
|
paths: &[(PathBuf, PathBuf)],
|
||||||
|
queue: MarkQueue,
|
||||||
|
color: Color,
|
||||||
|
title: &'static str,
|
||||||
|
) -> Self {
|
||||||
|
let enqueued_paths = paths
|
||||||
|
.iter()
|
||||||
|
.map(|(src, _)| src.clone())
|
||||||
|
.collect::<Vec<PathBuf>>();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
queue,
|
||||||
|
paths: enqueued_paths,
|
||||||
|
component: List::default()
|
||||||
|
.borders(Borders::default().color(color).modifiers(BorderType::Plain))
|
||||||
|
.rewind(true)
|
||||||
|
.scroll(true)
|
||||||
|
.step(4)
|
||||||
|
.highlighted_color(color)
|
||||||
|
.highlighted_str("➤ ")
|
||||||
|
.title(title, Alignment::Left)
|
||||||
|
.rows(
|
||||||
|
paths
|
||||||
|
.iter()
|
||||||
|
.map(|(src, dest)| {
|
||||||
|
vec![
|
||||||
|
TextSpan::from(Self::filename(src)),
|
||||||
|
TextSpan::from(" -> "),
|
||||||
|
TextSpan::from(Self::filename(dest)),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn filename(p: &Path) -> String {
|
||||||
|
p.file_name()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Component<Msg, NoUserEvent> for SelectedFilesList {
|
||||||
|
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||||
|
match ev {
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Down, ..
|
||||||
|
}) => {
|
||||||
|
self.perform(Cmd::Move(Direction::Down));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||||
|
self.perform(Cmd::Move(Direction::Up));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::PageDown,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
self.perform(Cmd::Scroll(Direction::Down));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::PageUp, ..
|
||||||
|
}) => {
|
||||||
|
self.perform(Cmd::Scroll(Direction::Up));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Home, ..
|
||||||
|
}) => {
|
||||||
|
self.perform(Cmd::GoTo(Position::Begin));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent { code: Key::End, .. }) => {
|
||||||
|
self.perform(Cmd::GoTo(Position::End));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Right, ..
|
||||||
|
}) => Some(Msg::Ui(UiMsg::BottomPanelRight)),
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Left, ..
|
||||||
|
}) => Some(Msg::Ui(UiMsg::BottomPanelLeft)),
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::BackTab | Key::Tab | Key::Char('p'),
|
||||||
|
..
|
||||||
|
}) => Some(Msg::Ui(UiMsg::LogBackTabbed)),
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Enter | Key::Delete,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
// unmark the selected file
|
||||||
|
let State::One(StateValue::Usize(idx)) = self.state() else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
let path = self.paths.get(idx)?;
|
||||||
|
|
||||||
|
Some(Msg::Ui(UiMsg::MarkRemove(self.queue, path.clone())))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
136
src/ui/activities/filetransfer/components/terminal.rs
Normal file
136
src/ui/activities/filetransfer/components/terminal.rs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
mod component;
|
||||||
|
mod history;
|
||||||
|
mod line;
|
||||||
|
|
||||||
|
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||||
|
use tuirealm::event::{Key, KeyEvent};
|
||||||
|
use tuirealm::props::Color;
|
||||||
|
use tuirealm::{AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent};
|
||||||
|
|
||||||
|
use self::component::TerminalComponent;
|
||||||
|
use self::line::Line;
|
||||||
|
use super::Msg;
|
||||||
|
use crate::ui::activities::filetransfer::{TransferMsg, UiMsg};
|
||||||
|
|
||||||
|
#[derive(MockComponent, Default)]
|
||||||
|
pub struct Terminal {
|
||||||
|
component: TerminalComponent,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Terminal {
|
||||||
|
/// Construct a new [`Terminal`] component with the given prompt line.
|
||||||
|
pub fn prompt(mut self, prompt: impl ToString) -> Self {
|
||||||
|
self.component = self.component.prompt(prompt);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Construct a new [`Terminal`] component with the given title.
|
||||||
|
pub fn title(mut self, title: impl ToString) -> Self {
|
||||||
|
self.component
|
||||||
|
.attr(Attribute::Title, AttrValue::String(title.to_string()));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn border_color(mut self, color: Color) -> Self {
|
||||||
|
self.component
|
||||||
|
.attr(Attribute::Borders, AttrValue::Color(color));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Construct a new [`Terminal`] component with the foreground color
|
||||||
|
pub fn foreground(mut self, color: Color) -> Self {
|
||||||
|
self.component
|
||||||
|
.attr(Attribute::Foreground, AttrValue::Color(color));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Component<Msg, NoUserEvent> for Terminal {
|
||||||
|
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||||
|
match ev {
|
||||||
|
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||||
|
Some(Msg::Ui(UiMsg::CloseExecPopup))
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Enter, ..
|
||||||
|
}) => match self.component.perform(Cmd::Submit) {
|
||||||
|
CmdResult::Submit(state) => {
|
||||||
|
let cmd = state.unwrap_one().unwrap_string();
|
||||||
|
Some(Msg::Transfer(TransferMsg::ExecuteCmd(cmd)))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Home, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::GoTo(Position::Begin));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent { code: Key::End, .. }) => {
|
||||||
|
self.component.perform(Cmd::GoTo(Position::End));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Backspace,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Cancel);
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Delete, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Delete);
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||||
|
self.component.perform(Cmd::Move(Direction::Up));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Down, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Move(Direction::Down));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Left, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Move(Direction::Left));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Right, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Move(Direction::Right));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Insert, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Toggle);
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::PageDown,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Scroll(Direction::Down));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::PageUp, ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Scroll(Direction::Up));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
Event::Keyboard(KeyEvent {
|
||||||
|
code: Key::Char(c), ..
|
||||||
|
}) => {
|
||||||
|
self.component.perform(Cmd::Type(c));
|
||||||
|
Some(Msg::None)
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
289
src/ui/activities/filetransfer/components/terminal/component.rs
Normal file
289
src/ui/activities/filetransfer/components/terminal/component.rs
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
use tui_term::vt100::Parser;
|
||||||
|
use tui_term::widget::PseudoTerminal;
|
||||||
|
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||||
|
use tuirealm::props::{BorderSides, BorderType, Style};
|
||||||
|
use tuirealm::ratatui::layout::Rect;
|
||||||
|
use tuirealm::ratatui::widgets::Block;
|
||||||
|
use tuirealm::{AttrValue, Attribute, MockComponent, Props, State, StateValue};
|
||||||
|
|
||||||
|
use super::Line;
|
||||||
|
use super::history::History;
|
||||||
|
|
||||||
|
const DEFAULT_HISTORY_SIZE: usize = 128;
|
||||||
|
|
||||||
|
pub struct TerminalComponent {
|
||||||
|
pub parser: Parser,
|
||||||
|
history: History,
|
||||||
|
line: Line,
|
||||||
|
props: Props,
|
||||||
|
scroll: usize,
|
||||||
|
size: (u16, u16),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for TerminalComponent {
|
||||||
|
fn default() -> Self {
|
||||||
|
let props = Props::default();
|
||||||
|
let parser = Parser::new(40, 220, 2048);
|
||||||
|
|
||||||
|
TerminalComponent {
|
||||||
|
parser,
|
||||||
|
history: History::new(DEFAULT_HISTORY_SIZE),
|
||||||
|
line: Line::default(),
|
||||||
|
props,
|
||||||
|
scroll: 0,
|
||||||
|
size: (40, 220),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TerminalComponent {
|
||||||
|
/// Set prompt line for the terminal
|
||||||
|
pub fn prompt(mut self, prompt: impl ToString) -> Self {
|
||||||
|
self.attr(Attribute::Content, AttrValue::String(prompt.to_string()));
|
||||||
|
self.write_prompt();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_prompt(&mut self) {
|
||||||
|
if let Some(value) = self.query(Attribute::Content) {
|
||||||
|
let prompt = value.unwrap_string();
|
||||||
|
self.parser.process(prompt.as_bytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set current line to the previous command in the [`History`]
|
||||||
|
fn history_prev(&mut self) {
|
||||||
|
if let Some(cmd) = self.history.previous() {
|
||||||
|
self.write_line(cmd.as_bytes());
|
||||||
|
self.line.set(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set current line to the next command in the [`History`]
|
||||||
|
fn history_next(&mut self) {
|
||||||
|
if let Some(cmd) = self.history.next() {
|
||||||
|
self.write_line(cmd.as_bytes());
|
||||||
|
self.line.set(cmd);
|
||||||
|
} else {
|
||||||
|
// If there is no next command, clear the line
|
||||||
|
self.line.set(String::new());
|
||||||
|
self.write_line(&[]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write a line to the terminal, processing it through the parser
|
||||||
|
fn write_line(&mut self, data: &[u8]) {
|
||||||
|
self.parser.process(b"\r");
|
||||||
|
// blank the line
|
||||||
|
self.write_prompt();
|
||||||
|
self.parser.process(&[b' '; 15]);
|
||||||
|
self.parser.process(b"\r");
|
||||||
|
self.write_prompt();
|
||||||
|
self.parser.process(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MockComponent for TerminalComponent {
|
||||||
|
fn attr(&mut self, attr: tuirealm::Attribute, value: AttrValue) {
|
||||||
|
if attr == Attribute::Text {
|
||||||
|
if let tuirealm::AttrValue::String(s) = value {
|
||||||
|
self.parser.process(b"\r");
|
||||||
|
self.parser.process(s.as_bytes());
|
||||||
|
self.parser.process(b"\r");
|
||||||
|
self.write_prompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.props.set(attr, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn perform(&mut self, cmd: Cmd) -> CmdResult {
|
||||||
|
match cmd {
|
||||||
|
Cmd::Type(s) => {
|
||||||
|
if !s.is_ascii() || self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Ignore non-ASCII characters or if scrolled
|
||||||
|
}
|
||||||
|
self.parser.process(&[s as u8]);
|
||||||
|
self.line.push(s);
|
||||||
|
CmdResult::Changed(self.state())
|
||||||
|
}
|
||||||
|
Cmd::Move(Direction::Down) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move down if not scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
self.history_next();
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Move(Direction::Left) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move up if not scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.line.left() {
|
||||||
|
self.parser.process(&[27, 91, 68]);
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Move(Direction::Right) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move up if not scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.line.right() {
|
||||||
|
self.parser.process(&[27, 91, 67]);
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Move(Direction::Up) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move up if not scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
self.history_prev();
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Cancel => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move to the beginning if scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self.line.is_empty() {
|
||||||
|
self.line.backspace();
|
||||||
|
self.parser.process(&[8]); // Backspace character
|
||||||
|
// delete the last character from the line
|
||||||
|
// write one empty character to the terminal
|
||||||
|
self.parser.process(&[32]); // Space character
|
||||||
|
self.parser.process(&[8]); // Backspace character
|
||||||
|
}
|
||||||
|
CmdResult::Changed(self.state())
|
||||||
|
}
|
||||||
|
Cmd::Delete => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move to the beginning if scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self.line.is_empty() {
|
||||||
|
self.line.delete();
|
||||||
|
self.parser.process(&[27, 91, 51, 126]); // Delete character
|
||||||
|
// write one empty character to the terminal
|
||||||
|
self.parser.process(&[32]); // Space character
|
||||||
|
self.parser.process(&[8]); // Backspace character
|
||||||
|
}
|
||||||
|
CmdResult::Changed(self.state())
|
||||||
|
}
|
||||||
|
Cmd::Scroll(Direction::Down) => {
|
||||||
|
self.scroll = self.scroll.saturating_sub(8);
|
||||||
|
self.parser.set_scrollback(self.scroll);
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Scroll(Direction::Up) => {
|
||||||
|
self.parser.set_scrollback(self.scroll.saturating_add(8));
|
||||||
|
let scrollback = self.parser.screen().scrollback();
|
||||||
|
self.scroll = scrollback;
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Toggle => {
|
||||||
|
// insert
|
||||||
|
self.parser.process(&[27, 91, 50, 126]); // Toggle insert mode
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::GoTo(Position::Begin) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move to the beginning if scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
for _ in 0..self.line.begin() {
|
||||||
|
self.parser.process(&[27, 91, 68]); // Move cursor to the left
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::GoTo(Position::End) => {
|
||||||
|
if self.scroll > 0 {
|
||||||
|
return CmdResult::None; // Cannot move to the beginning if scrolled
|
||||||
|
}
|
||||||
|
|
||||||
|
for _ in 0..self.line.end() {
|
||||||
|
self.parser.process(&[27, 91, 67]); // Move cursor to the right
|
||||||
|
}
|
||||||
|
CmdResult::None
|
||||||
|
}
|
||||||
|
Cmd::Submit => {
|
||||||
|
self.scroll = 0; // Reset scroll on submit
|
||||||
|
self.parser.set_scrollback(self.scroll);
|
||||||
|
|
||||||
|
if cfg!(target_family = "unix") {
|
||||||
|
self.parser.process(b"\n");
|
||||||
|
} else {
|
||||||
|
self.parser.process(b"\r\n\r");
|
||||||
|
}
|
||||||
|
|
||||||
|
let line = self.line.take();
|
||||||
|
if !line.is_empty() {
|
||||||
|
self.history.push(&line);
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdResult::Submit(State::One(StateValue::String(line)))
|
||||||
|
}
|
||||||
|
_ => CmdResult::None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn query(&self, attr: tuirealm::Attribute) -> Option<tuirealm::AttrValue> {
|
||||||
|
self.props.get(attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> State {
|
||||||
|
State::One(StateValue::String(self.line.content().to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(&mut self, frame: &mut tuirealm::Frame, area: Rect) {
|
||||||
|
let width = area.width.saturating_sub(2);
|
||||||
|
let height = area.height.saturating_sub(2);
|
||||||
|
|
||||||
|
// update the terminal size if it has changed
|
||||||
|
if self.size != (width, height) {
|
||||||
|
self.size = (width, height);
|
||||||
|
self.parser.set_size(height, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
let title = self
|
||||||
|
.query(Attribute::Title)
|
||||||
|
.map(|value| value.unwrap_string())
|
||||||
|
.unwrap_or_else(|| "Terminal".to_string());
|
||||||
|
|
||||||
|
let fg = self
|
||||||
|
.query(Attribute::Foreground)
|
||||||
|
.map(|value| value.unwrap_color())
|
||||||
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
|
let bg = self
|
||||||
|
.query(Attribute::Background)
|
||||||
|
.map(|value| value.unwrap_color())
|
||||||
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
|
let border_color = self
|
||||||
|
.query(Attribute::Borders)
|
||||||
|
.map(|value| value.unwrap_color())
|
||||||
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
|
let terminal = PseudoTerminal::new(self.parser.screen())
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
|
.title(title)
|
||||||
|
.border_type(BorderType::Rounded)
|
||||||
|
.border_style(Style::default().fg(border_color))
|
||||||
|
.borders(BorderSides::ALL)
|
||||||
|
.style(Style::default().fg(fg).bg(bg)),
|
||||||
|
)
|
||||||
|
.style(Style::default().fg(fg).bg(bg));
|
||||||
|
|
||||||
|
frame.render_widget(terminal, area);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
|
/// Shell history management module.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct History {
|
||||||
|
/// Entries in the history.
|
||||||
|
entries: VecDeque<String>,
|
||||||
|
/// Maximum size of the history.
|
||||||
|
max_size: usize,
|
||||||
|
/// Current index in the history for navigation.
|
||||||
|
index: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl History {
|
||||||
|
/// Create a new [`History`] with a specified maximum size.
|
||||||
|
pub fn new(max_size: usize) -> Self {
|
||||||
|
History {
|
||||||
|
entries: VecDeque::with_capacity(max_size),
|
||||||
|
max_size,
|
||||||
|
index: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Push a new command into the history.
|
||||||
|
pub fn push(&mut self, cmd: &str) {
|
||||||
|
if self.entries.len() == self.max_size {
|
||||||
|
self.entries.pop_front();
|
||||||
|
}
|
||||||
|
self.entries.push_back(cmd.to_string());
|
||||||
|
self.index = self.entries.len(); // Reset index to the end after adding a new command
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the previous command in the history.
|
||||||
|
///
|
||||||
|
/// Set also the index to the last command if it exists.
|
||||||
|
pub fn previous(&mut self) -> Option<String> {
|
||||||
|
if self.index > 0 {
|
||||||
|
self.index -= 1;
|
||||||
|
self.entries.get(self.index).cloned()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the next command in the history.
|
||||||
|
///
|
||||||
|
/// Set also the index to the next command if it exists.
|
||||||
|
pub fn next(&mut self) -> Option<String> {
|
||||||
|
if self.index < self.entries.len() {
|
||||||
|
let cmd = self.entries.get(self.index).cloned();
|
||||||
|
self.index += 1;
|
||||||
|
cmd
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::History;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_history() {
|
||||||
|
let mut history = History::new(5);
|
||||||
|
history.push("first");
|
||||||
|
history.push("second");
|
||||||
|
history.push("third");
|
||||||
|
|
||||||
|
assert_eq!(history.previous(), Some("third".to_string()));
|
||||||
|
assert_eq!(history.previous(), Some("second".to_string()));
|
||||||
|
assert_eq!(history.previous(), Some("first".to_string()));
|
||||||
|
assert_eq!(history.previous(), None); // No more previous commands
|
||||||
|
assert_eq!(history.next(), Some("first".to_string()));
|
||||||
|
assert_eq!(history.next(), Some("second".to_string()));
|
||||||
|
assert_eq!(history.next(), Some("third".to_string()));
|
||||||
|
assert_eq!(history.next(), None); // No more next commands
|
||||||
|
history.push("fourth");
|
||||||
|
assert_eq!(history.previous(), Some("fourth".to_string()));
|
||||||
|
}
|
||||||
|
}
|
||||||
220
src/ui/activities/filetransfer/components/terminal/line.rs
Normal file
220
src/ui/activities/filetransfer/components/terminal/line.rs
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
/// A simple line for the shell, which keeps track of the current
|
||||||
|
/// content and the cursor position.
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct Line {
|
||||||
|
content: String,
|
||||||
|
cursor: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Line {
|
||||||
|
/// Set the content of the line and reset the cursor to the end.
|
||||||
|
pub fn set(&mut self, content: String) {
|
||||||
|
self.cursor = content.len();
|
||||||
|
self.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push a character to the line at the current cursor position.
|
||||||
|
pub fn push(&mut self, c: char) {
|
||||||
|
self.content.insert(self.cursor, c);
|
||||||
|
self.cursor += c.len_utf8();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Take the current line content and reset the cursor.
|
||||||
|
pub fn take(&mut self) -> String {
|
||||||
|
self.cursor = 0;
|
||||||
|
std::mem::take(&mut self.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a reference to the current line content.
|
||||||
|
pub fn content(&self) -> &str {
|
||||||
|
&self.content
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the cursor to the left, if possible.
|
||||||
|
///
|
||||||
|
/// Returns `true` if the cursor was moved, `false` if it was already at the beginning.
|
||||||
|
pub fn left(&mut self) -> bool {
|
||||||
|
if self.cursor > 0 {
|
||||||
|
// get the previous character length
|
||||||
|
let prev_char_len = self
|
||||||
|
.content
|
||||||
|
.chars()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(i, c)| {
|
||||||
|
if i < self.cursor {
|
||||||
|
Some(c.len_utf8())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.last()
|
||||||
|
.unwrap();
|
||||||
|
self.cursor -= prev_char_len;
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the cursor to the right, if possible.
|
||||||
|
///
|
||||||
|
/// Returns `true` if the cursor was moved, `false` if it was already at the end.
|
||||||
|
pub fn right(&mut self) -> bool {
|
||||||
|
if self.cursor < self.content.len() {
|
||||||
|
// get the next character length
|
||||||
|
let next_char_len = self.content[self.cursor..]
|
||||||
|
.chars()
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.len_utf8();
|
||||||
|
self.cursor += next_char_len;
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the cursor to the beginning of the line.
|
||||||
|
///
|
||||||
|
/// Returns the previous cursor position.
|
||||||
|
pub fn begin(&mut self) -> usize {
|
||||||
|
std::mem::take(&mut self.cursor)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Move the cursor to the end of the line.
|
||||||
|
///
|
||||||
|
/// Returns the difference between the previous cursor position and the new position.
|
||||||
|
pub fn end(&mut self) -> usize {
|
||||||
|
let diff = self.content.len() - self.cursor;
|
||||||
|
self.cursor = self.content.len();
|
||||||
|
|
||||||
|
diff
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Remove the previous character from the line at the current cursor position.
|
||||||
|
pub fn backspace(&mut self) {
|
||||||
|
if self.cursor > 0 {
|
||||||
|
let prev_char_len = self
|
||||||
|
.content
|
||||||
|
.chars()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(i, c)| {
|
||||||
|
if i < self.cursor {
|
||||||
|
Some(c.len_utf8())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.last()
|
||||||
|
.unwrap();
|
||||||
|
self.content.remove(self.cursor - prev_char_len);
|
||||||
|
self.cursor -= prev_char_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deletes the character at the current cursor position.
|
||||||
|
pub fn delete(&mut self) {
|
||||||
|
if self.cursor < self.content.len() {
|
||||||
|
self.content.remove(self.cursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether the line is empty.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.content.is_empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_line() {
|
||||||
|
let mut line = Line::default();
|
||||||
|
assert!(line.is_empty());
|
||||||
|
|
||||||
|
line.push('H');
|
||||||
|
line.push('e');
|
||||||
|
line.push('l');
|
||||||
|
line.push('l');
|
||||||
|
line.push('o');
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
|
||||||
|
line.left();
|
||||||
|
line.left();
|
||||||
|
line.push(' ');
|
||||||
|
assert_eq!(line.content(), "Hel lo");
|
||||||
|
|
||||||
|
line.begin();
|
||||||
|
line.push('W');
|
||||||
|
assert_eq!(line.content(), "WHel lo");
|
||||||
|
|
||||||
|
line.end();
|
||||||
|
line.push('!');
|
||||||
|
assert_eq!(line.content(), "WHel lo!");
|
||||||
|
|
||||||
|
let taken = line.take();
|
||||||
|
assert_eq!(taken, "WHel lo!");
|
||||||
|
assert!(line.is_empty());
|
||||||
|
|
||||||
|
line.set("New Line".to_string());
|
||||||
|
assert_eq!(line.content(), "New Line");
|
||||||
|
|
||||||
|
line.backspace();
|
||||||
|
assert_eq!(line.content(), "New Lin");
|
||||||
|
line.left();
|
||||||
|
line.delete();
|
||||||
|
assert_eq!(line.content(), "New Li");
|
||||||
|
line.left();
|
||||||
|
line.left();
|
||||||
|
line.right();
|
||||||
|
assert_eq!(line.content(), "New Li");
|
||||||
|
line.end();
|
||||||
|
assert_eq!(line.content(), "New Li");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_should_return_whether_the_cursor_was_moved() {
|
||||||
|
let mut line = Line::default();
|
||||||
|
line.set("Hello".to_string());
|
||||||
|
|
||||||
|
assert!(line.left());
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
assert_eq!(line.cursor, 4);
|
||||||
|
|
||||||
|
assert!(line.left());
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
assert_eq!(line.cursor, 3);
|
||||||
|
|
||||||
|
assert!(line.right());
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
assert_eq!(line.cursor, 4);
|
||||||
|
assert!(line.right());
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
assert!(!line.right());
|
||||||
|
assert_eq!(line.cursor, 5);
|
||||||
|
assert!(!line.right());
|
||||||
|
|
||||||
|
line.end();
|
||||||
|
assert!(!line.right());
|
||||||
|
assert_eq!(line.content(), "Hello");
|
||||||
|
assert_eq!(line.cursor, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_should_allow_utf8_cursors() {
|
||||||
|
let mut line = Line::default();
|
||||||
|
line.set("Hello, 世界".to_string());
|
||||||
|
assert_eq!(line.content(), "Hello, 世界");
|
||||||
|
assert_eq!(line.cursor, 13); // "Hello, " is 7 bytes, "世界" is 6 bytes
|
||||||
|
|
||||||
|
assert!(line.left());
|
||||||
|
assert_eq!(line.content(), "Hello, 世界");
|
||||||
|
assert_eq!(line.cursor, 10); // Move left to '世'
|
||||||
|
assert!(line.left());
|
||||||
|
assert_eq!(line.content(), "Hello, 世界");
|
||||||
|
assert_eq!(line.cursor, 7); // Move left to ','
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,20 +17,17 @@ const PROP_DOT_DOT: &str = "dot_dot";
|
|||||||
/// OwnStates contains states for this component
|
/// OwnStates contains states for this component
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
struct OwnStates {
|
struct OwnStates {
|
||||||
list_index: usize, // Index of selected element in list
|
list_index: usize, // Index of selected element in list
|
||||||
selected: Vec<usize>, // Selected files
|
list_len: usize, // Length of the list
|
||||||
|
dot_dot: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OwnStates {
|
impl OwnStates {
|
||||||
/// Initialize list states
|
/// Initialize list states
|
||||||
pub fn init_list_states(&mut self, len: usize, has_dot_dot: bool) {
|
pub fn init_list_states(&mut self, len: usize, has_dot_dot: bool) {
|
||||||
self.selected = Vec::with_capacity(len + if has_dot_dot { 1 } else { 0 });
|
self.list_len = len + if has_dot_dot { 1 } else { 0 };
|
||||||
self.fix_list_index();
|
self.fix_list_index();
|
||||||
}
|
self.dot_dot = has_dot_dot;
|
||||||
|
|
||||||
/// Return current value for list index
|
|
||||||
pub fn list_index(&self) -> usize {
|
|
||||||
self.list_index
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Incremenet list index.
|
/// Incremenet list index.
|
||||||
@@ -44,6 +41,14 @@ impl OwnStates {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn real_index(&self) -> usize {
|
||||||
|
if self.dot_dot {
|
||||||
|
self.list_index.saturating_sub(1)
|
||||||
|
} else {
|
||||||
|
self.list_index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Decrement list index
|
/// Decrement list index
|
||||||
/// If `can_rewind` is `true` the index rewinds when boundary is reached
|
/// If `can_rewind` is `true` the index rewinds when boundary is reached
|
||||||
pub fn decr_list_index(&mut self, can_rewind: bool) {
|
pub fn decr_list_index(&mut self, can_rewind: bool) {
|
||||||
@@ -68,22 +73,7 @@ impl OwnStates {
|
|||||||
|
|
||||||
/// Returns the length of the file list, which is actually the capacity of the selection vector
|
/// Returns the length of the file list, which is actually the capacity of the selection vector
|
||||||
pub fn list_len(&self) -> usize {
|
pub fn list_len(&self) -> usize {
|
||||||
self.selected.capacity()
|
self.list_len
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns whether the file with index `entry` is selected
|
|
||||||
pub fn is_selected(&self, entry: usize) -> bool {
|
|
||||||
self.selected.contains(&entry)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns whether the selection is currently empty
|
|
||||||
pub fn is_selection_empty(&self) -> bool {
|
|
||||||
self.selected.is_empty()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns current file selection
|
|
||||||
pub fn get_selection(&self) -> Vec<usize> {
|
|
||||||
self.selected.clone()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Keep index if possible, otherwise set to lenght - 1
|
/// Keep index if possible, otherwise set to lenght - 1
|
||||||
@@ -94,44 +84,6 @@ impl OwnStates {
|
|||||||
self.list_index = 0;
|
self.list_index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- select manipulation
|
|
||||||
|
|
||||||
/// Select or deselect file with provided entry index
|
|
||||||
pub fn toggle_file(&mut self, entry: usize) {
|
|
||||||
match self.is_selected(entry) {
|
|
||||||
true => self.deselect(entry),
|
|
||||||
false => self.select(entry),
|
|
||||||
}
|
|
||||||
// increment index
|
|
||||||
self.incr_list_index(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Select all files
|
|
||||||
pub fn select_all(&mut self, has_dot_dot: bool) {
|
|
||||||
for i in 0..self.list_len() {
|
|
||||||
self.select(i + if has_dot_dot { 1 } else { 0 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Select all files
|
|
||||||
pub fn deselect_all(&mut self) {
|
|
||||||
self.selected.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Select provided index if not selected yet
|
|
||||||
fn select(&mut self, entry: usize) {
|
|
||||||
if !self.is_selected(entry) {
|
|
||||||
self.selected.push(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove element file with associated index
|
|
||||||
fn deselect(&mut self, entry: usize) {
|
|
||||||
if self.is_selected(entry) {
|
|
||||||
self.selected.retain(|&x| x != entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -206,7 +158,7 @@ impl MockComponent for FileList {
|
|||||||
.props
|
.props
|
||||||
.get_or(Attribute::Focus, AttrValue::Flag(false))
|
.get_or(Attribute::Focus, AttrValue::Flag(false))
|
||||||
.unwrap_flag();
|
.unwrap_flag();
|
||||||
let div = tui_realm_stdlib::utils::get_block(borders, Some(title), focus, None);
|
let div = tui_realm_stdlib::utils::get_block(borders, Some(&title), focus, None);
|
||||||
// Make list entries
|
// Make list entries
|
||||||
let init_table_iter = if self.has_dot_dot() {
|
let init_table_iter = if self.has_dot_dot() {
|
||||||
vec![vec![TextSpan::from("..")]]
|
vec![vec![TextSpan::from("..")]]
|
||||||
@@ -222,27 +174,12 @@ impl MockComponent for FileList {
|
|||||||
Some(table) => init_table_iter
|
Some(table) => init_table_iter
|
||||||
.iter()
|
.iter()
|
||||||
.chain(table.iter())
|
.chain(table.iter())
|
||||||
.enumerate()
|
.map(|row| {
|
||||||
.map(|(num, row)| {
|
|
||||||
let real_num = num;
|
|
||||||
let num = if self.has_dot_dot() {
|
|
||||||
num.checked_sub(1).unwrap_or_default()
|
|
||||||
} else {
|
|
||||||
num
|
|
||||||
};
|
|
||||||
|
|
||||||
let columns: Vec<Span> = row
|
let columns: Vec<Span> = row
|
||||||
.iter()
|
.iter()
|
||||||
.map(|col| {
|
.map(|col| {
|
||||||
let (fg, bg, mut modifiers) =
|
let (fg, bg, modifiers) =
|
||||||
tui_realm_stdlib::utils::use_or_default_styles(&self.props, col);
|
tui_realm_stdlib::utils::use_or_default_styles(&self.props, col);
|
||||||
if !(self.has_dot_dot() && real_num == 0)
|
|
||||||
&& self.states.is_selected(num)
|
|
||||||
{
|
|
||||||
modifiers |= TextModifiers::REVERSED
|
|
||||||
| TextModifiers::UNDERLINED
|
|
||||||
| TextModifiers::ITALIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
Span::styled(
|
Span::styled(
|
||||||
col.content.clone(),
|
col.content.clone(),
|
||||||
@@ -302,20 +239,11 @@ impl MockComponent for FileList {
|
|||||||
return State::One(StateValue::String("..".to_string()));
|
return State::One(StateValue::String("..".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.states.is_selection_empty() {
|
State::One(StateValue::Usize(if self.has_dot_dot() {
|
||||||
true => State::One(StateValue::Usize(if self.has_dot_dot() {
|
self.states.list_index.checked_sub(1).unwrap_or_default()
|
||||||
self.states.list_index.checked_sub(1).unwrap_or_default()
|
} else {
|
||||||
} else {
|
self.states.list_index
|
||||||
self.states.list_index
|
}))
|
||||||
})),
|
|
||||||
false => State::Vec(
|
|
||||||
self.states
|
|
||||||
.get_selection()
|
|
||||||
.into_iter()
|
|
||||||
.map(StateValue::Usize)
|
|
||||||
.collect(),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perform(&mut self, cmd: Cmd) -> CmdResult {
|
fn perform(&mut self, cmd: Cmd) -> CmdResult {
|
||||||
@@ -374,25 +302,18 @@ impl MockComponent for FileList {
|
|||||||
CmdResult::None
|
CmdResult::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::Custom(FILE_LIST_CMD_SELECT_ALL) => {
|
|
||||||
self.states.select_all(self.has_dot_dot());
|
|
||||||
CmdResult::None
|
|
||||||
}
|
|
||||||
Cmd::Custom(FILE_LIST_CMD_DESELECT_ALL) => {
|
|
||||||
self.states.deselect_all();
|
|
||||||
CmdResult::None
|
|
||||||
}
|
|
||||||
Cmd::Toggle => {
|
Cmd::Toggle => {
|
||||||
if self.has_dot_dot() && self.states.list_index() == 0 {
|
if self.states.list_index == 0 && self.has_dot_dot() {
|
||||||
return CmdResult::None;
|
return CmdResult::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.states.toggle_file(if self.has_dot_dot() {
|
let index = self.states.real_index();
|
||||||
self.states.list_index().checked_sub(1).unwrap_or_default()
|
self.states.list_index = self
|
||||||
} else {
|
.states
|
||||||
self.states.list_index()
|
.list_index
|
||||||
});
|
.saturating_add(1)
|
||||||
CmdResult::None
|
.min(self.states.list_len.saturating_sub(1));
|
||||||
|
CmdResult::Changed(State::One(StateValue::Usize(index)))
|
||||||
}
|
}
|
||||||
_ => CmdResult::None,
|
_ => CmdResult::None,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ impl FileListWithSearch {
|
|||||||
|
|
||||||
pub fn borders(mut self, b: Borders) -> Self {
|
pub fn borders(mut self, b: Borders) -> Self {
|
||||||
self.file_list
|
self.file_list
|
||||||
.attr(Attribute::Borders, AttrValue::Borders(b.clone()));
|
.attr(Attribute::Borders, AttrValue::Borders(b));
|
||||||
self.search.attr(Attribute::Borders, AttrValue::Borders(b));
|
self.search.attr(Attribute::Borders, AttrValue::Borders(b));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ impl ExplorerFuzzy {
|
|||||||
.foreground(fg)
|
.foreground(fg)
|
||||||
.highlighted_color(hg)
|
.highlighted_color(hg)
|
||||||
.title(title, Alignment::Left)
|
.title(title, Alignment::Left)
|
||||||
.rows(files.iter().map(|x| vec![TextSpan::from(x)]).collect()),
|
.rows(files.iter().map(|x| vec![TextSpan::from(*x)]).collect()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,21 +132,26 @@ impl ExplorerFuzzy {
|
|||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkAll))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('a'),
|
code: Key::Char('a'),
|
||||||
modifiers: KeyModifiers::ALT,
|
modifiers: KeyModifiers::ALT,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkClear))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('m'),
|
code: Key::Char('m'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Toggle);
|
let CmdResult::Changed(State::One(StateValue::Usize(index))) =
|
||||||
Some(Msg::None)
|
self.perform(Cmd::Toggle)
|
||||||
|
else {
|
||||||
|
return Some(Msg::None);
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Msg::Ui(UiMsg::MarkFile(index)))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||||
self.perform(Cmd::Change);
|
self.perform(Cmd::Change);
|
||||||
@@ -231,7 +236,7 @@ impl ExplorerFind {
|
|||||||
.foreground(fg)
|
.foreground(fg)
|
||||||
.highlighted_color(hg)
|
.highlighted_color(hg)
|
||||||
.title(title, Alignment::Left)
|
.title(title, Alignment::Left)
|
||||||
.rows(files.iter().map(|x| vec![TextSpan::from(x)]).collect()),
|
.rows(files.iter().map(|x| vec![TextSpan::from(*x)]).collect()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,21 +282,26 @@ impl Component<Msg, NoUserEvent> for ExplorerFind {
|
|||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkAll))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('a'),
|
code: Key::Char('a'),
|
||||||
modifiers: KeyModifiers::ALT,
|
modifiers: KeyModifiers::ALT,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkClear))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('m'),
|
code: Key::Char('m'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Toggle);
|
let CmdResult::Changed(State::One(StateValue::Usize(index))) =
|
||||||
Some(Msg::None)
|
self.perform(Cmd::Toggle)
|
||||||
|
else {
|
||||||
|
return Some(Msg::None);
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Msg::Ui(UiMsg::MarkFile(index)))
|
||||||
}
|
}
|
||||||
// -- comp msg
|
// -- comp msg
|
||||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||||
@@ -363,7 +373,7 @@ impl ExplorerLocal {
|
|||||||
.foreground(fg)
|
.foreground(fg)
|
||||||
.highlighted_color(hg)
|
.highlighted_color(hg)
|
||||||
.title(title, Alignment::Left)
|
.title(title, Alignment::Left)
|
||||||
.rows(files.iter().map(|x| vec![TextSpan::from(x)]).collect())
|
.rows(files.iter().map(|x| vec![TextSpan::from(*x)]).collect())
|
||||||
.dot_dot(true),
|
.dot_dot(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,21 +420,26 @@ impl Component<Msg, NoUserEvent> for ExplorerLocal {
|
|||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkAll))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('a'),
|
code: Key::Char('a'),
|
||||||
modifiers: KeyModifiers::ALT,
|
modifiers: KeyModifiers::ALT,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkClear))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('m'),
|
code: Key::Char('m'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Toggle);
|
let CmdResult::Changed(State::One(StateValue::Usize(index))) =
|
||||||
Some(Msg::None)
|
self.perform(Cmd::Toggle)
|
||||||
|
else {
|
||||||
|
return Some(Msg::None);
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Msg::Ui(UiMsg::MarkFile(index)))
|
||||||
}
|
}
|
||||||
// -- comp msg
|
// -- comp msg
|
||||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||||
@@ -508,7 +523,7 @@ impl Component<Msg, NoUserEvent> for ExplorerLocal {
|
|||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('p'),
|
code: Key::Char('p'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => Some(Msg::Ui(UiMsg::ShowLogPanel)),
|
}) => Some(Msg::Ui(UiMsg::GoToTransferQueue)),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('r') | Key::Function(6),
|
code: Key::Char('r') | Key::Function(6),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
@@ -532,7 +547,7 @@ impl Component<Msg, NoUserEvent> for ExplorerLocal {
|
|||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('x'),
|
code: Key::Char('x'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => Some(Msg::Ui(UiMsg::ShowExecPopup)),
|
}) => Some(Msg::Ui(UiMsg::ShowTerminal)),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('y'),
|
code: Key::Char('y'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
@@ -572,7 +587,7 @@ impl ExplorerRemote {
|
|||||||
.foreground(fg)
|
.foreground(fg)
|
||||||
.highlighted_color(hg)
|
.highlighted_color(hg)
|
||||||
.title(title, Alignment::Left)
|
.title(title, Alignment::Left)
|
||||||
.rows(files.iter().map(|x| vec![TextSpan::from(x)]).collect())
|
.rows(files.iter().map(|x| vec![TextSpan::from(*x)]).collect())
|
||||||
.dot_dot(true),
|
.dot_dot(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -619,21 +634,26 @@ impl Component<Msg, NoUserEvent> for ExplorerRemote {
|
|||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkAll))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('a'),
|
code: Key::Char('a'),
|
||||||
modifiers: KeyModifiers::ALT,
|
modifiers: KeyModifiers::ALT,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
|
||||||
Some(Msg::None)
|
Some(Msg::Ui(UiMsg::MarkClear))
|
||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('m'),
|
code: Key::Char('m'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => {
|
}) => {
|
||||||
let _ = self.perform(Cmd::Toggle);
|
let CmdResult::Changed(State::One(StateValue::Usize(index))) =
|
||||||
Some(Msg::None)
|
self.perform(Cmd::Toggle)
|
||||||
|
else {
|
||||||
|
return Some(Msg::None);
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Msg::Ui(UiMsg::MarkFile(index)))
|
||||||
}
|
}
|
||||||
// -- comp msg
|
// -- comp msg
|
||||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||||
@@ -717,7 +737,7 @@ impl Component<Msg, NoUserEvent> for ExplorerRemote {
|
|||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('p'),
|
code: Key::Char('p'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => Some(Msg::Ui(UiMsg::ShowLogPanel)),
|
}) => Some(Msg::Ui(UiMsg::GoToTransferQueue)),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('r') | Key::Function(6),
|
code: Key::Char('r') | Key::Function(6),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
@@ -741,7 +761,7 @@ impl Component<Msg, NoUserEvent> for ExplorerRemote {
|
|||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('x'),
|
code: Key::Char('x'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => Some(Msg::Ui(UiMsg::ShowExecPopup)),
|
}) => Some(Msg::Ui(UiMsg::ShowTerminal)),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
code: Key::Char('y'),
|
code: Key::Char('y'),
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
|
|||||||
@@ -60,6 +60,23 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn other_explorer_no_found(&self) -> &FileExplorer {
|
||||||
|
match self.tab {
|
||||||
|
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => &self.remote,
|
||||||
|
FileExplorerTab::Remote | FileExplorerTab::FindRemote => &self.host_bridge,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn explorer_mut(&mut self) -> &mut FileExplorer {
|
||||||
|
match self.tab {
|
||||||
|
FileExplorerTab::HostBridge => &mut self.host_bridge,
|
||||||
|
FileExplorerTab::Remote => &mut self.remote,
|
||||||
|
FileExplorerTab::FindHostBridge | FileExplorerTab::FindRemote => {
|
||||||
|
self.found.as_mut().map(|x| &mut x.explorer).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn host_bridge(&self) -> &FileExplorer {
|
pub fn host_bridge(&self) -> &FileExplorer {
|
||||||
&self.host_bridge
|
&self.host_bridge
|
||||||
}
|
}
|
||||||
@@ -131,6 +148,25 @@ impl Browser {
|
|||||||
self.sync_browsing = !self.sync_browsing;
|
self.sync_browsing = !self.sync_browsing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Toggle terminal for the current tab
|
||||||
|
pub fn toggle_terminal(&mut self, terminal: bool) {
|
||||||
|
if self.tab == FileExplorerTab::HostBridge {
|
||||||
|
self.host_bridge.toggle_terminal(terminal);
|
||||||
|
} else if self.tab == FileExplorerTab::Remote {
|
||||||
|
self.remote.toggle_terminal(terminal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if terminal is open for the host bridge tab
|
||||||
|
pub fn is_terminal_open_host_bridge(&self) -> bool {
|
||||||
|
self.tab == FileExplorerTab::HostBridge && self.host_bridge.terminal_open()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if terminal is open for the remote tab
|
||||||
|
pub fn is_terminal_open_remote(&self) -> bool {
|
||||||
|
self.tab == FileExplorerTab::Remote && self.remote.terminal_open()
|
||||||
|
}
|
||||||
|
|
||||||
/// Build a file explorer with local host setup
|
/// Build a file explorer with local host setup
|
||||||
pub fn build_local_explorer(cli: &ConfigClient) -> FileExplorer {
|
pub fn build_local_explorer(cli: &ConfigClient) -> FileExplorer {
|
||||||
let mut builder = Self::build_explorer(cli);
|
let mut builder = Self::build_explorer(cli);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ use std::path::{Path, PathBuf};
|
|||||||
|
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use tuirealm::props::{
|
use tuirealm::props::{
|
||||||
Alignment, AttrValue, Attribute, Color, PropPayload, PropValue, TableBuilder, TextSpan,
|
Alignment, AttrValue, Attribute, Color, PropPayload, PropValue, TableBuilder, TextModifiers,
|
||||||
|
TextSpan,
|
||||||
};
|
};
|
||||||
use tuirealm::{PollStrategy, Update};
|
use tuirealm::{PollStrategy, Update};
|
||||||
|
|
||||||
@@ -90,7 +91,9 @@ impl FileTransferActivity {
|
|||||||
|
|
||||||
/// Set text editor to use
|
/// Set text editor to use
|
||||||
pub(super) fn setup_text_editor(&self) {
|
pub(super) fn setup_text_editor(&self) {
|
||||||
env::set_var("EDITOR", self.config().get_text_editor());
|
unsafe {
|
||||||
|
env::set_var("EDITOR", self.config().get_text_editor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a path to absolute according to host explorer
|
/// Convert a path to absolute according to host explorer
|
||||||
@@ -225,7 +228,7 @@ impl FileTransferActivity {
|
|||||||
transfer_stats
|
transfer_stats
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
TransferPayload::Many(entries) => {
|
TransferPayload::TransferQueue(entries) => {
|
||||||
format!(
|
format!(
|
||||||
"{} files has been successfully transferred ({})",
|
"{} files has been successfully transferred ({})",
|
||||||
entries.len(),
|
entries.len(),
|
||||||
@@ -238,6 +241,11 @@ impl FileTransferActivity {
|
|||||||
/// Update host bridge file list
|
/// Update host bridge file list
|
||||||
pub(super) fn update_host_bridge_filelist(&mut self) {
|
pub(super) fn update_host_bridge_filelist(&mut self) {
|
||||||
self.reload_host_bridge_dir();
|
self.reload_host_bridge_dir();
|
||||||
|
self.reload_host_bridge_filelist();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update host bridge file list
|
||||||
|
pub(super) fn reload_host_bridge_filelist(&mut self) {
|
||||||
// Get width
|
// Get width
|
||||||
let width = self
|
let width = self
|
||||||
.context_mut()
|
.context_mut()
|
||||||
@@ -259,31 +267,108 @@ impl FileTransferActivity {
|
|||||||
let files: Vec<Vec<TextSpan>> = self
|
let files: Vec<Vec<TextSpan>> = self
|
||||||
.host_bridge()
|
.host_bridge()
|
||||||
.iter_files()
|
.iter_files()
|
||||||
.map(|x| vec![TextSpan::from(self.host_bridge().fmt_file(x))])
|
.map(|x| {
|
||||||
|
let mut span = TextSpan::from(self.host_bridge().fmt_file(x));
|
||||||
|
if self.host_bridge().enqueued().contains_key(x.path()) {
|
||||||
|
span.modifiers |=
|
||||||
|
TextModifiers::REVERSED | TextModifiers::UNDERLINED | TextModifiers::ITALIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec![span]
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
// Update content and title
|
// Update content and title
|
||||||
assert!(self
|
assert!(
|
||||||
.app
|
self.app
|
||||||
.attr(
|
.attr(
|
||||||
&Id::ExplorerHostBridge,
|
&Id::ExplorerHostBridge,
|
||||||
Attribute::Content,
|
Attribute::Content,
|
||||||
AttrValue::Table(files)
|
AttrValue::Table(files)
|
||||||
)
|
)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
assert!(self
|
);
|
||||||
.app
|
assert!(
|
||||||
.attr(
|
self.app
|
||||||
&Id::ExplorerHostBridge,
|
.attr(
|
||||||
Attribute::Title,
|
&Id::ExplorerHostBridge,
|
||||||
AttrValue::Title((hostname, Alignment::Left))
|
Attribute::Title,
|
||||||
)
|
AttrValue::Title((hostname, Alignment::Left))
|
||||||
.is_ok());
|
)
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update remote file list
|
/// Update remote file list
|
||||||
pub(super) fn update_remote_filelist(&mut self) {
|
pub(super) fn update_remote_filelist(&mut self) {
|
||||||
self.reload_remote_dir();
|
self.reload_remote_dir();
|
||||||
|
self.reload_remote_filelist();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn get_tab_hostname(&self) -> String {
|
||||||
|
match self.browser.tab() {
|
||||||
|
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => {
|
||||||
|
self.get_hostbridge_hostname()
|
||||||
|
}
|
||||||
|
FileExplorerTab::Remote | FileExplorerTab::FindRemote => self.get_remote_hostname(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn terminal_prompt(&self) -> String {
|
||||||
|
const TERM_CYAN: &str = "\x1b[36m";
|
||||||
|
const TERM_GREEN: &str = "\x1b[32m";
|
||||||
|
const TERM_YELLOW: &str = "\x1b[33m";
|
||||||
|
const TERM_RESET: &str = "\x1b[0m";
|
||||||
|
|
||||||
|
let panel = self.browser.tab();
|
||||||
|
match panel {
|
||||||
|
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => {
|
||||||
|
let username = self
|
||||||
|
.context()
|
||||||
|
.host_bridge_params()
|
||||||
|
.and_then(|params| {
|
||||||
|
params
|
||||||
|
.username()
|
||||||
|
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
||||||
|
})
|
||||||
|
.unwrap_or("".to_string());
|
||||||
|
let hostname = self.get_hostbridge_hostname();
|
||||||
|
format!(
|
||||||
|
"{username}{TERM_GREEN}{hostname}:{TERM_YELLOW}{}{TERM_RESET}$ ",
|
||||||
|
fmt_path_elide_ex(
|
||||||
|
self.host_bridge().wrkdir.as_path(),
|
||||||
|
0,
|
||||||
|
hostname.len() + 3 // 3 because of '/…/'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
FileExplorerTab::Remote | FileExplorerTab::FindRemote => {
|
||||||
|
let username = self
|
||||||
|
.context()
|
||||||
|
.remote_params()
|
||||||
|
.and_then(|params| {
|
||||||
|
params
|
||||||
|
.username()
|
||||||
|
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
||||||
|
})
|
||||||
|
.unwrap_or("".to_string());
|
||||||
|
let hostname = self.get_remote_hostname();
|
||||||
|
let fmt_path = fmt_path_elide_ex(
|
||||||
|
self.remote().wrkdir.as_path(),
|
||||||
|
0,
|
||||||
|
hostname.len() + 3, // 3 because of '/…/'
|
||||||
|
);
|
||||||
|
let fmt_path = if fmt_path.starts_with('/') {
|
||||||
|
fmt_path
|
||||||
|
} else {
|
||||||
|
format!("/{}", fmt_path)
|
||||||
|
};
|
||||||
|
|
||||||
|
format!("{username}{TERM_GREEN}{hostname}:{TERM_YELLOW}{fmt_path}{TERM_RESET}$ ",)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn reload_remote_filelist(&mut self) {
|
||||||
let width = self
|
let width = self
|
||||||
.context_mut()
|
.context_mut()
|
||||||
.terminal()
|
.terminal()
|
||||||
@@ -304,25 +389,35 @@ impl FileTransferActivity {
|
|||||||
let files: Vec<Vec<TextSpan>> = self
|
let files: Vec<Vec<TextSpan>> = self
|
||||||
.remote()
|
.remote()
|
||||||
.iter_files()
|
.iter_files()
|
||||||
.map(|x| vec![TextSpan::from(self.remote().fmt_file(x))])
|
.map(|x| {
|
||||||
|
let mut span = TextSpan::from(self.remote().fmt_file(x));
|
||||||
|
if self.remote().enqueued().contains_key(x.path()) {
|
||||||
|
span.modifiers |=
|
||||||
|
TextModifiers::REVERSED | TextModifiers::UNDERLINED | TextModifiers::ITALIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec![span]
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
// Update content and title
|
// Update content and title
|
||||||
assert!(self
|
assert!(
|
||||||
.app
|
self.app
|
||||||
.attr(
|
.attr(
|
||||||
&Id::ExplorerRemote,
|
&Id::ExplorerRemote,
|
||||||
Attribute::Content,
|
Attribute::Content,
|
||||||
AttrValue::Table(files)
|
AttrValue::Table(files)
|
||||||
)
|
)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
assert!(self
|
);
|
||||||
.app
|
assert!(
|
||||||
.attr(
|
self.app
|
||||||
&Id::ExplorerRemote,
|
.attr(
|
||||||
Attribute::Title,
|
&Id::ExplorerRemote,
|
||||||
AttrValue::Title((hostname, Alignment::Left))
|
Attribute::Title,
|
||||||
)
|
AttrValue::Title((hostname, Alignment::Left))
|
||||||
.is_ok());
|
)
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update log box
|
/// Update log box
|
||||||
@@ -361,61 +456,67 @@ impl FileTransferActivity {
|
|||||||
.add_col(TextSpan::from("]: "))
|
.add_col(TextSpan::from("]: "))
|
||||||
.add_col(TextSpan::from(record.msg.as_str()));
|
.add_col(TextSpan::from(record.msg.as_str()));
|
||||||
}
|
}
|
||||||
assert!(self
|
assert!(
|
||||||
.app
|
self.app
|
||||||
.attr(
|
.attr(
|
||||||
&Id::Log,
|
&Id::Log,
|
||||||
Attribute::Content,
|
Attribute::Content,
|
||||||
AttrValue::Table(table.build())
|
AttrValue::Table(table.build())
|
||||||
)
|
)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn update_progress_bar(&mut self, filename: String) {
|
pub(super) fn update_progress_bar(&mut self, filename: String) {
|
||||||
assert!(self
|
assert!(
|
||||||
.app
|
self.app
|
||||||
.attr(
|
.attr(
|
||||||
&Id::ProgressBarFull,
|
&Id::ProgressBarFull,
|
||||||
Attribute::Text,
|
Attribute::Text,
|
||||||
AttrValue::String(self.transfer.full.to_string())
|
AttrValue::String(self.transfer.full.to_string())
|
||||||
)
|
)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
assert!(self
|
);
|
||||||
.app
|
assert!(
|
||||||
.attr(
|
self.app
|
||||||
&Id::ProgressBarFull,
|
.attr(
|
||||||
Attribute::Value,
|
&Id::ProgressBarFull,
|
||||||
AttrValue::Payload(PropPayload::One(PropValue::F64(
|
Attribute::Value,
|
||||||
self.transfer.full.calc_progress()
|
AttrValue::Payload(PropPayload::One(PropValue::F64(
|
||||||
)))
|
self.transfer.full.calc_progress()
|
||||||
)
|
)))
|
||||||
.is_ok());
|
)
|
||||||
assert!(self
|
.is_ok()
|
||||||
.app
|
);
|
||||||
.attr(
|
assert!(
|
||||||
&Id::ProgressBarPartial,
|
self.app
|
||||||
Attribute::Text,
|
.attr(
|
||||||
AttrValue::String(self.transfer.partial.to_string())
|
&Id::ProgressBarPartial,
|
||||||
)
|
Attribute::Text,
|
||||||
.is_ok());
|
AttrValue::String(self.transfer.partial.to_string())
|
||||||
assert!(self
|
)
|
||||||
.app
|
.is_ok()
|
||||||
.attr(
|
);
|
||||||
&Id::ProgressBarPartial,
|
assert!(
|
||||||
Attribute::Value,
|
self.app
|
||||||
AttrValue::Payload(PropPayload::One(PropValue::F64(
|
.attr(
|
||||||
self.transfer.partial.calc_progress()
|
&Id::ProgressBarPartial,
|
||||||
)))
|
Attribute::Value,
|
||||||
)
|
AttrValue::Payload(PropPayload::One(PropValue::F64(
|
||||||
.is_ok());
|
self.transfer.partial.calc_progress()
|
||||||
assert!(self
|
)))
|
||||||
.app
|
)
|
||||||
.attr(
|
.is_ok()
|
||||||
&Id::ProgressBarPartial,
|
);
|
||||||
Attribute::Title,
|
assert!(
|
||||||
AttrValue::Title((filename, Alignment::Center))
|
self.app
|
||||||
)
|
.attr(
|
||||||
.is_ok());
|
&Id::ProgressBarPartial,
|
||||||
|
Attribute::Title,
|
||||||
|
AttrValue::Title((filename, Alignment::Center))
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finalize find process
|
/// Finalize find process
|
||||||
@@ -448,16 +549,24 @@ impl FileTransferActivity {
|
|||||||
.found()
|
.found()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter_files()
|
.iter_files()
|
||||||
.map(|x| vec![TextSpan::from(self.found().unwrap().fmt_file(x))])
|
.map(|x| {
|
||||||
|
let mut span = TextSpan::from(self.found().unwrap().fmt_file(x));
|
||||||
|
if self.found().unwrap().enqueued().contains_key(x.path()) {
|
||||||
|
span.modifiers |=
|
||||||
|
TextModifiers::REVERSED | TextModifiers::UNDERLINED | TextModifiers::ITALIC;
|
||||||
|
}
|
||||||
|
vec![span]
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
assert!(self
|
assert!(
|
||||||
.app
|
self.app
|
||||||
.attr(
|
.attr(
|
||||||
&Id::ExplorerFind,
|
&Id::ExplorerFind,
|
||||||
Attribute::Content,
|
Attribute::Content,
|
||||||
AttrValue::Table(files)
|
AttrValue::Table(files)
|
||||||
)
|
)
|
||||||
.is_ok());
|
.is_ok()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn update_browser_file_list(&mut self) {
|
pub(super) fn update_browser_file_list(&mut self) {
|
||||||
@@ -469,6 +578,15 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn reload_browser_file_list(&mut self) {
|
||||||
|
match self.browser.tab() {
|
||||||
|
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => {
|
||||||
|
self.reload_host_bridge_filelist()
|
||||||
|
}
|
||||||
|
FileExplorerTab::Remote | FileExplorerTab::FindRemote => self.reload_remote_filelist(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn update_browser_file_list_swapped(&mut self) {
|
pub(super) fn update_browser_file_list_swapped(&mut self) {
|
||||||
match self.browser.tab() {
|
match self.browser.tab() {
|
||||||
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => {
|
FileExplorerTab::HostBridge | FileExplorerTab::FindHostBridge => {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user