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](#changelog)
|
- [Changelog](#changelog)
|
||||||
|
- [0.10.0](#0100)
|
||||||
- [0.9.0](#090)
|
- [0.9.0](#090)
|
||||||
- [0.8.2](#082)
|
- [0.8.2](#082)
|
||||||
- [0.8.1](#081)
|
- [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
|
## 0.9.0
|
||||||
|
|
||||||
Released on 18/06/2022
|
Released on 18/06/2022
|
||||||
|
|||||||
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -1127,6 +1127,29 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"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]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -2496,6 +2519,7 @@ dependencies = [
|
|||||||
"edit",
|
"edit",
|
||||||
"hostname",
|
"hostname",
|
||||||
"keyring",
|
"keyring",
|
||||||
|
"lazy-regex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"magic-crypt",
|
"magic-crypt",
|
||||||
@@ -2504,7 +2528,6 @@ dependencies = [
|
|||||||
"open",
|
"open",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rand",
|
"rand",
|
||||||
"regex",
|
|
||||||
"remotefs",
|
"remotefs",
|
||||||
"remotefs-aws-s3",
|
"remotefs-aws-s3",
|
||||||
"remotefs-ftp",
|
"remotefs-ftp",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ dirs = "4.0.0"
|
|||||||
edit = "0.1.4"
|
edit = "0.1.4"
|
||||||
hostname = "0.3.1"
|
hostname = "0.3.1"
|
||||||
keyring = { version = "1.1.2", optional = true }
|
keyring = { version = "1.1.2", optional = true }
|
||||||
|
lazy-regex = "^2.3.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
magic-crypt = "3.1.10"
|
magic-crypt = "3.1.10"
|
||||||
@@ -47,7 +48,6 @@ notify = "4.0.17"
|
|||||||
notify-rust = { version = "4.5.6", default-features = false, features = [ "d" ] }
|
notify-rust = { version = "4.5.6", default-features = false, features = [ "d" ] }
|
||||||
open = "2.1.3"
|
open = "2.1.3"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
regex = "1.5.6"
|
|
||||||
remotefs = "^0.2.0"
|
remotefs = "^0.2.0"
|
||||||
remotefs-aws-s3 = "^0.2.0"
|
remotefs-aws-s3 = "^0.2.0"
|
||||||
remotefs-ftp = { version = "^0.1.0", features = [ "secure" ] }
|
remotefs-ftp = { version = "^0.1.0", features = [ "secure" ] }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::utils::path::diff_paths;
|
|||||||
use crate::utils::string::secure_substring;
|
use crate::utils::string::secure_substring;
|
||||||
// Ext
|
// Ext
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use regex::Regex;
|
use lazy_regex::{Lazy, Regex};
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::UNIX_EPOCH;
|
use std::time::UNIX_EPOCH;
|
||||||
@@ -32,17 +32,14 @@ const FMT_KEY_SYMLINK: &str = "SYMLINK";
|
|||||||
const FMT_KEY_USER: &str = "USER";
|
const FMT_KEY_USER: &str = "USER";
|
||||||
// Default
|
// Default
|
||||||
const FMT_DEFAULT_STX: &str = "{NAME} {PEX} {USER} {SIZE} {MTIME}";
|
const FMT_DEFAULT_STX: &str = "{NAME} {PEX} {USER} {SIZE} {MTIME}";
|
||||||
// Regex
|
/**
|
||||||
lazy_static! {
|
* Regex matches:
|
||||||
/**
|
* - group 0: KEY NAME
|
||||||
* Regex matches:
|
* - group 1?: LENGTH
|
||||||
* - group 0: KEY NAME
|
* - group 2?: EXTRA
|
||||||
* - 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]+))?(:?(.+))?");
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call Chain block is a block in a chain of functions which are called in order to format the File.
|
/// 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
|
/// 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]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate lazy_regex;
|
||||||
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|||||||
@@ -14,56 +14,57 @@ use crate::system::environment;
|
|||||||
|
|
||||||
// Ext
|
// Ext
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use regex::Regex;
|
use lazy_regex::{Lazy, Regex};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tuirealm::tui::style::Color;
|
use tuirealm::tui::style::Color;
|
||||||
use tuirealm::utils::parser as tuirealm_parser;
|
use tuirealm::utils::parser as tuirealm_parser;
|
||||||
|
|
||||||
// Regex
|
// Regex
|
||||||
lazy_static! {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This regex matches the protocol used as option
|
* This regex matches the protocol used as option
|
||||||
* Regex matches:
|
* Regex matches:
|
||||||
* - group 1: Some(protocol) | None
|
* - group 1: Some(protocol) | None
|
||||||
* - group 2: Some(other args)
|
* - group 2: Some(other args)
|
||||||
*/
|
*/
|
||||||
static ref REMOTE_OPT_PROTOCOL_REGEX: Regex = Regex::new(r"(?:([a-z0-9]+)://)?(?:(.+))").unwrap();
|
static REMOTE_OPT_PROTOCOL_REGEX: Lazy<Regex> = lazy_regex!(r"(?:([a-z0-9]+)://)?(?:(.+))");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex matches:
|
* Regex matches:
|
||||||
* - group 1: Some(user) | None
|
* - group 1: Some(user) | None
|
||||||
* - group 2: Address
|
* - group 2: Address
|
||||||
* - group 3: Some(port) | None
|
* - group 3: Some(port) | None
|
||||||
* - group 4: Some(path) | 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();
|
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:
|
* Regex matches:
|
||||||
* - group 1: Bucket
|
* - group 1: Bucket
|
||||||
* - group 2: Region
|
* - group 2: Region
|
||||||
* - group 3: Some(profile) | None
|
* - group 3: Some(profile) | None
|
||||||
* - group 4: Some(path) | None
|
* - group 4: Some(path) | None
|
||||||
*/
|
*/
|
||||||
static ref REMOTE_S3_OPT_REGEX: Regex = Regex::new(r"(?:([^@]+)@)(?:([^:]+))(?::([a-zA-Z0-9][^:]+))?(?::([^:]+))?").unwrap();
|
static REMOTE_S3_OPT_REGEX: Lazy<Regex> =
|
||||||
|
lazy_regex!(r"(?:([^@]+)@)(?:([^:]+))(?::([a-zA-Z0-9][^:]+))?(?::([^:]+))?");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex matches:
|
* Regex matches:
|
||||||
* - group 1: Version
|
* - group 1: Version
|
||||||
* E.g. termscp-0.3.2 => 0.3.2
|
* E.g. termscp-0.3.2 => 0.3.2
|
||||||
* v0.4.0 => 0.4.0
|
* v0.4.0 => 0.4.0
|
||||||
*/
|
*/
|
||||||
static ref SEMVER_REGEX: Regex = Regex::new(r".*(:?[0-9]\.[0-9]\.[0-9])").unwrap();
|
static SEMVER_REGEX: Lazy<Regex> = lazy_regex!(r".*(:?[0-9]\.[0-9]\.[0-9])");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex matches:
|
* Regex matches:
|
||||||
* - group 1: amount (number)
|
* - group 1: amount (number)
|
||||||
* - group 4: unit (K, M, G, T, P)
|
* - group 4: unit (K, M, G, T, P)
|
||||||
*/
|
*/
|
||||||
static ref BYTESIZE_REGEX: Regex = Regex::new(r"(:?([0-9])+)( )*(:?[KMGTP])?B$").unwrap();
|
static BYTESIZE_REGEX: Lazy<Regex> = lazy_regex!(r"(:?([0-9])+)( )*(:?[KMGTP])?B$");
|
||||||
}
|
|
||||||
|
|
||||||
// -- remote opts
|
// -- remote opts
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user