panic on unknown CLI arguments
Currently silently ignores which is not helpful ...
This commit is contained in:
@@ -22,7 +22,7 @@ use egui_extras::{Size, StripBuilder};
|
||||
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
use tracing::{error, info, trace, warn};
|
||||
@@ -51,6 +51,8 @@ pub struct Damus {
|
||||
pub debug: bool,
|
||||
pub since_optimize: bool,
|
||||
pub textmode: bool,
|
||||
|
||||
pub unrecognized_args: BTreeSet<String>,
|
||||
}
|
||||
|
||||
fn handle_key_events(input: &egui::InputState, columns: &mut Columns) {
|
||||
@@ -357,7 +359,7 @@ impl Damus {
|
||||
pub fn new(ctx: &mut AppContext<'_>, args: &[String]) -> Self {
|
||||
// arg parsing
|
||||
|
||||
let parsed_args = ColumnsArgs::parse(
|
||||
let (parsed_args, unrecognized_args) = ColumnsArgs::parse(
|
||||
args,
|
||||
ctx.accounts
|
||||
.get_selected_account()
|
||||
@@ -433,6 +435,7 @@ impl Damus {
|
||||
support,
|
||||
decks_cache,
|
||||
debug,
|
||||
unrecognized_args,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,12 +478,17 @@ impl Damus {
|
||||
view_state: ViewState::default(),
|
||||
support,
|
||||
decks_cache,
|
||||
unrecognized_args: BTreeSet::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn subscriptions(&mut self) -> &mut HashMap<String, SubKind> {
|
||||
&mut self.subscriptions.subs
|
||||
}
|
||||
|
||||
pub fn unrecognized_args(&self) -> &BTreeSet<String> {
|
||||
&self.unrecognized_args
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::timeline::TimelineKind;
|
||||
use enostr::{Filter, Pubkey};
|
||||
use tracing::{debug, error, info};
|
||||
@@ -9,7 +11,8 @@ pub struct ColumnsArgs {
|
||||
}
|
||||
|
||||
impl ColumnsArgs {
|
||||
pub fn parse(args: &[String], deck_author: Option<&Pubkey>) -> Self {
|
||||
pub fn parse(args: &[String], deck_author: Option<&Pubkey>) -> (Self, BTreeSet<String>) {
|
||||
let mut unrecognized_args = BTreeSet::new();
|
||||
let mut res = Self {
|
||||
columns: vec![],
|
||||
since_optimize: true,
|
||||
@@ -132,12 +135,14 @@ impl ColumnsArgs {
|
||||
} else {
|
||||
error!("failed to parse filter in '{}'", filter_file);
|
||||
}
|
||||
} else {
|
||||
unrecognized_args.insert(arg.clone());
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
res
|
||||
(res, unrecognized_args)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user