Switch to directories crate for directory finding
This commit is contained in:
parent
2755d6ed5c
commit
962a5769dc
4 changed files with 36 additions and 56 deletions
49
Cargo.lock
generated
49
Cargo.lock
generated
|
@ -19,17 +19,6 @@ dependencies = [
|
|||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "app_dirs2"
|
||||
version = "2.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.4"
|
||||
|
@ -300,6 +289,14 @@ dependencies = [
|
|||
"generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "directories"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.2"
|
||||
|
@ -354,12 +351,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
name = "ffsend"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"app_dirs2 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clipboard 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derive_builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"directories 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ffsend-api 0.0.1",
|
||||
|
@ -768,15 +765,6 @@ dependencies = [
|
|||
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ole32-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "1.2.1"
|
||||
|
@ -1112,15 +1100,6 @@ dependencies = [
|
|||
"fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell32-sys"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.2.2"
|
||||
|
@ -1586,16 +1565,10 @@ dependencies = [
|
|||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xdg"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6cbd0b9af8587c72beadc9f72d35b9fbb070982c9e6203e46e93f10df25f8f45"
|
||||
"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
|
||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
"checksum app_dirs2 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0aa02944d8a100b79057d1619032b1ad39de5eed6567cdeccbd53908b326e082"
|
||||
"checksum arrayref 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd1479b7c29641adbd35ff3b5c293922d696a92f25c8c975da3e0acbc87258f"
|
||||
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
|
||||
"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1"
|
||||
|
@ -1629,6 +1602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum derive_builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c998e6ab02a828dd9735c18f154e14100e674ed08cb4e1938f0e4177543f439"
|
||||
"checksum derive_builder_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "735e24ee9e5fa8e16b86da5007856e97d592e11867e45d76e0c0d0a164a0b757"
|
||||
"checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603"
|
||||
"checksum directories 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc2561db021b6f1321d0f16b67ed28ce843ef4610dfaa432e3ffa2e8a3050ebf"
|
||||
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
|
||||
"checksum encode_unicode 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c088ec0ed2282dcd054f2c124c0327f953563e6c75fdc6ff5141779596289830"
|
||||
"checksum encoding_rs 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98fd0f24d1fb71a4a6b9330c8ca04cbd4e7cc5d846b54ca74ff376bc7c9f798d"
|
||||
|
@ -1680,7 +1654,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "877f30f37acef6749b1841cceab289707f211aecfc756553cd63976190e6cc2e"
|
||||
"checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
|
||||
"checksum objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4730aa1c64d722db45f7ccc4113a3e2c465d018de6db4d3e7dfe031e8c8a297"
|
||||
"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
|
||||
"checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113"
|
||||
"checksum openssl 0.10.7 (registry+https://github.com/rust-lang/crates.io-index)" = "63c6ff2c7d9903daf9f3429eb2f6beedb15b1f7362e3529e5bf00b6caf182400"
|
||||
"checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985"
|
||||
|
@ -1719,7 +1692,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f3ad6d546e765177cf3dded3c2e424a8040f870083a0e64064746b958ece9cb1"
|
||||
"checksum serde_urlencoded 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce0fd303af908732989354c6f02e05e2e6d597152870f2c6990efb0577137480"
|
||||
"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
|
||||
"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c"
|
||||
"checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
|
||||
"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23"
|
||||
"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d"
|
||||
|
@ -1777,4 +1749,3 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum x11-clipboard 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7374c7699210cca7084ca61d57e09640fc744d1391808cb9ae2fe4ca9bd1df"
|
||||
"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de"
|
||||
"checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61"
|
||||
|
|
|
@ -19,12 +19,12 @@ default = ["clipboard"]
|
|||
no-color = ["colored/no-color"]
|
||||
|
||||
[dependencies]
|
||||
app_dirs2 = "2.0"
|
||||
chrono = "0.4"
|
||||
clap = "2.31"
|
||||
clipboard = { version = "0.4", optional = true }
|
||||
colored = "1.6"
|
||||
derive_builder = "0.5"
|
||||
directories = "0.10"
|
||||
failure = "0.1"
|
||||
failure_derive = "0.1"
|
||||
ffsend-api = { version = "*", path = "../api" }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
extern crate app_dirs2;
|
||||
extern crate directories;
|
||||
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use self::app_dirs2::{AppDataType, AppInfo, get_app_dir};
|
||||
|
||||
use super::matcher::{
|
||||
DeleteMatcher,
|
||||
|
@ -24,22 +23,11 @@ use super::cmd::{
|
|||
CmdPassword,
|
||||
CmdUpload,
|
||||
};
|
||||
use util::app_history_file_path_string;
|
||||
|
||||
lazy_static! {
|
||||
/// The default history file
|
||||
static ref DEFAULT_HISTORY_FILE: String =
|
||||
get_app_dir(
|
||||
AppDataType::UserCache,
|
||||
&AppInfo {
|
||||
name: crate_name!(),
|
||||
author: crate_name!(),
|
||||
},
|
||||
"history.toml",
|
||||
)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
static ref DEFAULT_HISTORY_FILE: String = app_history_file_path_string();
|
||||
}
|
||||
|
||||
/// CLI argument handler.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#[cfg(feature = "clipboard")]
|
||||
extern crate clipboard;
|
||||
extern crate colored;
|
||||
extern crate directories;
|
||||
extern crate fs2;
|
||||
extern crate open;
|
||||
|
||||
|
@ -14,7 +15,7 @@ use std::io::{
|
|||
stderr,
|
||||
Write,
|
||||
};
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{exit, ExitStatus};
|
||||
|
||||
use chrono::Duration;
|
||||
|
@ -24,6 +25,7 @@ use ffsend_api::url::Url;
|
|||
use rpassword::prompt_password_stderr;
|
||||
use self::clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use self::colored::*;
|
||||
use self::directories::ProjectDirs;
|
||||
use self::fs2::available_space;
|
||||
|
||||
use cmd::matcher::MainMatcher;
|
||||
|
@ -588,3 +590,22 @@ pub fn ensure_enough_space<P: AsRef<Path>>(path: P, size: u64) {
|
|||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Get the project directories instance for this application.
|
||||
/// This may be used to determine the project, cache, configuration, data and
|
||||
/// some other directory paths.
|
||||
pub fn app_project_dirs() -> ProjectDirs {
|
||||
ProjectDirs::from("", "", crate_name!())
|
||||
}
|
||||
|
||||
/// Get the default path to use for the history file.
|
||||
pub fn app_history_file_path<'a>() -> PathBuf {
|
||||
app_project_dirs().cache_dir().join("history.toml")
|
||||
}
|
||||
|
||||
/// Get the default path to use for the history file, as a string.
|
||||
pub fn app_history_file_path_string() -> String {
|
||||
app_history_file_path().to_str()
|
||||
.unwrap()
|
||||
.to_owned()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue