added lib terminalsize
parent
77ecc25132
commit
d8d174c5d6
|
@ -93,7 +93,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
|||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -341,7 +341,7 @@ checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
|
|||
dependencies = [
|
||||
"atty",
|
||||
"lazy_static",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -525,7 +525,7 @@ checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
|
|||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -787,6 +787,16 @@ version = "1.0.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
dependencies = [
|
||||
"winapi 0.2.8",
|
||||
"winapi-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -885,7 +895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1028,7 +1038,7 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad9c443cce91fc3e12f017290db75dde490d685cdaaf508d7159d7cf41f0eb2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1089,6 +1099,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
|
@ -1273,6 +1289,7 @@ dependencies = [
|
|||
"log",
|
||||
"mysql",
|
||||
"sprintf",
|
||||
"termsize",
|
||||
"time",
|
||||
]
|
||||
|
||||
|
@ -1285,6 +1302,15 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
|
||||
dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.3"
|
||||
|
@ -1519,7 +1545,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1547,7 +1573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "0c2e86926081dda636c546d8c5e641661049d7562a68f5488be4a1f7f66f6086"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1591,6 +1617,31 @@ dependencies = [
|
|||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"numtoa",
|
||||
"redox_syscall",
|
||||
"redox_termios",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termsize"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e86d824a8e90f342ad3ef4bd51ef7119a9b681b0cc9f8ee7b2852f02ccd2517"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"kernel32-sys",
|
||||
"libc",
|
||||
"termion",
|
||||
"winapi 0.2.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
|
@ -1740,6 +1791,12 @@ version = "0.11.0+wasi-snapshot-preview1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
@ -1750,6 +1807,12 @@ dependencies = [
|
|||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -13,4 +13,5 @@ dotenv = "0.15.0"
|
|||
log = "0.4.17"
|
||||
mysql = "23.0.1"
|
||||
sprintf = "0.1.3"
|
||||
termsize = "0.1.6"
|
||||
time = "0.3.20"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
pub trait TerminalSize {
|
||||
fn get_width(&self) -> usize {
|
||||
let terminal = termsize::get().unwrap();
|
||||
terminal.cols.into()
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
match args.mode {
|
||||
Commands::Merch { search } => {
|
||||
let merchant_service: MerchantService = container::get_merchant_service(&mut conn);
|
||||
let mut merchant_service: MerchantService = container::get_merchant_service(&mut conn);
|
||||
merchant_service.get_merchant(&search.unwrap());
|
||||
}
|
||||
Commands::Schema { search } => {
|
||||
|
@ -45,7 +45,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
}
|
||||
Commands::Page { page_id } => {
|
||||
let file_service: FileService = container::get_page_service(&mut conn);
|
||||
let mut file_service: FileService = container::get_page_service(&mut conn);
|
||||
file_service.get_page(&page_id);
|
||||
}
|
||||
Commands::Job { job_id, log } => {
|
||||
|
|
|
@ -12,7 +12,7 @@ impl<'a> FileRepo<'a> {
|
|||
Self { db_pool }
|
||||
}
|
||||
|
||||
pub fn find_page(self, file_id: &usize) -> Result<Vec<Page>, mysql::Error> {
|
||||
pub fn find_page(&mut self, file_id: &usize) -> Result<Vec<Page>, mysql::Error> {
|
||||
let stat = self.db_pool
|
||||
.prep("SELECT m_id, description, file FROM global_data.effi_file_mapping WHERE file_id = :file_id")
|
||||
.unwrap();
|
||||
|
|
|
@ -63,7 +63,7 @@ impl<'a> FilterRepo<'a> {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn find_filter_log(
|
||||
pub fn find_filter_log(
|
||||
&mut self,
|
||||
filter_id: &usize,
|
||||
) -> Result<Vec<FilterLog>, mysql::Error> {
|
||||
|
|
|
@ -12,7 +12,7 @@ impl<'a> MerchantRepo<'a> {
|
|||
}
|
||||
|
||||
pub fn find_by_name_or_id(
|
||||
self,
|
||||
&mut self,
|
||||
search: &str,
|
||||
) -> Result<Vec<Merchant>, mysql::Error> {
|
||||
let stat = self.db_pool
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
use rcc::TerminalSize;
|
||||
|
||||
use crate::{entity::file::Page, repository::file_repo::FileRepo};
|
||||
|
||||
pub struct FileService<'a> {
|
||||
repo: FileRepo<'a>,
|
||||
}
|
||||
|
||||
impl TerminalSize for FileService<'_> {}
|
||||
|
||||
impl<'a> FileService<'a> {
|
||||
pub fn new(repo: FileRepo<'a>) -> Self {
|
||||
Self { repo }
|
||||
}
|
||||
|
||||
pub fn get_page(self, page_id: &usize) {
|
||||
pub fn get_page(&mut self, page_id: &usize) {
|
||||
let result = self.repo.find_page(page_id);
|
||||
|
||||
match result {
|
||||
|
@ -18,12 +22,12 @@ impl<'a> FileService<'a> {
|
|||
println!("No page found.");
|
||||
} else {
|
||||
page.into_iter().for_each(|page: Page| {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
println!("M-ID: {}", page.m_id);
|
||||
println!("FileName: {}", page.file);
|
||||
println!("Title: {}", page.title);
|
||||
});
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("{}", err),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use colored::Colorize;
|
||||
use rcc::TerminalSize;
|
||||
|
||||
use crate::{
|
||||
entity::{filter::Filter, filter_config::FilterConfig, filter_log::FilterLog},
|
||||
|
@ -9,6 +10,8 @@ pub struct FilterService<'a> {
|
|||
repo: FilterRepo<'a>,
|
||||
}
|
||||
|
||||
impl TerminalSize for FilterService<'_> {}
|
||||
|
||||
impl<'a> FilterService<'a> {
|
||||
pub fn new(repo: FilterRepo<'a>) -> Self {
|
||||
Self { repo }
|
||||
|
@ -23,7 +26,7 @@ impl<'a> FilterService<'a> {
|
|||
println!("Filter not found!");
|
||||
} else {
|
||||
filters.into_iter().for_each(|filter: Filter| {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
println!("Module ID: {}", filter.filter_module_id);
|
||||
println!("FileName: {}", filter.file_name);
|
||||
println!("Description: {}", filter.description);
|
||||
|
@ -34,7 +37,7 @@ impl<'a> FilterService<'a> {
|
|||
if all {
|
||||
self.get_filter_configs(filter_id)
|
||||
} else {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +53,7 @@ impl<'a> FilterService<'a> {
|
|||
if filter_configs.is_empty() {
|
||||
println!("No filter configs found!");
|
||||
} else {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
filter_configs
|
||||
.into_iter()
|
||||
.for_each(|filter_config: FilterConfig| {
|
||||
|
@ -63,7 +66,7 @@ impl<'a> FilterService<'a> {
|
|||
filter_config.name
|
||||
);
|
||||
});
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("{}", err),
|
||||
|
@ -77,7 +80,7 @@ impl<'a> FilterService<'a> {
|
|||
if filter_log.is_empty() {
|
||||
println!("No filter log found!");
|
||||
} else {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
filter_log.into_iter().for_each(|filter_log: FilterLog| {
|
||||
println!(
|
||||
"TS: {} Error Code: {}",
|
||||
|
@ -98,7 +101,7 @@ impl<'a> FilterService<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use rcc::TerminalSize;
|
||||
|
||||
use crate::{
|
||||
entity::job::{Job, JobLog},
|
||||
repository::job_repo::JobRepo,
|
||||
|
@ -7,6 +9,8 @@ pub struct JobService<'a> {
|
|||
pub repo: JobRepo<'a>,
|
||||
}
|
||||
|
||||
impl TerminalSize for JobService<'_> {}
|
||||
|
||||
impl<'a> JobService<'a> {
|
||||
pub fn new(repo: JobRepo<'a>) -> Self {
|
||||
Self { repo }
|
||||
|
@ -21,12 +25,12 @@ impl<'a> JobService<'a> {
|
|||
println!("Job not found!");
|
||||
} else {
|
||||
job.into_iter().for_each(|job: Job| {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
println!("FileName: {}", job.file_name);
|
||||
println!("Description: {}", job.description);
|
||||
});
|
||||
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("{}", err),
|
||||
|
@ -45,7 +49,7 @@ impl<'a> JobService<'a> {
|
|||
println!("{0: <25} | {1: <20} ", joblog.upd_ts, joblog.content,);
|
||||
});
|
||||
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("{}", err),
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
use rcc::TerminalSize;
|
||||
|
||||
use crate::repository::merchant_repo::MerchantRepo;
|
||||
|
||||
pub struct MerchantService<'a> {
|
||||
repo: MerchantRepo<'a>,
|
||||
}
|
||||
|
||||
impl TerminalSize for MerchantService<'_> {}
|
||||
|
||||
impl<'a> MerchantService<'a> {
|
||||
pub fn new(repo: MerchantRepo<'a>) -> Self {
|
||||
Self { repo }
|
||||
}
|
||||
|
||||
pub fn get_merchant(self, search: &str) {
|
||||
pub fn get_merchant(&mut self, search: &str) {
|
||||
let merchants = self.repo.find_by_name_or_id(search);
|
||||
|
||||
match merchants {
|
||||
|
@ -18,12 +22,12 @@ impl<'a> MerchantService<'a> {
|
|||
println!("Merchant not found!");
|
||||
}
|
||||
merchants.into_iter().for_each(|merchant| {
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
println!("Merchant: {}", merchant.m_name);
|
||||
println!("M-ID: {}", merchant.m_id);
|
||||
});
|
||||
|
||||
println!("{}", "-".repeat(150));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
Err(err) => panic!("{}", err),
|
||||
};
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
use rcc::TerminalSize;
|
||||
|
||||
use crate::repository::schema_repo::SchemaRepo;
|
||||
|
||||
pub struct SchemaService<'a> {
|
||||
repo: SchemaRepo<'a>,
|
||||
}
|
||||
|
||||
impl TerminalSize for SchemaService<'_> {}
|
||||
|
||||
impl<'a> SchemaService<'a> {
|
||||
pub fn new(repo: SchemaRepo<'a>) -> Self {
|
||||
Self { repo }
|
||||
|
@ -17,12 +21,12 @@ impl<'a> SchemaService<'a> {
|
|||
println!("No column found!");
|
||||
} else {
|
||||
columns.into_iter().for_each(|column| {
|
||||
println!("{}", "-".repeat(100));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
println!("Table name: {}", column.table_name);
|
||||
println!("Column name: {}", column.column_name);
|
||||
println!("Type: {}", column.column_type);
|
||||
});
|
||||
println!("{}", "-".repeat(100));
|
||||
println!("{}", "-".repeat(self.get_width()));
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("{err}"),
|
||||
|
|
Loading…
Reference in New Issue