Skip to content

Commit 8a6b9ed

Browse files
committed
feat(sync): add --archived-only flag
1 parent 938696d commit 8a6b9ed

5 files changed

Lines changed: 19 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tgcli"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
edition = "2021"
55
authors = ["Dario <me@dgrp.es>"]
66
description = "Telegram CLI tool using grammers (pure Rust MTProto)"

src/app/sync.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub struct SyncOptions {
4646
pub prune_after: Option<usize>,
4747
/// Skip archived chats entirely (don't fetch dialogs or messages from archived folder)
4848
pub skip_archived: bool,
49+
/// Sync ONLY archived chats (opposite of --skip-archived)
50+
pub archived_only: bool,
4951
}
5052

5153
/// Get media type string and file extension from grammers Media enum
@@ -618,6 +620,8 @@ impl App {
618620

619621
// Filter chats to process
620622
let chat_filter = opts.chat_filter;
623+
let skip_archived = opts.skip_archived;
624+
let archived_only = opts.archived_only;
621625
let chats_to_sync: Vec<_> = all_chats
622626
.into_iter()
623627
.filter(|chat| {
@@ -633,6 +637,13 @@ impl App {
633637
if ignore_channels && chat.kind == "channel" {
634638
return false;
635639
}
640+
// Filter by archived status
641+
if skip_archived && chat.archived {
642+
return false;
643+
}
644+
if archived_only && !chat.archived {
645+
return false;
646+
}
636647
// Must have peer info to sync
637648
self.resolve_peer_from_session(chat.id, &chat.kind, chat.access_hash)
638649
.is_some()

src/cmd/daemon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ pub async fn run(cli: &Cli, args: &DaemonArgs) -> Result<()> {
217217
chat_filter: None,
218218
prune_after: None,
219219
skip_archived: false,
220+
archived_only: false,
220221
};
221222

222223
let result = backfill_app.sync(opts).await;

src/cmd/sync.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ pub struct CommonSyncArgs {
5454
/// Skip archived chats entirely (don't fetch dialogs or messages from archived folder)
5555
#[arg(long, default_value_t = false)]
5656
pub skip_archived: bool,
57+
58+
/// Sync ONLY archived chats (opposite of --skip-archived)
59+
#[arg(long, default_value_t = false, conflicts_with = "skip_archived")]
60+
pub archived_only: bool,
5761
}
5862

5963
#[derive(Subcommand, Debug, Clone)]
@@ -112,6 +116,7 @@ fn build_sync_options(common: &CommonSyncArgs) -> crate::app::sync::SyncOptions
112116
chat_filter: None,
113117
prune_after: common.prune_after,
114118
skip_archived: common.skip_archived,
119+
archived_only: common.archived_only,
115120
}
116121
}
117122

0 commit comments

Comments
 (0)