mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 01:26:04 -08:00
lazy-regex
This commit is contained in:
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,6 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
- [Changelog](#changelog)
|
||||
- [0.10.0](#0100)
|
||||
- [0.9.0](#090)
|
||||
- [0.8.2](#082)
|
||||
- [0.8.1](#081)
|
||||
@@ -25,6 +26,16 @@
|
||||
|
||||
---
|
||||
|
||||
## 0.10.0
|
||||
|
||||
Released on ??
|
||||
|
||||
> ⭐ 500 stars update 🌟
|
||||
|
||||
- Dependencies:
|
||||
- Changed `regex` to `lazy-regex 2.3.0`
|
||||
- Bump `tuirealm` to `1.8.0`
|
||||
|
||||
## 0.9.0
|
||||
|
||||
Released on 18/06/2022
|
||||
|
||||
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -1127,6 +1127,29 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy-regex"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6b12f2eb6ed7d39405c5eb25a034b4c106a9ad87a6d9be3298de6c5f32fd57d"
|
||||
dependencies = [
|
||||
"lazy-regex-proc_macros",
|
||||
"once_cell",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy-regex-proc_macros"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2496e5264069bc726ccf37eb76b9cd89406ae110d836c3f76729f99c8a23293"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
@@ -2496,6 +2519,7 @@ dependencies = [
|
||||
"edit",
|
||||
"hostname",
|
||||
"keyring",
|
||||
"lazy-regex",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"magic-crypt",
|
||||
@@ -2504,7 +2528,6 @@ dependencies = [
|
||||
"open",
|
||||
"pretty_assertions",
|
||||
"rand",
|
||||
"regex",
|
||||
"remotefs",
|
||||
"remotefs-aws-s3",
|
||||
"remotefs-ftp",
|
||||
|
||||
@@ -40,6 +40,7 @@ dirs = "4.0.0"
|
||||
edit = "0.1.4"
|
||||
hostname = "0.3.1"
|
||||
keyring = { version = "1.1.2", optional = true }
|
||||
lazy-regex = "^2.3.0"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.17"
|
||||
magic-crypt = "3.1.10"
|
||||
@@ -47,7 +48,6 @@ notify = "4.0.17"
|
||||
notify-rust = { version = "4.5.6", default-features = false, features = [ "d" ] }
|
||||
open = "2.1.3"
|
||||
rand = "0.8.5"
|
||||
regex = "1.5.6"
|
||||
remotefs = "^0.2.0"
|
||||
remotefs-aws-s3 = "^0.2.0"
|
||||
remotefs-ftp = { version = "^0.1.0", features = [ "secure" ] }
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::utils::path::diff_paths;
|
||||
use crate::utils::string::secure_substring;
|
||||
// Ext
|
||||
use bytesize::ByteSize;
|
||||
use regex::Regex;
|
||||
use lazy_regex::{Lazy, Regex};
|
||||
use remotefs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::time::UNIX_EPOCH;
|
||||
@@ -32,17 +32,14 @@ const FMT_KEY_SYMLINK: &str = "SYMLINK";
|
||||
const FMT_KEY_USER: &str = "USER";
|
||||
// Default
|
||||
const FMT_DEFAULT_STX: &str = "{NAME} {PEX} {USER} {SIZE} {MTIME}";
|
||||
// Regex
|
||||
lazy_static! {
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 0: KEY NAME
|
||||
* - group 1?: LENGTH
|
||||
* - group 2?: EXTRA
|
||||
*/
|
||||
static ref FMT_KEY_REGEX: Regex = Regex::new(r"\{(.*?)\}").ok().unwrap();
|
||||
static ref FMT_ATTR_REGEX: Regex = Regex::new(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?").ok().unwrap();
|
||||
}
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 0: KEY NAME
|
||||
* - group 1?: LENGTH
|
||||
* - group 2?: EXTRA
|
||||
*/
|
||||
static FMT_KEY_REGEX: Lazy<Regex> = lazy_regex!(r"\{(.*?)\}");
|
||||
static FMT_ATTR_REGEX: Lazy<Regex> = lazy_regex!(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?");
|
||||
|
||||
/// Call Chain block is a block in a chain of functions which are called in order to format the File.
|
||||
/// A callChain is instantiated starting from the Formatter syntax and the regex, once the groups are found
|
||||
|
||||
@@ -5,6 +5,8 @@ const TERMSCP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
#[macro_use]
|
||||
extern crate lazy_regex;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
@@ -14,56 +14,57 @@ use crate::system::environment;
|
||||
|
||||
// Ext
|
||||
use bytesize::ByteSize;
|
||||
use regex::Regex;
|
||||
use lazy_regex::{Lazy, Regex};
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use tuirealm::tui::style::Color;
|
||||
use tuirealm::utils::parser as tuirealm_parser;
|
||||
|
||||
// Regex
|
||||
lazy_static! {
|
||||
|
||||
/**
|
||||
* This regex matches the protocol used as option
|
||||
* Regex matches:
|
||||
* - group 1: Some(protocol) | None
|
||||
* - group 2: Some(other args)
|
||||
*/
|
||||
static ref REMOTE_OPT_PROTOCOL_REGEX: Regex = Regex::new(r"(?:([a-z0-9]+)://)?(?:(.+))").unwrap();
|
||||
/**
|
||||
* This regex matches the protocol used as option
|
||||
* Regex matches:
|
||||
* - group 1: Some(protocol) | None
|
||||
* - group 2: Some(other args)
|
||||
*/
|
||||
static REMOTE_OPT_PROTOCOL_REGEX: Lazy<Regex> = lazy_regex!(r"(?:([a-z0-9]+)://)?(?:(.+))");
|
||||
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Some(user) | None
|
||||
* - group 2: Address
|
||||
* - group 3: Some(port) | None
|
||||
* - group 4: Some(path) | None
|
||||
*/
|
||||
static ref REMOTE_GENERIC_OPT_REGEX: Regex = Regex::new(r"(?:([^@]+)@)?(?:([^:]+))(?::((?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])))?(?::([^:]+))?").ok().unwrap();
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Some(user) | None
|
||||
* - group 2: Address
|
||||
* - group 3: Some(port) | None
|
||||
* - group 4: Some(path) | None
|
||||
*/
|
||||
static REMOTE_GENERIC_OPT_REGEX: Lazy<Regex> = lazy_regex!(
|
||||
r"(?:([^@]+)@)?(?:([^:]+))(?::((?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])))?(?::([^:]+))?"
|
||||
);
|
||||
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Bucket
|
||||
* - group 2: Region
|
||||
* - group 3: Some(profile) | None
|
||||
* - group 4: Some(path) | None
|
||||
*/
|
||||
static ref REMOTE_S3_OPT_REGEX: Regex = Regex::new(r"(?:([^@]+)@)(?:([^:]+))(?::([a-zA-Z0-9][^:]+))?(?::([^:]+))?").unwrap();
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Bucket
|
||||
* - group 2: Region
|
||||
* - group 3: Some(profile) | None
|
||||
* - group 4: Some(path) | None
|
||||
*/
|
||||
static REMOTE_S3_OPT_REGEX: Lazy<Regex> =
|
||||
lazy_regex!(r"(?:([^@]+)@)(?:([^:]+))(?::([a-zA-Z0-9][^:]+))?(?::([^:]+))?");
|
||||
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Version
|
||||
* E.g. termscp-0.3.2 => 0.3.2
|
||||
* v0.4.0 => 0.4.0
|
||||
*/
|
||||
static ref SEMVER_REGEX: Regex = Regex::new(r".*(:?[0-9]\.[0-9]\.[0-9])").unwrap();
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: Version
|
||||
* E.g. termscp-0.3.2 => 0.3.2
|
||||
* v0.4.0 => 0.4.0
|
||||
*/
|
||||
static SEMVER_REGEX: Lazy<Regex> = lazy_regex!(r".*(:?[0-9]\.[0-9]\.[0-9])");
|
||||
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: amount (number)
|
||||
* - group 4: unit (K, M, G, T, P)
|
||||
*/
|
||||
static ref BYTESIZE_REGEX: Regex = Regex::new(r"(:?([0-9])+)( )*(:?[KMGTP])?B$").unwrap();
|
||||
}
|
||||
/**
|
||||
* Regex matches:
|
||||
* - group 1: amount (number)
|
||||
* - group 4: unit (K, M, G, T, P)
|
||||
*/
|
||||
static BYTESIZE_REGEX: Lazy<Regex> = lazy_regex!(r"(:?([0-9])+)( )*(:?[KMGTP])?B$");
|
||||
|
||||
// -- remote opts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user