write shit
This commit is contained in:
@ -2,7 +2,7 @@ use clap::{Parser, Subcommand};
|
||||
use comfy_table::Table;
|
||||
use std::process;
|
||||
use thiserror::Error as TeError;
|
||||
use wfassoc::{Error as WfError, FileExt, Scope};
|
||||
use wfassoc::{Error as WfError, FileExt, Scope, View};
|
||||
|
||||
// region: Basic Types
|
||||
|
||||
@ -95,31 +95,36 @@ fn run_query(cli: Cli) -> Result<()> {
|
||||
".kra", ".xcf", ".avif", ".qoi", ".apng", ".exr",
|
||||
];
|
||||
|
||||
let mut table = Table::new();
|
||||
table.set_header(["Extension", "Default Open", "Open With"]);
|
||||
for ext in exts.iter().map(|e| FileExt::new(e).unwrap()) {
|
||||
if let Some(ext_assoc) = ext.query(Scope::User) {
|
||||
if ext_assoc.len_open_with_progid() == 0 {
|
||||
table.add_row([ext.to_string().as_str(), ext_assoc.get_default(), ""]);
|
||||
} else {
|
||||
for (i, open_with_entry) in ext_assoc.iter_open_with_progids().enumerate() {
|
||||
if i == 0 {
|
||||
table.add_row([
|
||||
ext.to_string().as_str(),
|
||||
ext_assoc.get_default(),
|
||||
open_with_entry,
|
||||
]);
|
||||
} else {
|
||||
table.add_row(["", "", open_with_entry]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
table.add_row([ext.to_string().as_str(), "", ""]);
|
||||
if let Some(ext_assoc) = ext.query(View::Hybrid) {
|
||||
println!("{:?}", ext_assoc)
|
||||
}
|
||||
}
|
||||
|
||||
println!("{table}");
|
||||
// let mut table = Table::new();
|
||||
// table.set_header(["Extension", "Default Open", "Open With"]);
|
||||
// for ext in exts.iter().map(|e| FileExt::new(e).unwrap()) {
|
||||
// if let Some(ext_assoc) = ext.query(View::Hybrid) {
|
||||
// if ext_assoc.len_open_with_progid() == 0 {
|
||||
// table.add_row([ext.to_string().as_str(), ext_assoc.get_default(), ""]);
|
||||
// } else {
|
||||
// for (i, open_with_entry) in ext_assoc.iter_open_with_progids().enumerate() {
|
||||
// if i == 0 {
|
||||
// table.add_row([
|
||||
// ext.to_string().as_str(),
|
||||
// ext_assoc.get_default(),
|
||||
// open_with_entry,
|
||||
// ]);
|
||||
// } else {
|
||||
// table.add_row(["", "", open_with_entry]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// table.add_row([ext.to_string().as_str(), "", ""]);
|
||||
// }
|
||||
// }
|
||||
// println!("{table}");
|
||||
|
||||
// let program = Program::new();
|
||||
// program.query()?;
|
||||
|
Reference in New Issue
Block a user