[system/kconfigeditor] /: Add commandline flag to check for schema completeness
Nicolas Fella <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit e6bf2e5bd9be833422f38b20b563b937db103d95 by Nicolas Fella.
Committed on 23/07/2026 at 11:32.
Pushed by nicolasfella into branch 'master'.
Add commandline flag to check for schema completeness
M +13 -0 .flatpak/generated-sources.json
M +13 -0 Cargo.lock
M +1 -0 Cargo.toml
M +62 -7 src/main.rs
https://invent.kde.org/system/kconfigeditor/-/commit/e6bf2e5bd9be833422f38b20b563b937db103d95
diff --git a/.flatpak/generated-sources.json b/.flatpak/generated-sources.json
index b8bda3d..8021ab9 100644
--- a/.flatpak/generated-sources.json
+++ b/.flatpak/generated-sources.json
@@ -285,6 +285,19 @@
"dest": "cargo/vendor/cxx-qt-lib-0.9.1",
"dest-filename": ".cargo-checksum.json"
},
+ {
+ "type": "archive",
+ "archive-type": "tar-gzip",
+ "url": "https://static.crates.io/crates/cxx-qt-lib-extras/cxx-qt-lib-extras-0.9.1.crate",
+ "sha256": "caecf40d614ac4cc448ac6baf462bf4c0d1d70c5a48d6b790e9e735c8d39ef97",
+ "dest": "cargo/vendor/cxx-qt-lib-extras-0.9.1"
+ },
+ {
+ "type": "inline",
+ "contents": "{\"package\": \"caecf40d614ac4cc448ac6baf462bf4c0d1d70c5a48d6b790e9e735c8d39ef97\", \"files\": {}}",
+ "dest": "cargo/vendor/cxx-qt-lib-extras-0.9.1",
+ "dest-filename": ".cargo-checksum.json"
+ },
{
"type": "archive",
"archive-type": "tar-gzip",
diff --git a/Cargo.lock b/Cargo.lock
index 46ae1a3..71b8c63 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -137,6 +137,7 @@ dependencies = [
"cxx-qt",
"cxx-qt-build",
"cxx-qt-lib",
+ "cxx-qt-lib-extras",
"gio 0.22.8",
"libflatpak",
"serde",
@@ -254,6 +255,18 @@ dependencies = [
"qt-build-utils",
]
+[[package]]
+name = "cxx-qt-lib-extras"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caecf40d614ac4cc448ac6baf462bf4c0d1d70c5a48d6b790e9e735c8d39ef97"
+dependencies = [
+ "cxx",
+ "cxx-qt",
+ "cxx-qt-build",
+ "cxx-qt-lib",
+]
+
[[package]]
name = "cxx-qt-macro"
version = "0.9.1"
diff --git a/Cargo.toml b/Cargo.toml
index 36436af..5e36296 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ edition = "2021"
cxx = "1.0.192"
cxx-qt = "0.9.1"
cxx-qt-lib = { version = "0.9.1", features = ["qt_full"]}
+cxx-qt-lib-extras = "0.9.1"
gio = "0.22.4"
libflatpak = "0.7.0"
serde = { version = "1.0.228", features = ["derive"] }
diff --git a/src/main.rs b/src/main.rs
index e514f5a..b8a1bb4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,17 +9,72 @@ mod groupsmodel;
mod qstandardpaths;
mod util;
-use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};
+use std::fs;
+
+use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QString, QStringList, QUrl};
+use cxx_qt_lib_extras::{QCommandLineOption, QCommandLineParser};
fn main() {
- let mut app = QGuiApplication::new();
- let mut engine = QQmlApplicationEngine::new();
+ let mut parser = QCommandLineParser::default();
+ let check_files_option = QCommandLineOption::from(&QString::from("check-files"));
+ parser.add_option(&check_files_option);
- if let Some(engine) = engine.as_mut() {
- engine.load(&QUrl::from("qrc:/qt/qml/org/kde/configeditor/qml/main.qml"));
+ // TODO put QGuiApplication::arguments() in cxx-qt
+ let mut args = QStringList::default();
+ for arg in std::env::args_os() {
+ args.append(QString::from(arg.into_string().unwrap()));
}
- if let Some(app) = app.as_mut() {
- app.exec();
+ let mut app = QGuiApplication::new();
+
+ parser.process(&args);
+
+ if parser.is_set(&QString::from("check-files")) {
+ let kcfg_files = util::find_kcfg_files(&QString::default());
+
+ let config_schemas: Vec<_> = kcfg_files
+ .iter()
+ .flat_map(|file| config::parse(&file.to_string()))
+ .collect();
+
+ let file_names_from_schemas: Vec<_> = config_schemas
+ .iter()
+ .flat_map(|config| config.kcfgfile.clone())
+ .flat_map(|cfg| cfg.name)
+ .collect();
+
+ let config_files = fs::read_dir(std::env::var("HOME").unwrap() + "/.config/").unwrap();
+
+ println!("The following files have no associated kcfg file:");
+
+ for config_file in config_files {
+ if config_file.as_ref().unwrap().file_type().unwrap().is_dir() {
+ continue;
+ }
+
+ if !file_names_from_schemas.contains(
+ &config_file
+ .as_ref()
+ .unwrap()
+ .file_name()
+ .into_string()
+ .unwrap(),
+ ) {
+ println!(
+ "{}",
+ &config_file.unwrap().file_name().into_string().unwrap()
+ );
+ }
+ }
+ } else {
+ let mut engine = QQmlApplicationEngine::new();
+
+ if let Some(engine) = engine.as_mut() {
+ engine.load(&QUrl::from("qrc:/qt/qml/org/kde/configeditor/qml/main.qml"));
+ }
+
+ if let Some(app) = app.as_mut() {
+ app.exec();
+ }
}
}