Skip to content

Commit 749f304

Browse files
committed
distrbuted the library packages and worked on the sync functionality to print file name, type, and last modified date
1 parent fb0f822 commit 749f304

25 files changed

Lines changed: 482 additions & 28 deletions

File tree

Cargo.lock

Lines changed: 165 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
[workspace]
22
resolver = "3"
3-
members = ["cli", "crates"]
3+
members = ["cli", "crates/*"]
44

55
[workspace.dependencies]
66
clap = { version = "4.5.47", features = ["derive"] }
7+
time = { version = "0.3.44", features = ["local-offset", "macros", "formatting"] }
8+
walkdir = "2.5.0"
79

810
[workspace.package]
911
edition = "2024"
1012
repository = "https://github.com/ibilalkayy/cover"
11-
version = "0.1.0"
13+
version = "0.1.1"
1214
license = "Apache-2.0"
1315
readme = "README.md"
1416
categories = ["command-line-utilities"]

cli/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ categories.workspace = true
99

1010
[dependencies]
1111
clap.workspace = true
12+
clean = { path = "../crates/clean" }
13+
archive = { path = "../crates/archive" }
14+
list = { path = "../crates/list" }
15+
restore = { path = "../crates/restore" }
16+
schedule = { path = "../crates/schedule" }
17+
sync = { path = "../crates/sync" }

cli/src/flags/restore.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::PathBuf;
2-
31
use clap::Parser;
2+
use std::path::PathBuf;
43

54
#[derive(Debug, Parser)]
65
pub struct RestoreData {

cli/src/flags/sync.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ use clap::Parser;
22

33
#[derive(Debug, Parser)]
44
pub struct SyncData {
5+
/// Source folder to take the file from
6+
#[clap(short, long)]
7+
pub source: String,
8+
9+
/// Destination folder to move the file to
10+
#[clap(short, long)]
11+
pub destination: String,
12+
513
/// Copy only the changed files
614
#[clap(long)]
715
pub incremental: Option<bool>,

cli/src/main.rs

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,71 @@ pub mod commands;
22
pub mod flags;
33

44
use crate::commands::commands::{Command, Cover};
5+
use archive::ArchiveData;
56
use clap::Parser;
7+
use clean::CleanData;
8+
use list::ListData;
9+
use restore::RestoreData;
10+
use schedule::ScheduleData;
11+
use sync::SyncData;
612

713
fn handle_commands() {
814
let cover = Cover::parse();
915
match cover.command {
10-
Command::Sync(_s) => println!("Sync data"),
11-
Command::Archive(_a) => println!("Archive data"),
12-
Command::Restore(_r) => println!("Restore data"),
13-
Command::Schedule(_s) => println!("Schedule data"),
14-
Command::List(_l) => println!("List data"),
15-
Command::Clean(_c) => println!("Clean data"),
16+
Command::Sync(s) => {
17+
let sync_data = SyncData {
18+
source: s.source,
19+
destination: s.destination,
20+
incremental: s.incremental,
21+
delete: s.delete,
22+
dry_run: s.dry_run,
23+
verbose: s.verbose,
24+
hash: s.hash,
25+
};
26+
sync_data.sync_options();
27+
}
28+
Command::Archive(a) => {
29+
let archive_data = ArchiveData {
30+
zip: a.zip,
31+
tar: a.tar,
32+
encrypt: a.encrypt,
33+
timestamp: a.timestamp,
34+
};
35+
archive_data.archive_options();
36+
}
37+
Command::Restore(r) => {
38+
let restore_data = RestoreData {
39+
overwrite: r.overwrite,
40+
to: r.to,
41+
select: r.select,
42+
};
43+
restore_data.restore_options();
44+
}
45+
Command::Schedule(s) => {
46+
let schedule_data = ScheduleData {
47+
daily: s.daily,
48+
weekly: s.weekly,
49+
interval: s.interval,
50+
command: s.command,
51+
};
52+
schedule_data.schedule_options();
53+
}
54+
Command::List(l) => {
55+
let list_data = ListData {
56+
archives: l.archives,
57+
schedules: l.schedules,
58+
details: l.details,
59+
};
60+
list_data.list_options();
61+
}
62+
Command::Clean(c) => {
63+
let clean_data = CleanData {
64+
keep_last: c.keep_last,
65+
older_than: c.older_than,
66+
dry_run: c.dry_run,
67+
};
68+
clean_data.clean_options();
69+
}
1670
}
1771
}
1872

crates/archive/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "archive"
3+
edition.workspace = true
4+
repository.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
readme.workspace = true
8+
categories.workspace = true
9+
10+
[dependencies]

crates/archive/README.md

Whitespace-only changes.

crates/archive/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pub struct ArchiveData {
2+
pub zip: Option<bool>,
3+
pub tar: Option<bool>,
4+
pub encrypt: Option<bool>,
5+
pub timestamp: Option<bool>,
6+
}
7+
8+
impl ArchiveData {
9+
pub fn archive_output(&self) {
10+
println!("{}", self.zip.unwrap());
11+
println!("{}", self.tar.unwrap());
12+
println!("{}", self.encrypt.unwrap());
13+
println!("{}", self.timestamp.unwrap());
14+
}
15+
16+
pub fn archive_options(&self) {
17+
self.archive_output();
18+
}
19+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "crates"
2+
name = "clean"
33
edition.workspace = true
44
repository.workspace = true
55
version.workspace = true

0 commit comments

Comments
 (0)