From 159b5fc6b1e0cc3a9524d451839b7534a96592f0 Mon Sep 17 00:00:00 2001 From: Leonard Lesinski <84378319+Le0X8@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:17:15 +0200 Subject: [PATCH 1/7] chore!: removed JSON --- src/json.rs | 8 -------- src/main.rs | 54 +++++++++++++++++++++-------------------------------- 2 files changed, 21 insertions(+), 41 deletions(-) delete mode 100644 src/json.rs diff --git a/src/json.rs b/src/json.rs deleted file mode 100644 index 9626b77..0000000 --- a/src/json.rs +++ /dev/null @@ -1,8 +0,0 @@ -use corelib; - -pub fn get_version() { - print!("{{\n\t"); - print!("\"cli\": \"v{}\",\n\t", env!("CARGO_PKG_VERSION")); - print!("\"core\": \"v{}\"\n", corelib::get_version()); - print!("}}\n"); -} diff --git a/src/main.rs b/src/main.rs index a1026db..20691e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -mod json; mod text; use clap::Parser; @@ -10,10 +9,6 @@ struct Args { #[arg(short, long)] version: bool, - /// Output as JSON - #[arg(short, long)] - json: bool, - /// Show archive metadata #[arg(short, long)] metadata: bool, @@ -76,33 +71,26 @@ fn main() { }); let format = format.as_str(); - if !args.json { - match command { - "version" => text::get_version(), - "metadata" => match format { - "zip" => text::zip_metadata(args.input.unwrap()), - _ => println!("Unknown format"), - }, - "list" => match format { - "zip" => text::zip_list(args.input.unwrap()), - _ => println!("Unknown format"), - }, - "extract" => match format { - "zip" => text::zip_extract( - args.input.unwrap(), - args.output.unwrap(), - args.index, - args.path, - args.all, - ), - _ => println!("Unknown format"), - }, - _ => println!("Nothing to do, try --help"), - } - } else { - match command { - "version" => json::get_version(), - _ => print!("{{}}\n"), - } + match command { + "version" => text::get_version(), + "metadata" => match format { + "zip" => text::zip_metadata(args.input.unwrap()), + _ => println!("Unknown format"), + }, + "list" => match format { + "zip" => text::zip_list(args.input.unwrap()), + _ => println!("Unknown format"), + }, + "extract" => match format { + "zip" => text::zip_extract( + args.input.unwrap(), + args.output.unwrap(), + args.index, + args.path, + args.all, + ), + _ => println!("Unknown format"), + }, + _ => println!("Nothing to do, try --help"), } } From f016cb7384261e018ed4f0ededd887ba1a88dd18 Mon Sep 17 00:00:00 2001 From: Leonard Lesinski <84378319+Le0X8@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:55:35 +0200 Subject: [PATCH 2/7] chore: Updated to the new v0.2.0 API --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands.rs | 4 ++ src/commands/extract.rs | 5 ++ src/commands/list.rs | 43 ++++++++++++ src/commands/metadata.rs | 44 ++++++++++++ src/commands/version.rs | 5 ++ src/main.rs | 59 +++++++++------- src/text.rs | 148 --------------------------------------- 9 files changed, 136 insertions(+), 176 deletions(-) create mode 100644 src/commands.rs create mode 100644 src/commands/extract.rs create mode 100644 src/commands/list.rs create mode 100644 src/commands/metadata.rs create mode 100644 src/commands/version.rs delete mode 100644 src/text.rs diff --git a/Cargo.lock b/Cargo.lock index 875c765..4a96139 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "acridotheres_core" version = "0.1.1" -source = "git+https://github.com/acridotheres/core.git?tag=v0.1.1#451081afea0fb101834ee0da02351c2023833030" +source = "git+https://github.com/acridotheres/core.git?tag=v0.2.0#92b0704484fa38735249168fc6f23bfca066c3e1" dependencies = [ "chrono", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index d5ee0ba..3ce3af0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.1.1" } +acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.2.0" } byte-unit = { version = "5.1.4", features = ["u128"] } clap = { version = "4.5.7", features = ["derive"] } diff --git a/src/commands.rs b/src/commands.rs new file mode 100644 index 0000000..f7d3d48 --- /dev/null +++ b/src/commands.rs @@ -0,0 +1,4 @@ +pub mod metadata; +pub mod version; +pub mod list; +pub mod extract; \ No newline at end of file diff --git a/src/commands/extract.rs b/src/commands/extract.rs new file mode 100644 index 0000000..ab40e82 --- /dev/null +++ b/src/commands/extract.rs @@ -0,0 +1,5 @@ +use corelib::{archive, formats}; + +pub fn extract(format: String, input: String, output: String, index: Option, path: Option, all: bool, check_integrity: bool, buffer_size: u64) { + archive::extract(formats::from_string(&format), input, output, index, path, all, check_integrity, buffer_size).unwrap(); +} \ No newline at end of file diff --git a/src/commands/list.rs b/src/commands/list.rs new file mode 100644 index 0000000..2cdf732 --- /dev/null +++ b/src/commands/list.rs @@ -0,0 +1,43 @@ +use corelib::{ + archive::{self, OriginalArchiveMetadata}, + formats::{self, Formats}, +}; + +pub fn list(format_string: String, input: String, check_integrity: bool, buffer_size: u64) { + let format = formats::from_string(&format_string); + let metadata = archive::metadata(format, input, check_integrity, buffer_size).unwrap(); + + match format { + Formats::Zip => { + let metadata = match *metadata { + OriginalArchiveMetadata::Zip(metadata) => metadata, + }; + + let mut i: u32 = 0; + println!(""); + for file in &metadata.files { + println!("{}", file.path); + println!("{}", "=".repeat(file.path.len())); + println!("Index: {}", i); + if file.is_directory { + println!("Directory\n"); + } else { + println!( + "Size: {} ({} compressed)", + byte_unit::Byte::from_u64(file.uncompressed_size.into()) + .get_appropriate_unit(byte_unit::UnitType::Decimal), + byte_unit::Byte::from_u64(file.size.into()) + .get_appropriate_unit(byte_unit::UnitType::Decimal) + ); + println!( + "Last modified: {}", + file.modified.format("%Y-%m-%d %H:%M:%S") + ); + println!("CRC-32 checksum: 0x{:x}", file.checksum); + println!("Compression method: {}\n", file.compression); + }; + i += 1; + } + } + } +} diff --git a/src/commands/metadata.rs b/src/commands/metadata.rs new file mode 100644 index 0000000..a2e45db --- /dev/null +++ b/src/commands/metadata.rs @@ -0,0 +1,44 @@ +use corelib::{ + archive::{self, OriginalArchiveMetadata}, + formats::{self, Formats}, +}; + +pub fn metadata(format_string: String, input: String, check_integrity: bool, buffer_size: u64) { + let format = formats::from_string(&format_string); + let metadata = archive::metadata(format, input, check_integrity, buffer_size).unwrap(); + + match format { + Formats::Zip => { + let metadata = match *metadata { + OriginalArchiveMetadata::Zip(metadata) => metadata, + }; + + println!("Type: {}", format_string); + let mut file_count: u32 = 0; + let mut dir_count: u32 = 0; + for file in &metadata.files { + if file.is_directory { + dir_count += 1; + continue; + } + file_count += 1; + } + println!("Files: {}", file_count); + println!("Directories: {}", dir_count); + let mut total_size = 0; + for file in &metadata.files { + total_size += file.uncompressed_size; + } + let total_size = byte_unit::Byte::from_u64(total_size.into()) + .get_appropriate_unit(byte_unit::UnitType::Decimal); + println!("Total size (uncompressed): {}", total_size); + let mut total_size = 0; + for file in &metadata.files { + total_size += file.size; + } + let total_size = byte_unit::Byte::from_u64(total_size.into()) + .get_appropriate_unit(byte_unit::UnitType::Decimal); + println!("Total size (compressed): {}", total_size); + } + } +} diff --git a/src/commands/version.rs b/src/commands/version.rs new file mode 100644 index 0000000..2e1d388 --- /dev/null +++ b/src/commands/version.rs @@ -0,0 +1,5 @@ +pub fn version() { + println!("Acridotheres\n"); + println!("cli v{}", env!("CARGO_PKG_VERSION")); + println!("core v{}", corelib::get_version()); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 20691e0..667fe04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -mod text; +//mod text; +mod commands; use clap::Parser; @@ -44,6 +45,14 @@ struct Args { /// "all" (combine with -x or similar) #[arg(short, long)] all: bool, + + /// Skip integrity checks (not recommended, faster) + #[arg(long, default_value = "false")] + skip_integrity_checks: bool, + + /// Buffer size for file operations in bytes + #[arg(long, default_value = "16777216")] + buffer: u64, } fn get_command(args: &Args) -> &'static str { @@ -65,32 +74,30 @@ fn main() { let command = get_command(&args); - let format = args.input_type.unwrap_or_else(|| { - // add format detection here - "".to_string() - }); - let format = format.as_str(); - match command { - "version" => text::get_version(), - "metadata" => match format { - "zip" => text::zip_metadata(args.input.unwrap()), - _ => println!("Unknown format"), - }, - "list" => match format { - "zip" => text::zip_list(args.input.unwrap()), - _ => println!("Unknown format"), - }, - "extract" => match format { - "zip" => text::zip_extract( - args.input.unwrap(), - args.output.unwrap(), - args.index, - args.path, - args.all, - ), - _ => println!("Unknown format"), - }, + "version" => commands::version::version(), + "metadata" => commands::metadata::metadata( + args.input_type.unwrap(), + args.input.unwrap(), + !args.skip_integrity_checks, + args.buffer, + ), + "list" => commands::list::list( + args.input_type.unwrap(), + args.input.unwrap(), + !args.skip_integrity_checks, + args.buffer, + ), + "extract" => commands::extract::extract( + args.input_type.unwrap(), + args.input.unwrap(), + args.output.unwrap(), + args.index, + args.path, + args.all, + !args.skip_integrity_checks, + args.buffer, + ), _ => println!("Nothing to do, try --help"), } } diff --git a/src/text.rs b/src/text.rs deleted file mode 100644 index ef8ac46..0000000 --- a/src/text.rs +++ /dev/null @@ -1,148 +0,0 @@ -use byte_unit; -use corelib; - -pub fn get_version() { - println!("Acridotheres\n"); - println!("cli v{}", env!("CARGO_PKG_VERSION")); - println!("core v{}", corelib::get_version()); -} - -pub fn zip_metadata(path: String) { - let mut file = corelib::FileReader::new(&path); - - let metadata = corelib::formats::zip::parser::metadata(&mut file); - - println!("Type: {}", metadata.archive.format); - let mut file_count: u32 = 0; - let mut dir_count: u32 = 0; - for file in &metadata.files { - if file.file.is_directory { - dir_count += 1; - continue; - } - file_count += 1; - } - println!("Files: {}", file_count); - println!("Directories: {}", dir_count); - let mut total_size = 0; - for file in &metadata.files { - total_size += file.uncompressed_size; - } - let total_size = byte_unit::Byte::from_u64(total_size.into()) - .get_appropriate_unit(byte_unit::UnitType::Decimal); - println!("Total size (uncompressed): {}", total_size); - let mut total_size = 0; - for file in &metadata.files { - total_size += file.file.size; - } - let total_size = byte_unit::Byte::from_u64(total_size.into()) - .get_appropriate_unit(byte_unit::UnitType::Decimal); - println!("Total size (compressed): {}", total_size); -} - -pub fn zip_list(path: String) { - let mut file = corelib::FileReader::new(&path); - - let metadata = corelib::formats::zip::parser::metadata(&mut file); - - let mut i: u32 = 0; - println!(""); - for file in &metadata.files { - println!("{}", file.file.path); - println!("{}", "=".repeat(file.file.path.len())); - println!("Index: {}", i); - if file.file.is_directory { - println!("Directory\n"); - } else { - println!( - "Size: {} ({} compressed)", - byte_unit::Byte::from_u64(file.uncompressed_size.into()) - .get_appropriate_unit(byte_unit::UnitType::Decimal), - byte_unit::Byte::from_u64(file.file.size.into()) - .get_appropriate_unit(byte_unit::UnitType::Decimal) - ); - println!( - "Last modified: {}", - file.file.modified.format("%Y-%m-%d %H:%M:%S") - ); - println!("CRC-32 checksum: 0x{:x}", file.checksum); - println!("Compression method: {}\n", file.compression); - }; - i += 1; - } -} - -pub fn zip_extract( - input: String, - output: String, - index: Option, - path: Option, - all: bool, -) { - let mut file = corelib::FileReader::new(&input); - std::fs::create_dir_all(&output).unwrap(); - - let metadata = corelib::formats::zip::parser::metadata(&mut file); - - if all { - corelib::formats::zip::parser::extract(&mut file, &metadata.files, &1024, &|path| { - format!("{}/{}", &output, &path) - }); - } else { - if index != None { - let index = index.unwrap(); - if index >= metadata.files.len() as u32 { - println!("Index out of range"); - return; - } - let files = &vec![corelib::ZipFileEntry { - file: corelib::FileEntry { - path: metadata.files[index as usize].file.path.clone(), - size: metadata.files[index as usize].file.size, - offset: metadata.files[index as usize].file.offset, - modified: metadata.files[index as usize].file.modified, - is_directory: metadata.files[index as usize].file.is_directory, - }, - uncompressed_size: metadata.files[index as usize].uncompressed_size, - checksum: metadata.files[index as usize].checksum, - extra_field: metadata.files[index as usize].extra_field.clone(), - version: metadata.files[index as usize].version, - bit_flag: metadata.files[index as usize].bit_flag, - compression: metadata.files[index as usize].compression, - }]; - corelib::formats::zip::parser::extract(&mut file, files, &1024, &|path| { - format!("{}/{}", &output, &path) - }); - } else { - let path = path.unwrap(); - let files: Vec = metadata - .files - .iter() - .filter_map(|file| { - if file.file.path.starts_with(&path) { - Some(corelib::ZipFileEntry { - file: corelib::FileEntry { - path: file.file.path.clone(), - size: file.file.size, - offset: file.file.offset, - modified: file.file.modified, - is_directory: file.file.is_directory, - }, - uncompressed_size: file.uncompressed_size, - checksum: file.checksum, - extra_field: file.extra_field.clone(), - version: file.version, - bit_flag: file.bit_flag, - compression: file.compression, - }) - } else { - None - } - }) - .collect(); - corelib::formats::zip::parser::extract(&mut file, &files, &1024, &|path| { - format!("{}/{}", &output, &path) - }); - } - }; -} From 4ddaf503a8da02990432229262ce850fbf5f320e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 19:56:02 +0000 Subject: [PATCH 3/7] Format Rust code using rustfmt --- src/commands.rs | 4 ++-- src/commands/extract.rs | 25 ++++++++++++++++++++++--- src/commands/version.rs | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index f7d3d48..5cee882 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,4 +1,4 @@ +pub mod extract; +pub mod list; pub mod metadata; pub mod version; -pub mod list; -pub mod extract; \ No newline at end of file diff --git a/src/commands/extract.rs b/src/commands/extract.rs index ab40e82..9b0f15c 100644 --- a/src/commands/extract.rs +++ b/src/commands/extract.rs @@ -1,5 +1,24 @@ use corelib::{archive, formats}; -pub fn extract(format: String, input: String, output: String, index: Option, path: Option, all: bool, check_integrity: bool, buffer_size: u64) { - archive::extract(formats::from_string(&format), input, output, index, path, all, check_integrity, buffer_size).unwrap(); -} \ No newline at end of file +pub fn extract( + format: String, + input: String, + output: String, + index: Option, + path: Option, + all: bool, + check_integrity: bool, + buffer_size: u64, +) { + archive::extract( + formats::from_string(&format), + input, + output, + index, + path, + all, + check_integrity, + buffer_size, + ) + .unwrap(); +} diff --git a/src/commands/version.rs b/src/commands/version.rs index 2e1d388..6392aaf 100644 --- a/src/commands/version.rs +++ b/src/commands/version.rs @@ -2,4 +2,4 @@ pub fn version() { println!("Acridotheres\n"); println!("cli v{}", env!("CARGO_PKG_VERSION")); println!("core v{}", corelib::get_version()); -} \ No newline at end of file +} From 75d54409e26354ed316e1d46b15760a2174e4f33 Mon Sep 17 00:00:00 2001 From: Leonard Lesinski <84378319+Le0X8@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:49:30 +0200 Subject: [PATCH 4/7] chore: Bump corelib to v2.0.1 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a96139..78ec966 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,8 +13,8 @@ dependencies = [ [[package]] name = "acridotheres_core" -version = "0.1.1" -source = "git+https://github.com/acridotheres/core.git?tag=v0.2.0#92b0704484fa38735249168fc6f23bfca066c3e1" +version = "0.2.1" +source = "git+https://github.com/acridotheres/core.git?tag=v0.2.1#b1525971fa4577d0351f59cc5bd33b66d5e0d93f" dependencies = [ "chrono", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index 3ce3af0..526430c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.2.0" } +acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.2.1" } byte-unit = { version = "5.1.4", features = ["u128"] } clap = { version = "4.5.7", features = ["derive"] } From b8c276142896fe2fdaf4ff610a5afdf16c7bf16f Mon Sep 17 00:00:00 2001 From: Leonard Lesinski <84378319+Le0X8@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:38:37 +0200 Subject: [PATCH 5/7] feat: Added archive creation --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/commands.rs | 1 + src/commands/create.rs | 31 +++++++++++++++++++++++++++++++ src/main.rs | 14 +++++++++++++- 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/commands/create.rs diff --git a/Cargo.lock b/Cargo.lock index 78ec966..f6faad8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,8 +13,8 @@ dependencies = [ [[package]] name = "acridotheres_core" -version = "0.2.1" -source = "git+https://github.com/acridotheres/core.git?tag=v0.2.1#b1525971fa4577d0351f59cc5bd33b66d5e0d93f" +version = "0.2.2" +source = "git+https://github.com/acridotheres/core.git?tag=v0.2.2#3dc5a7b12c7a218ddd465ef46349b938c73ae940" dependencies = [ "chrono", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index 526430c..dedaeaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.2.1" } +acridotheres_core = { git = "https://github.com/acridotheres/core.git", tag="v0.2.2" } byte-unit = { version = "5.1.4", features = ["u128"] } clap = { version = "4.5.7", features = ["derive"] } diff --git a/src/commands.rs b/src/commands.rs index 5cee882..f656358 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,3 +1,4 @@ +pub mod create; pub mod extract; pub mod list; pub mod metadata; diff --git a/src/commands/create.rs b/src/commands/create.rs new file mode 100644 index 0000000..cd64938 --- /dev/null +++ b/src/commands/create.rs @@ -0,0 +1,31 @@ +use corelib::{archive::{self, EntrySource}, file::FsFile, formats}; + +pub fn create( + format: String, + input: String, + output: String, + buffer_size: u64, +) { + let files: Vec = input.split(';').map(|file| { + let file = file.split(':').collect::>(); + let source_path = file.get(0).unwrap(); + let mut target_path = source_path; + match file.get(1) { + Some(path) => { + target_path = path; + } + None => {} + } + EntrySource { + path: target_path.to_string(), + source: FsFile::new(&source_path.to_string()), + } + }).collect(); + archive::create( + formats::from_string(&format), + output, + files, + buffer_size, + ) + .unwrap(); +} diff --git a/src/main.rs b/src/main.rs index 667fe04..26392a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ struct Args { #[arg(short = 't', long = "type")] input_type: Option, - /// Path to input file + /// Path to input file (if creating, multiple files can be separated by semicolons) #[arg(short, long)] input: Option, @@ -34,6 +34,10 @@ struct Args { #[arg(short = 'x', long = "extract")] extract: bool, + /// Create archive + #[arg(short, long)] + create: bool, + /// by path #[arg(short = 'p', long = "path", value_name = "PATH")] path: Option, @@ -64,6 +68,8 @@ fn get_command(args: &Args) -> &'static str { "list" } else if args.extract { "extract" + } else if args.create { + "create" } else { "" } @@ -98,6 +104,12 @@ fn main() { !args.skip_integrity_checks, args.buffer, ), + "create" => commands::create::create( + args.input_type.unwrap(), + args.input.unwrap(), + args.output.unwrap(), + args.buffer, + ), _ => println!("Nothing to do, try --help"), } } From 4a32157f2b60910dc73dc704a91e0706e4ae7189 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:38:52 +0000 Subject: [PATCH 6/7] Format Rust code using rustfmt --- src/commands/create.rs | 52 +++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/commands/create.rs b/src/commands/create.rs index cd64938..f5525af 100644 --- a/src/commands/create.rs +++ b/src/commands/create.rs @@ -1,31 +1,27 @@ -use corelib::{archive::{self, EntrySource}, file::FsFile, formats}; +use corelib::{ + archive::{self, EntrySource}, + file::FsFile, + formats, +}; -pub fn create( - format: String, - input: String, - output: String, - buffer_size: u64, -) { - let files: Vec = input.split(';').map(|file| { - let file = file.split(':').collect::>(); - let source_path = file.get(0).unwrap(); - let mut target_path = source_path; - match file.get(1) { - Some(path) => { - target_path = path; +pub fn create(format: String, input: String, output: String, buffer_size: u64) { + let files: Vec = input + .split(';') + .map(|file| { + let file = file.split(':').collect::>(); + let source_path = file.get(0).unwrap(); + let mut target_path = source_path; + match file.get(1) { + Some(path) => { + target_path = path; + } + None => {} } - None => {} - } - EntrySource { - path: target_path.to_string(), - source: FsFile::new(&source_path.to_string()), - } - }).collect(); - archive::create( - formats::from_string(&format), - output, - files, - buffer_size, - ) - .unwrap(); + EntrySource { + path: target_path.to_string(), + source: FsFile::new(&source_path.to_string()), + } + }) + .collect(); + archive::create(formats::from_string(&format), output, files, buffer_size).unwrap(); } From 337b7c431435543a95270792df4d7895748d58ba Mon Sep 17 00:00:00 2001 From: Leonard Lesinski <84378319+Le0X8@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:46:29 +0200 Subject: [PATCH 7/7] chore: Added CI and fixed Clippy warnings --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ .vscode/extensions.json | 16 ++++++++++++++++ .vscode/settings.json | 11 ++++++++++- src/commands/create.rs | 9 +++------ src/commands/list.rs | 12 ++++-------- src/commands/metadata.rs | 6 ++---- src/main.rs | 3 ++- 7 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .vscode/extensions.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0008304 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: Run CI +on: [push, pull_request] +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - name: Set up Rust + uses: actions/checkout@v4 + - name: Install cargo-audit + run: cargo install cargo-audit + - name: Build + run: cargo build --verbose + - name: Run clippy + run: cargo clippy --verbose -- -D warnings + - name: Run audit + run: cargo audit \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d486f31 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,16 @@ +{ + "recommendations": [ + "github.vscode-github-actions", + "ms-vscode.hexeditor", + "wakatime.vscode-wakatime", + "github.vscode-pull-request-github", + "fill-labs.dependi", + "tamasfe.even-better-toml", + "github.remotehub", + "dustypomerleau.rust-syntax", + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + "usernamehw.errorlens", + "gruntfuggly.todo-tree" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 68ebc15..5a89bd3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "editor.tabSize": 4 + "editor.tabSize": 4, + "errorLens.enabled": true, + "errorLens.gutterIconsEnabled": true, + "errorLens.gutterIconSet": "squareRounded", + "todo-tree.regex.regex": "(//|#|