Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.1.27 dev opendal #90

Merged
merged 37 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
da3055a
opendal WIP
qkzk Aug 31, 2024
68d6edd
navigable google drive. WIP: files copying
qkzk Aug 31, 2024
49a8eae
basic file downloader
qkzk Aug 31, 2024
71e1e5b
rename a function
qkzk Aug 31, 2024
3341da8
google drive config helper
qkzk Aug 31, 2024
e42b4a2
remove comments
qkzk Aug 31, 2024
349ff19
WIP: basic picker menu
qkzk Sep 1, 2024
1ef31ee
WIP: use picker to select fake cloud account
qkzk Sep 1, 2024
37394fa
cloud connect & disconnect
qkzk Sep 1, 2024
625a93e
improve google driver token helper & picker
qkzk Sep 1, 2024
13185aa
dec
qkzk Sep 1, 2024
e684057
delete cloud file with x
qkzk Sep 1, 2024
cf2dee6
cloud directory creation
qkzk Sep 1, 2024
fc8f7a9
upload selected file
qkzk Sep 1, 2024
27f0f9a
cloud: keybindings, improve config folder access
qkzk Sep 1, 2024
ef5bcba
dev
qkzk Sep 1, 2024
1b2edf5
cloud: refactoring
qkzk Sep 2, 2024
b5bff01
cloud: refactoring again
qkzk Sep 2, 2024
1a07aad
cloud: refactoring
qkzk Sep 3, 2024
e89e122
move tokio::main to opendal.rs
qkzk Sep 3, 2024
c535dc1
cloud: documentation. Use a trait to display opendal entry modes
qkzk Sep 3, 2024
3f1e4af
cloud & tree mode for download & upload
qkzk Sep 4, 2024
fa56f83
cloud: refactor
qkzk Sep 4, 2024
48eb772
help for google helper
qkzk Sep 4, 2024
c1130ea
improve token creation
qkzk Sep 5, 2024
5e8787f
dev
qkzk Sep 5, 2024
b229e3d
FIX: recenter window after deletion
qkzk Sep 5, 2024
2cc4a0c
FIX: collision on last line of menu window
qkzk Sep 5, 2024
f6a348e
merge both binaries
qkzk Sep 6, 2024
94e9c09
cloud configuration readme
qkzk Sep 7, 2024
fa95319
default for opendal container
qkzk Sep 7, 2024
f24ecb1
improve cloud file mode display
qkzk Sep 7, 2024
5ead998
FIX: while navigating, contentwindow len isn't updated
qkzk Sep 7, 2024
01ebedf
metadata info with ?
qkzk Sep 8, 2024
5861ae1
opendal documentation
qkzk Sep 8, 2024
e1a1cac
status cloud methods documentation
qkzk Sep 8, 2024
4a13c21
dev
qkzk Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,200 changes: 1,159 additions & 41 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ version = "0.1.27"
authors = ["Quentin Konieczko <[email protected]>"]
edition = "2021"
license-file = "LICENSE.txt"
description = "A TUI file manager inspired by dired and ranger"
description = "FM : a file manager inspired by ranger and dired{n}{n}Config files ~/.config/fm/{n}Documentation https://github.com/qkzk/fm{n}"
readme = "readme.md"
repository = "https://github.com/qkzk/fm"
keywords = ["tui", "file-manager", "file", "manager", "tuikit"]
categories = ["command-line-utilities", "filesystem", "os::unix-apis"]
documentation = "https://docs.rs/fm-tui/latest/"
default-run = "fm"

[profile.release]
# strip = true # Automatically strip symbols from the binary.
Expand All @@ -30,7 +31,7 @@ fs_extra = "1.2.0"

[dependencies]
anyhow = "1.0.28"
chrono = "0.4.31"
chrono = "0.4.38"
clap = { version = "4.0.2", features = ["derive"] }
content_inspector = "0.2.4"
copypasta = "0.8.1"
Expand All @@ -41,6 +42,8 @@ lazy_static = "1.4.0"
log = { version = "0.4.0", features = ["std"] }
log4rs = { version = "1.2.0", features = ["rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
nvim-rs = { version = "0.3", features = ["use_tokio"] }
oauth2 = "4.4.2"
opendal = { version = "0.49.2", features = ["services-gdrive"] }
pathdiff = "0.2.1"
pgs-files = "0.0.7"
rand = "0.8.5"
Expand All @@ -61,5 +64,6 @@ tokio = "1"
tuikit = "0.5.0"
ueberzug = "0.1.0"
unicode-segmentation = "1.10.1"
url = { version = "2.1", features = ["serde"]}
url-escape = "0.1.1"
zip = "2.1.6"
27 changes: 26 additions & 1 deletion development.md
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- hex colors can be used in config file.
- click on right pane while previewing a tree moves there.
- Display keybindings sorted by alphabetical order with `$ fm --keybinds`
- Google drive. Navigate, download, upload file to google drive once configured. See the readme for more details.

#### Changelog

Expand Down Expand Up @@ -1018,14 +1019,38 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] dump keybinds & refactor help message
- [x] FIX: leaving preview in current tab doesn't select the last file
- [ ] perfomance
- [ ] Apache OpenDAL: [Official Documentation](https://opendal.apache.org/) - [crates.io](https://crates.io/crates/opendal)
- [x] refresh token creation
- [x] write tokens in config folder for user
- [x] keybindings in menu
- [x] readme for users
- [x] token handling
- [x] simplest configuration
- [x] google drive listing
- [x] listing
- [x] directory navigation
- [x] file downloading :
- [x] directory mode
- [x] tree mode
- [x] directory creation
- [x] file uploading
- [x] file deletion
- [x] move all tokio::main to opendal
- [x] log errors
- [x] delete confirmation
- [x] FIX: window is offset after deletion when deleted wasn't on first screen
- [x] merge into a single binary
- [x] FIX: while navigating, contentwindow len isn't updated
- [x] WONTDO: metadata for cloud files. Way too long for big folder
- [ ] BUG: opendal crashes if multiple files have the same name. See [issue](https://github.com/apache/opendal/issues/5099)
- [ ] non blocking previews: use the mpsc to do the previews async (once again)
- [ ] stop & undo actions (bulkrename, copy, move, delete ???)
- [ ] FIX: alt + g, type, complete, back crash. Can't reproduce
- [x] FIX: too much thing on menu and last line
- [ ] reduce dependencies

## TODO

- [ ] Apache OpenDAL: [Official Documentation](https://opendal.apache.org/) - [crates.io](https://crates.io/crates/opendal)
- [ ] ideas from broot : https://dystroy.org/broot/#apply-commands-on-several-files
- [ ] floating windows ?
- [ ] rclone
Expand Down
49 changes: 47 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
[docrs]: https://docs.rs/fm-tui/0.1.24

```
A TUI file manager inspired by dired and ranger
FM : a file manager inspired by ranger and dired

Config files ~/.config/fm/
Documentation https://github.com/qkzk/fm


Usage: fm [OPTIONS]

Expand All @@ -19,8 +23,10 @@ Options:
-A, --all Display all files (hidden)
-l, --log Enable logging
--neovim Started inside neovim terminal emulator
--keybinds Print keybinds
--cloudconfig Configure a google drive client
-h, --help Print help
-V, --version Print version [3,8s]
-V, --version Print version
```

## Platform
Expand Down Expand Up @@ -181,6 +187,45 @@ Critical actions will be logged to `~/.config/fm/log/fm.log` and actions affecti
The last action is displayed at the bottom of the screen and can be read with `Alt+l` like a preview.
Those logs can be seen even if logging is disabled, it just won't be up to date.

### Google Drive

With the help of the amazing [OpenDal](https://opendal.apache.org/) library from Apache, you can access your remote GoogleDrive files within fm.

You must setup a client id and a client secret first. Once it's done, the helper `fm --cloudconfig` will create the configuration file for you.
It uses a refresh token which will automatically be refreshed for you by OpenDal.

Open the Cloud menu with Shift-Alt-C and pick a valid config file.
Once done, you can navigate your files with the arrow keys, download them with Return, upload the selected file with u, Delete a remote file with X (no confirmation !) and create a new directory with d.

You can setup many google drive accounts but only one can be opened at once. Use `l` to _leave_ the current one and select another one.

This is an advanced user feature with rough edges.

#### Initial setup

You need to provide credentials to access a google drive account. The only way to get them is to create a project in Google Cloud and share the credentials.

1. Open google cloud console and setup a new project for fm
2. Add the google drive API for your project with the scopes `https://www.googleapis.com/auth/drive` and create credentials
3. Add a tester with the same email account
4. Add OAuth 2.0 credentials and copy the client id and client secret.
5. Publish your application. It changes nothing but make the refresh tokens last longer.
6. Run the helper `fm --cloudconfig` and provide the requested informations.

More infos about credentials can be found in the [rclone](https://rclone.org/drive/#making-your-own-client-id) documentation.

#### Multiple files having the same name

For some reason, GoogleDrive allows multiple files to have exactly the same name. ATM it crashes OpenDal in _testing mode_ and those files are ignored in _release_ mode.
Only developpers of fm should be concerned.

#### Notes

- This feature is still in beta and is subject to change a lot.
- Be careful with your files.
- A lot of GoogleDrive features aren't supported yet, mostly because I couldn't test them. If you want to sync your files in Linux, you should take a look at [rclone](https://rclone.org/).
- OpenDal provides a [lot of services](https://docs.rs/opendal/latest/opendal/services/index.html), not only GoogleDrive. If you want more services like that, open an issue and I'll take a look.

### More

- Copy a filename/filepath to clipboard with Ctrl+n, Ctrl+p
Expand Down
10 changes: 9 additions & 1 deletion src/app/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::app::Refresher;
use crate::app::Status;
use crate::common::CONFIG_PATH;
use crate::common::{clear_tmp_file, init_term};
use crate::config::cloud_config;
use crate::config::load_config;
use crate::config::START_FOLDER;
use crate::event::EventDispatcher;
Expand Down Expand Up @@ -60,11 +61,18 @@ impl FM {
exit_wrong_config()
};

if Args::parse().keybinds {
let args = Args::parse();

if args.keybinds {
println!("{binds}", binds = config.binds.to_str());
exit(0);
}

if args.cloudconfig {
cloud_config()?;
exit(0);
}

log_info!(
"start folder: {startfolder}",
startfolder = &START_FOLDER.display()
Expand Down
Loading