arg: add -c profile{,:pubkey} arg column
This allows you to add profile columns Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
15
src/args.rs
15
src/args.rs
@@ -150,6 +150,21 @@ impl Args {
|
|||||||
.push(ArgColumn::Column(ColumnKind::notifications(
|
.push(ArgColumn::Column(ColumnKind::notifications(
|
||||||
PubkeySource::DeckAuthor,
|
PubkeySource::DeckAuthor,
|
||||||
)))
|
)))
|
||||||
|
} else if column_name == "profile" {
|
||||||
|
debug!("got profile column for default user");
|
||||||
|
res.columns.push(ArgColumn::Column(ColumnKind::profile(
|
||||||
|
PubkeySource::DeckAuthor,
|
||||||
|
)))
|
||||||
|
} else if let Some(profile_pk_str) = column_name.strip_prefix("profile:") {
|
||||||
|
if let Ok(pubkey) = Pubkey::parse(profile_pk_str) {
|
||||||
|
info!("got profile column for user {}", pubkey.hex());
|
||||||
|
res.columns.push(ArgColumn::Column(ColumnKind::profile(
|
||||||
|
PubkeySource::Explicit(pubkey),
|
||||||
|
)))
|
||||||
|
} else {
|
||||||
|
error!("error parsing profile pubkey {}", profile_pk_str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if arg == "--filter-file" || arg == "-f" {
|
} else if arg == "--filter-file" || arg == "-f" {
|
||||||
i += 1;
|
i += 1;
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ pub enum ListKind {
|
|||||||
/// - DM
|
/// - DM
|
||||||
/// - filter
|
/// - filter
|
||||||
/// - ... etc
|
/// - ... etc
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ColumnKind {
|
pub enum ColumnKind {
|
||||||
List(ListKind),
|
List(ListKind),
|
||||||
|
|
||||||
Notifications(PubkeySource),
|
Notifications(PubkeySource),
|
||||||
|
|
||||||
|
Profile(PubkeySource),
|
||||||
|
|
||||||
Universe,
|
Universe,
|
||||||
|
|
||||||
/// Generic filter
|
/// Generic filter
|
||||||
@@ -43,6 +45,7 @@ impl Display for ColumnKind {
|
|||||||
ColumnKind::List(ListKind::Contact(_src)) => f.write_str("Contacts"),
|
ColumnKind::List(ListKind::Contact(_src)) => f.write_str("Contacts"),
|
||||||
ColumnKind::Generic => f.write_str("Timeline"),
|
ColumnKind::Generic => f.write_str("Timeline"),
|
||||||
ColumnKind::Notifications(_) => f.write_str("Notifications"),
|
ColumnKind::Notifications(_) => f.write_str("Notifications"),
|
||||||
|
ColumnKind::Profile(_) => f.write_str("Profile"),
|
||||||
ColumnKind::Universe => f.write_str("Universe"),
|
ColumnKind::Universe => f.write_str("Universe"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,6 +56,10 @@ impl ColumnKind {
|
|||||||
ColumnKind::List(ListKind::Contact(pk))
|
ColumnKind::List(ListKind::Contact(pk))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn profile(pk: PubkeySource) -> Self {
|
||||||
|
ColumnKind::Profile(pk)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn notifications(pk: PubkeySource) -> Self {
|
pub fn notifications(pk: PubkeySource) -> Self {
|
||||||
ColumnKind::Notifications(pk)
|
ColumnKind::Notifications(pk)
|
||||||
}
|
}
|
||||||
@@ -69,6 +76,24 @@ impl ColumnKind {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColumnKind::Profile(pk_src) => {
|
||||||
|
let pk = match &pk_src {
|
||||||
|
PubkeySource::DeckAuthor => default_user?,
|
||||||
|
PubkeySource::Explicit(pk) => pk.bytes(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let filter = Filter::new()
|
||||||
|
.authors([pk])
|
||||||
|
.kinds([1])
|
||||||
|
.limit(filter::default_limit())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Some(Timeline::new(
|
||||||
|
ColumnKind::profile(pk_src),
|
||||||
|
FilterState::ready(vec![filter]),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
ColumnKind::Notifications(pk_src) => {
|
ColumnKind::Notifications(pk_src) => {
|
||||||
let pk = match &pk_src {
|
let pk = match &pk_src {
|
||||||
PubkeySource::DeckAuthor => default_user?,
|
PubkeySource::DeckAuthor => default_user?,
|
||||||
|
|||||||
Reference in New Issue
Block a user