Do not crash on unknown arg
Signed-off-by: Jakub Gladysz <jakub.gladysz@protonmail.com>
This commit is contained in:
@@ -2,11 +2,13 @@
|
|||||||
//use egui_android::run_android;
|
//use egui_android::run_android;
|
||||||
|
|
||||||
use egui_winit::winit::platform::android::activity::AndroidApp;
|
use egui_winit::winit::platform::android::activity::AndroidApp;
|
||||||
|
use notedeck::enostr::Error;
|
||||||
use notedeck_columns::Damus;
|
use notedeck_columns::Damus;
|
||||||
use notedeck_dave::Dave;
|
use notedeck_dave::Dave;
|
||||||
|
|
||||||
use crate::{app::NotedeckApp, chrome::Chrome, setup::setup_chrome};
|
use crate::{app::NotedeckApp, chrome::Chrome, setup::setup_chrome};
|
||||||
use notedeck::Notedeck;
|
use notedeck::Notedeck;
|
||||||
|
use tracing::error;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -80,11 +82,10 @@ pub async fn android_main(app: AndroidApp) {
|
|||||||
.intersection(columns.unrecognized_args())
|
.intersection(columns.unrecognized_args())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
assert!(
|
if !completely_unrecognized.is_empty() {
|
||||||
completely_unrecognized.is_empty(),
|
error!("Unrecognized arguments: {:?}", completely_unrecognized);
|
||||||
"unrecognized args: {:?}",
|
return Err(Error::Empty.into());
|
||||||
completely_unrecognized
|
}
|
||||||
);
|
|
||||||
|
|
||||||
chrome.add_app(NotedeckApp::Columns(columns));
|
chrome.add_app(NotedeckApp::Columns(columns));
|
||||||
chrome.add_app(NotedeckApp::Dave(dave));
|
chrome.add_app(NotedeckApp::Dave(dave));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use re_memory::AccountingAllocator;
|
|||||||
static GLOBAL: AccountingAllocator<std::alloc::System> =
|
static GLOBAL: AccountingAllocator<std::alloc::System> =
|
||||||
AccountingAllocator::new(std::alloc::System);
|
AccountingAllocator::new(std::alloc::System);
|
||||||
|
|
||||||
|
use notedeck::enostr::Error;
|
||||||
use notedeck::{DataPath, DataPathType, Notedeck};
|
use notedeck::{DataPath, DataPathType, Notedeck};
|
||||||
use notedeck_chrome::{
|
use notedeck_chrome::{
|
||||||
setup::{generate_native_options, setup_chrome},
|
setup::{generate_native_options, setup_chrome},
|
||||||
@@ -16,6 +17,7 @@ use notedeck_chrome::{
|
|||||||
};
|
};
|
||||||
use notedeck_columns::Damus;
|
use notedeck_columns::Damus;
|
||||||
use notedeck_dave::Dave;
|
use notedeck_dave::Dave;
|
||||||
|
use tracing::error;
|
||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
@@ -104,10 +106,10 @@ async fn main() {
|
|||||||
.intersection(columns.unrecognized_args())
|
.intersection(columns.unrecognized_args())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
assert!(
|
if !completely_unrecognized.is_empty() {
|
||||||
completely_unrecognized.is_empty(),
|
error!("Unrecognized arguments: {:?}", completely_unrecognized);
|
||||||
"unrecognized args: {completely_unrecognized:?}"
|
return Err(Error::Empty.into());
|
||||||
);
|
}
|
||||||
|
|
||||||
chrome.add_app(NotedeckApp::Columns(columns));
|
chrome.add_app(NotedeckApp::Columns(columns));
|
||||||
chrome.add_app(NotedeckApp::Dave(dave));
|
chrome.add_app(NotedeckApp::Dave(dave));
|
||||||
@@ -212,17 +214,6 @@ mod tests {
|
|||||||
let mut app_ctx = notedeck.app_context();
|
let mut app_ctx = notedeck.app_context();
|
||||||
let app = Damus::new(&mut app_ctx, &args);
|
let app = Damus::new(&mut app_ctx, &args);
|
||||||
|
|
||||||
// ensure we recognized all the arguments
|
|
||||||
let completely_unrecognized: Vec<String> = unrecognized_args
|
|
||||||
.intersection(app.unrecognized_args())
|
|
||||||
.cloned()
|
|
||||||
.collect();
|
|
||||||
assert!(
|
|
||||||
completely_unrecognized.is_empty(),
|
|
||||||
"unrecognized args: {:?}",
|
|
||||||
completely_unrecognized
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(app.columns(app_ctx.accounts).columns().len(), 2);
|
assert_eq!(app.columns(app_ctx.accounts).columns().len(), 2);
|
||||||
|
|
||||||
let tl1 = app
|
let tl1 = app
|
||||||
|
|||||||
Reference in New Issue
Block a user