Merge relay debug view fixes & more strict args #711

Ken Sedgwick (5):
      drive-by compiler warning fixes
      drive-by clippy fixes
      add derive Debug to some things
      panic on unknown CLI arguments
      move RelayDebugView to notedeck crate and restore --relay-debug

William Casarin (4):
      clippy: fix lint
      args: skip creation of vec
      nix: fix android build

Link: https://github.com/damus-io/notedeck/pull/711
This commit is contained in:
William Casarin
2025-02-10 17:03:18 -08:00
13 changed files with 129 additions and 17 deletions

View File

@@ -60,6 +60,19 @@ pub async fn android_main(app: AndroidApp) {
setup_chrome(ctx, &notedeck.args(), notedeck.theme());
let damus = Damus::new(&mut notedeck.app_context(), &app_args);
// ensure we recognized all the arguments
let completely_unrecognized: Vec<String> = notedeck
.unrecognized_args()
.intersection(damus.unrecognized_args())
.cloned()
.collect();
assert!(
completely_unrecognized.is_empty(),
"unrecognized args: {:?}",
completely_unrecognized
);
notedeck.set_app(damus);
Ok(Box::new(notedeck))

View File

@@ -82,6 +82,19 @@ async fn main() {
setup_chrome(ctx, notedeck.args(), notedeck.theme());
let damus = Damus::new(&mut notedeck.app_context(), &args);
// ensure we recognized all the arguments
let completely_unrecognized: Vec<String> = notedeck
.unrecognized_args()
.intersection(damus.unrecognized_args())
.cloned()
.collect();
assert!(
completely_unrecognized.is_empty(),
"unrecognized args: {:?}",
completely_unrecognized
);
// TODO: move "chrome" frame over Damus app somehow
notedeck.set_app(damus);
@@ -135,7 +148,7 @@ mod tests {
async fn test_dbpath() {
let datapath = create_tmp_dir();
let dbpath = create_tmp_dir();
let args: Vec<String> = vec![
let args: Vec<String> = [
"--testrunner",
"--datapath",
&datapath.to_str().unwrap(),
@@ -161,7 +174,7 @@ mod tests {
async fn test_column_args() {
let tmpdir = create_tmp_dir();
let npub = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s";
let args: Vec<String> = vec![
let args: Vec<String> = [
"--testrunner",
"--no-keystore",
"--pub",
@@ -177,9 +190,21 @@ mod tests {
let ctx = egui::Context::default();
let mut notedeck = Notedeck::new(&ctx, &tmpdir, &args);
let unrecognized_args = notedeck.unrecognized_args().clone();
let mut app_ctx = notedeck.app_context();
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);
let tl1 = app
@@ -204,4 +229,39 @@ mod tests {
rmrf(tmpdir);
}
#[tokio::test]
async fn test_unknown_args() {
let tmpdir = create_tmp_dir();
let npub = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s";
let args: Vec<String> = [
"--testrunner",
"--no-keystore",
"--unknown-arg", // <-- UNKNOWN
"--pub",
npub,
"-c",
"notifications",
"-c",
"contacts",
]
.iter()
.map(|s| s.to_string())
.collect();
let ctx = egui::Context::default();
let mut notedeck = Notedeck::new(&ctx, &tmpdir, &args);
let mut app_ctx = notedeck.app_context();
let app = Damus::new(&mut app_ctx, &args);
// ensure we recognized all the arguments
let completely_unrecognized: Vec<String> = notedeck
.unrecognized_args()
.intersection(app.unrecognized_args())
.cloned()
.collect();
assert_eq!(completely_unrecognized, ["--unknown-arg"]);
rmrf(tmpdir);
}
}

View File

@@ -33,6 +33,11 @@ impl PreviewRunner {
let ctx = &cc.egui_ctx;
let mut notedeck = Notedeck::new(ctx, &base_path, &args);
assert!(
notedeck.unrecognized_args().is_empty(),
"unrecognized args: {:?}",
notedeck.unrecognized_args()
);
setup_chrome(ctx, notedeck.args(), notedeck.theme());
notedeck.set_app(PreviewApp::new(preview));