forked from Plugin-JF-Onkostar/osc-variant
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f456e278cb | |||
| f28ab1afcd | |||
| ae6b8d48e5 | |||
| 1302963b56 | |||
| 6be11a8951 | |||
| 416204b30a | |||
| 86e988c50e | |||
| 76de86b685 | |||
| d0de76770f | |||
| 8cae6ce706 | |||
| 81a0c6204b | |||
| 21e31f35d1 | |||
| 108aae329c | |||
| 1f51d3e994 | |||
| c514005182 | |||
| a127133ba2 | |||
| e2d4d71063 | |||
| 629cc8aba9 | |||
| 298a142586 | |||
| 9b9a0b4622 | |||
| 9ffc0783ff | |||
| 771d99fa27 | |||
| eadf9326d0 | |||
| bf63d93efa | |||
| ce52f92a7f | |||
| b3054f971e | |||
| e27d31a8bf | |||
| d30c2991c0 | |||
| ce8dca1c10 | |||
| bfa7cc3c6b | |||
| 9256e242eb | |||
| e33b1a3a4c | |||
| 42cbb9ce7e | |||
| 8edd50feb4 | |||
| 31eda3efc9 | |||
| 54cea88486 | |||
| 4040c49521 | |||
| e0b16c16d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.idea/*
|
||||
/target
|
||||
/completion
|
||||
|
||||
*.iml
|
||||
|
||||
280
Cargo.lock
generated
280
Cargo.lock
generated
@@ -3,37 +3,116 @@
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
name = "addr2line"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.4.1"
|
||||
version = "4.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27"
|
||||
checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.4.1"
|
||||
version = "4.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d"
|
||||
checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.4.0"
|
||||
name = "clap_complete"
|
||||
version = "4.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a"
|
||||
checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -60,6 +139,35 @@ dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "0.3.6"
|
||||
@@ -73,10 +181,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.0"
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
@@ -85,10 +209,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.0"
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@@ -108,39 +238,58 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.147"
|
||||
version = "0.2.148"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.6.2"
|
||||
version = "2.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e"
|
||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.18.0"
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "osc-variant"
|
||||
version = "0.3.0"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"console",
|
||||
"quick-xml",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"xml-rs",
|
||||
"sha256",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.66"
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -164,6 +313,12 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.15"
|
||||
@@ -204,10 +359,34 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.29"
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
|
||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha256"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7895c8ae88588ccead14ff438b939b0c569cd619116f14b4d13fdff7b8333386"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"hex",
|
||||
"sha2",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -215,16 +394,33 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.11"
|
||||
name = "tokio"
|
||||
version = "1.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||
checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
@@ -232,6 +428,12 @@ version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
@@ -297,9 +499,3 @@ name = "windows_x86_64_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
|
||||
|
||||
17
Cargo.toml
17
Cargo.toml
@@ -1,19 +1,25 @@
|
||||
[package]
|
||||
name = "osc-variant"
|
||||
version = "0.3.0"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
authors = ["Paul-Christian Volkmer <volkmer_p@ukw.de>"]
|
||||
description = "Anwendung zum Anpassen einer OSC-Datei an einen Standort"
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.3", features = ["std", "help", "usage", "derive", "error-context"], default-features = false }
|
||||
clap = { version = "4.4", features = ["std", "help", "usage", "derive", "error-context"], default-features = false }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_yaml = "0.9"
|
||||
quick-xml = { version = "0.30", features = ["escape-html", "serialize"], default-features = false }
|
||||
xml-rs = "0.8"
|
||||
console = "0.15"
|
||||
sha256 = "1.4"
|
||||
|
||||
[build-dependencies]
|
||||
clap = { version = "4.4", features = ["std", "help", "usage", "derive", "error-context"], default-features = false }
|
||||
clap_complete = "4.4"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
@@ -24,3 +30,8 @@ panic = "abort"
|
||||
|
||||
[package.metadata.deb]
|
||||
copyright = "Copyright (c) 2023 Comprehensive Cancer Center Mainfranken"
|
||||
extended-description = "Anwendung zum Anpassen einer OSC-Datei an einen Standort."
|
||||
assets = [
|
||||
["target/release/osc-variant", "usr/bin/", "755"],
|
||||
["completion/osc-variant.bash", "etc/bash_completion.d/", "644"]
|
||||
]
|
||||
|
||||
55
README.md
55
README.md
@@ -16,21 +16,51 @@ unvollständigen Ausgabedateien zu erzeugen.
|
||||
|
||||
### Beispiele
|
||||
|
||||
Die folgenden Unterbefehle sind verfügbar
|
||||
|
||||
#### `sha256sum`
|
||||
|
||||
Das Berechnen der SHA256 Prüfsumme ist mit dem Unterbefehl `sha256sum` auch unter Windows einfach möglich
|
||||
und erzeugt eine Ausgabe analog dem Befehl auf Linux-Systemen:
|
||||
|
||||
```
|
||||
osc-variant sha256sum meine-beispieldatei.osc
|
||||
```
|
||||
|
||||
#### `list`
|
||||
|
||||
Zum Auflisten der Inhalte einer Datei wird folgender Befehl verwendet:
|
||||
|
||||
```
|
||||
osc-variant list meine-beispieldatei.osc
|
||||
```
|
||||
|
||||
Zum Auflisten der Inhalte mit allen Abhängigkeiten, z.B. Daten- und Merkmalkataloge und bei Formularen wird der Befehl
|
||||
Mit der Option `--filter` kann die Ausgabe eingeschränkt werden.
|
||||
|
||||
#### `tree`
|
||||
|
||||
Zum Auflisten der Inhalte mit allen Abhängigkeiten, z.B. Daten- und Merkmalskataloge und bei Formularen wird der Befehl
|
||||
`tree` verwendet:
|
||||
|
||||
```
|
||||
osc-variant tree meine-beispieldatei.osc
|
||||
```
|
||||
|
||||
Abhängigkeiten werden je nach Art gekennzeichnet:
|
||||
|
||||
* `+`: Datenkatalog
|
||||
* `-`: Merkmalskatalog
|
||||
* `>`: Formularverweis
|
||||
* `*`: Unterformular
|
||||
|
||||
Für Formularverweise und Unterformulare werden dabei die verwendeten Datenkataloge nicht erneut ausgegeben.
|
||||
|
||||
Achtung! Dies erzeugt eine sehr umfangreiche Ausgabe.
|
||||
|
||||
Mit der Option `--filter` kann auch hier die Ausgabe eingeschränkt werden.
|
||||
|
||||
#### `diff`
|
||||
|
||||
Zum Vergleich zweier OSC-Dateien wird der Unterbefehl `diff` verwendet.
|
||||
Der optionale Parameter `--strict` vergleicht auch den Inhalt der OSC-Datei.
|
||||
Ohne diesen wird nur das Vorhandensein von Inhalten und die Revision verglichen.
|
||||
@@ -45,6 +75,8 @@ bzw.
|
||||
osc-variant diff meine-beispieldatei.osc andere-beispieldatei.osc --strict
|
||||
```
|
||||
|
||||
#### `modify`
|
||||
|
||||
Zum Anpassen des Inhalts einer Datei:
|
||||
|
||||
```
|
||||
@@ -62,25 +94,28 @@ Ohne eine Angabe der Ausgabedatei wird auf die Standardausgabe ausgegeben.
|
||||
OSC-Dateien sind XML-Dateien. Diese Anwendung ermöglicht optional die Ausgabe als kompaktere XML-Datei ohne Zeilenumbrüche.
|
||||
Hierzu ist die Option `--compact` vorgesehen. Es können, je nach Datei, bis zu 30% eingespart werden.
|
||||
|
||||
#### Filter
|
||||
|
||||
Bei der Auflistung von Inhalten ist es möglich, die Anzeige für die Unterbefehle `list` und `tree` anhand des Namens zu filtern.
|
||||
Hierzu ist die Option `--filter=` vorgesehen.
|
||||
Wird diese angewendet, werden nur Inhalte angezeigt, deren Name die angegebene Zeichenkette beinhalten.
|
||||
|
||||
#### Sortierung
|
||||
|
||||
Bei der Auflistung der Inhalte, kann die Option `--sorted` dazu verwendet werden, die angezeigten Einträge alphabetisch zu sortieren.
|
||||
Die Sortierung erfolgt dabei nach Namen des Katalogs oder des Formulars.
|
||||
|
||||
#### Experimentelle Funktionen
|
||||
Beim Modifizieren der Inhalte kann ebenfalls die Option `--sorted` dazu verwendet werden, die Einträge im Anschluss an die Modifikation
|
||||
nach Namen und für Formulare der Abhängigkeit von Formularverweisen und Unterformularen zu sortieren.
|
||||
|
||||
Neben den gebräuchlichen Funktionen gibt es weitere, derzeit noch experimentelle, Funktionen.
|
||||
Formulare, die von anderen Formularen in einem Formularverweis oder als Unterformular verwendet werden, werden dabei weiter oben angeordnet,
|
||||
da Onkostar einen Formularimport sequenziell, ohne Berücksichtigung von Abhängigkeiten, durchführt.
|
||||
|
||||
##### Sortierung bei Modifikation
|
||||
|
||||
Beim Modifizieren der Inhalte kann die experimentelle Option `--x-sorted` dazu verwendet werden, die Einträge im Anschluss an die Modifikation
|
||||
nach Namen zu sortieren.
|
||||
Dies erlaubt eine konsistente Reihenfolge der Einträge, wodurch ein direkter Vergleich mit Vorversionen ermöglicht wird.
|
||||
ACHTUNG: Es kann sein, dass dadurch ein Import der resultierenden OSC-Datei nicht mehr möglich ist, da das genaue Verhalten des Imports aktuell noch nicht bekannt ist.
|
||||
|
||||
##### Entfernen von Inhalten der Systembibliothek bei Modifikation
|
||||
|
||||
Mit der die experimentelle Option `--x-strip` ist es möglich, die in der OSC-Datei enthaltenen und beim Import nicht genutzten Inhalte aus der Systembibliothek zu entfernen.
|
||||
Mit der die experimentelle Option `--strip` ist es möglich, die in der OSC-Datei enthaltenen und beim Import nicht genutzten Inhalte aus der Systembibliothek zu entfernen.
|
||||
|
||||
Hierbei werden alle Inhalte entfernt, die im Ordner "ONKOSTAR Bibliothek" enthalten sind, beim Import jedoch ignoriert werden.
|
||||
|
||||
@@ -137,4 +172,4 @@ Wird sie angeben, sind die Felder `name`, `position` und `column` verpflichtend.
|
||||
Es können beliebig viele Formulare mit beliebig vielen Änderungen zu Formularverweisen in einer Profildatei
|
||||
hinterlegt werden, jedoch ist mindestens eine Angabe zu einem Formularfeld erforderlich.
|
||||
|
||||
Beispiele für eine Profildatei sind unter [`examples/`](examples/) zu finden.
|
||||
Beispiele für eine Profildatei sind unter [`examples/`](/examples) zu finden.
|
||||
|
||||
44
build.rs
Normal file
44
build.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2023 Comprehensive Cancer Center Mainfranken
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use std::fs;
|
||||
use std::io::Error;
|
||||
|
||||
use clap_complete::generate_to;
|
||||
use clap_complete::Shell::Bash;
|
||||
|
||||
include!("src/cli.rs");
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let mut cmd = build_cli();
|
||||
|
||||
let package_name = std::env::var("CARGO_CRATE_NAME").unwrap_or("osc-variant".to_string());
|
||||
|
||||
fs::remove_dir_all("completion").unwrap_or_default();
|
||||
fs::create_dir("completion")?;
|
||||
|
||||
generate_to(Bash, &mut cmd, package_name.as_str(), "completion")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
27
examples/dnpm-master.yml
Normal file
27
examples/dnpm-master.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
forms:
|
||||
- name: 'DNPM Klinik/Anamnese'
|
||||
form_references:
|
||||
- name: MTB
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
- name: 'DNPM Therapieplan'
|
||||
form_references:
|
||||
- name: referstemtb
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
- name: reftkhumangenber
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
- name: reftkreevaluation
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
- name: 'DNPM UF Einzelempfehlung'
|
||||
form_references:
|
||||
- name: mtb
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
- name: 'DNPM UF Rebiopsie'
|
||||
form_references:
|
||||
- name: reftumorkonferenz
|
||||
referenced_data_form: 'OS.Tumorkonferenz'
|
||||
anzeige_auswahl: 'MTB vom {Datum}'
|
||||
@@ -4,6 +4,9 @@ forms:
|
||||
- name: MTB
|
||||
referenced_data_form: 'MR.MTB_Anmeldung'
|
||||
anzeige_auswahl: 'MTB Anmeldung vom {Anmeldedatum}'
|
||||
scripts_code: |
|
||||
setFieldValue('AnmeldedatumMTB', getFieldValue('MTB').MTBTermin);
|
||||
setFieldValue('WHOGrad', getFieldValue('MTB').WHOGrad);
|
||||
- name: 'DNPM Therapieplan'
|
||||
form_references:
|
||||
- name: referstemtb
|
||||
|
||||
30
src/cli.rs
30
src/cli.rs
@@ -22,18 +22,28 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use clap::{Command, CommandFactory, Parser, Subcommand};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn build_cli() -> Command {
|
||||
Cli::command()
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
#[command(propagate_version = true, arg_required_else_help(true))]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
pub cmd: SubCommand,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Command {
|
||||
pub enum SubCommand {
|
||||
#[command(
|
||||
name = "sha256sum",
|
||||
about = "Berechne SHA256 Prüfsumme für die angegebene Datei"
|
||||
)]
|
||||
Sha256Sum { inputfile: String },
|
||||
#[command(about = "Zeigt alle enthaltenen Kataloge und Formulare mit Revision an.")]
|
||||
List {
|
||||
inputfile: String,
|
||||
@@ -42,6 +52,8 @@ pub enum Command {
|
||||
help = "Sortiere Kataloge und Formulare nach Name (Optional)"
|
||||
)]
|
||||
sorted: bool,
|
||||
#[arg(long = "filter", help = "Filtere Ausgabe nach Name (Optional)")]
|
||||
filter: Option<String>,
|
||||
},
|
||||
#[command(about = "Zeigt Kataloge und Formulare mit Revision und Abhängigkeiten an.")]
|
||||
Tree {
|
||||
@@ -51,6 +63,8 @@ pub enum Command {
|
||||
help = "Sortiere Kataloge und Formulare nach Name (Optional)"
|
||||
)]
|
||||
sorted: bool,
|
||||
#[arg(long = "filter", help = "Filtere Ausgabe nach Name (Optional)")]
|
||||
filter: Option<String>,
|
||||
},
|
||||
#[command(about = "Modifiziert die angegebene Datei anhand der Profildatei")]
|
||||
Modify {
|
||||
@@ -62,13 +76,15 @@ pub enum Command {
|
||||
#[arg(long = "compact", help = "Kompakte Ausgabe, ohne Einrücken (Optional)")]
|
||||
compact: bool,
|
||||
#[arg(
|
||||
long = "x-sorted",
|
||||
help = "EXPERIMENTELL: Sortiere Kataloge und Formulare nach Name (Optional).\nKann negative Auswirkungen auf den ordnungsgemäßen Import haben."
|
||||
long = "sorted",
|
||||
alias = "x-sorted",
|
||||
help = "Sortiere Kataloge und Formulare nach Name (Optional)."
|
||||
)]
|
||||
sorted: bool,
|
||||
#[arg(
|
||||
long = "x-strip",
|
||||
help = "EXPERIMENTELL: Entferne Einträge aus der Systembibliothek die nicht importiert werden (Optional).\nKann negative Auswirkungen auf den ordnungsgemäßen Import haben."
|
||||
long = "strip",
|
||||
alias = "x-strip",
|
||||
help = "Entferne Einträge aus der Systembibliothek die nicht importiert werden (Optional)."
|
||||
)]
|
||||
strip: bool,
|
||||
},
|
||||
|
||||
48
src/main.rs
48
src/main.rs
@@ -28,14 +28,16 @@ use std::fs;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::ops::Add;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::Parser;
|
||||
use console::style;
|
||||
use quick_xml::se::Serializer;
|
||||
use serde::Serialize;
|
||||
use sha256::digest;
|
||||
|
||||
use crate::cli::{Cli, Command};
|
||||
use crate::cli::{Cli, SubCommand};
|
||||
use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::profile::Profile;
|
||||
|
||||
@@ -109,22 +111,38 @@ fn read_profile(filename: String) -> Result<Profile, FileError> {
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
match cli.command {
|
||||
Command::List { inputfile, sorted } => {
|
||||
match cli.cmd {
|
||||
SubCommand::List {
|
||||
inputfile,
|
||||
sorted,
|
||||
filter,
|
||||
} => {
|
||||
let mut data = read_inputfile(inputfile)?;
|
||||
if sorted {
|
||||
data.sorted()
|
||||
}
|
||||
if let Some(name) = filter {
|
||||
OnkostarEditor::print_list_filtered(&mut data, name.as_str());
|
||||
return Ok(());
|
||||
}
|
||||
data.print_list();
|
||||
}
|
||||
Command::Tree { inputfile, sorted } => {
|
||||
SubCommand::Tree {
|
||||
inputfile,
|
||||
sorted,
|
||||
filter,
|
||||
} => {
|
||||
let mut data = read_inputfile(inputfile)?;
|
||||
if sorted {
|
||||
data.sorted()
|
||||
}
|
||||
if let Some(name) = filter {
|
||||
OnkostarEditor::print_tree_filtered(&mut data, name.as_str());
|
||||
return Ok(());
|
||||
}
|
||||
OnkostarEditor::print_tree(&data);
|
||||
}
|
||||
Command::Modify {
|
||||
SubCommand::Modify {
|
||||
inputfile,
|
||||
profile,
|
||||
outputfile,
|
||||
@@ -175,7 +193,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::Diff {
|
||||
SubCommand::Diff {
|
||||
inputfile_a,
|
||||
inputfile_b,
|
||||
strict,
|
||||
@@ -191,6 +209,24 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
data_a.print_diff(data_b, strict);
|
||||
}
|
||||
SubCommand::Sha256Sum { inputfile } => {
|
||||
match fs::read_to_string(inputfile.clone()) {
|
||||
Ok(content) => {
|
||||
println!(
|
||||
"{} {}",
|
||||
digest(content).as_str(),
|
||||
PathBuf::from(inputfile.clone())
|
||||
.canonicalize()
|
||||
.unwrap_or_default()
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("{}", FileError::Reading(inputfile, err.to_string()));
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -102,7 +102,8 @@ impl Comparable for DataCatalogue {
|
||||
|
||||
impl Requires for DataCatalogue {
|
||||
fn get_required_entries<'a>(&'a self, all: &'a OnkostarEditor) -> Vec<Requirement> {
|
||||
self.entries
|
||||
let mut result = self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|&entry| entry.property_catalogue.is_some())
|
||||
@@ -116,7 +117,10 @@ impl Requires for DataCatalogue {
|
||||
Some(contained) => Requirement::PropertyCatalogue(contained),
|
||||
None => Requirement::ExternalPropertyCatalogue(entry),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.collect::<Vec<_>>();
|
||||
result.sort_unstable_by_key(|item| item.sorting_key());
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
|
||||
@@ -127,10 +131,10 @@ impl Requires for DataCatalogue {
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
Requirement::PropertyCatalogue(_) => {
|
||||
Some(format!(" + {}\n", entry.to_string()))
|
||||
Some(format!(" - {}\n", entry.to_string()))
|
||||
}
|
||||
Requirement::ExternalPropertyCatalogue(_) => {
|
||||
Some(format!(" + {}\n", entry.to_string()))
|
||||
Some(format!(" - {}\n", entry.to_string()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use console::style;
|
||||
@@ -192,13 +193,25 @@ impl FormEntryContainer for DataForm {
|
||||
impl Listable for DataForm {
|
||||
fn to_listed_string(&self) -> String {
|
||||
format!(
|
||||
"Formular ({}) '{}' in Revision '{}'",
|
||||
"Formular ({}) '{}' in Revision '{}' {}",
|
||||
match self.is_system_library_content() {
|
||||
true => style("S").yellow(),
|
||||
_ => style("u"),
|
||||
},
|
||||
style(&self.name).yellow(),
|
||||
style(&self.revision).yellow()
|
||||
style(&self.revision).yellow(),
|
||||
if self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|entry| entry.procedure_date_status != "none")
|
||||
.count()
|
||||
== 0
|
||||
{
|
||||
style("Formular hat keine Angabe zum Prozedurdatum!").red()
|
||||
} else {
|
||||
style("")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -240,11 +253,57 @@ impl Comparable for DataForm {
|
||||
fn get_revision(&self) -> u16 {
|
||||
self.revision
|
||||
}
|
||||
|
||||
fn compare_by_requirement(a: &Self, b: &Self) -> Ordering {
|
||||
if a.get_name() == b.get_name()
|
||||
|| a.is_system_library_content()
|
||||
|| b.is_system_library_content()
|
||||
{
|
||||
return Ordering::Equal;
|
||||
}
|
||||
|
||||
if a.requires_form_reference(&b.get_name()) || a.requires_subform(&b.get_name()) {
|
||||
return Ordering::Greater;
|
||||
}
|
||||
|
||||
Ordering::Less
|
||||
}
|
||||
}
|
||||
|
||||
impl Requires for DataForm {
|
||||
fn requires_form_reference(&self, name: &str) -> bool {
|
||||
self.entries
|
||||
.entry
|
||||
.iter()
|
||||
.map(|item| {
|
||||
item.type_ == "formReference"
|
||||
&& match item.referenced_data_form.as_ref() {
|
||||
Some(refname) => refname == name,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
.filter(|&it| it)
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
fn requires_subform(&self, name: &str) -> bool {
|
||||
self.entries
|
||||
.entry
|
||||
.iter()
|
||||
.map(|item| {
|
||||
item.type_ == "subform"
|
||||
&& match item.referenced_data_form.as_ref() {
|
||||
Some(refname) => refname == name,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
.filter(|&it| it)
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
fn get_required_entries<'a>(&'a self, all: &'a OnkostarEditor) -> Vec<Requirement> {
|
||||
self.data_catalogues
|
||||
let mut result = self
|
||||
.data_catalogues
|
||||
.data_catalogue
|
||||
.iter()
|
||||
.collect::<HashSet<_>>()
|
||||
@@ -253,49 +312,54 @@ impl Requires for DataForm {
|
||||
Some(contained) => Requirement::DataCatalogue(contained),
|
||||
None => Requirement::ExternalDataCatalogue(entry.to_string()),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
.collect::<Vec<_>>();
|
||||
result.sort_unstable_by_key(|item| item.sorting_key());
|
||||
|
||||
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
|
||||
format!(
|
||||
"{}\n{}",
|
||||
self.to_listed_string(),
|
||||
self.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
Requirement::DataCatalogue(x) => {
|
||||
let inner = x
|
||||
.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|inner_entry| match inner_entry {
|
||||
Requirement::PropertyCatalogue(y) => Some(y.to_listed_string()),
|
||||
Requirement::ExternalPropertyCatalogue(name) => Some(format!(
|
||||
"Merkmalskatalog (-) '{}' - hier nicht enthalten",
|
||||
style(name).yellow()
|
||||
)),
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.map(|item| format!(" - {}\n", item.unwrap()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
let referenced_forms = &mut self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|&entry| entry.get_type() == "formReference")
|
||||
.filter_map(|entry| match &entry.referenced_data_form {
|
||||
Some(name) => Some(name),
|
||||
None => None,
|
||||
})
|
||||
.collect::<HashSet<_>>()
|
||||
.into_iter()
|
||||
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||
Some(contained) => Requirement::DataFormReference(contained),
|
||||
None => match all.find_unterformular(entry.as_str()) {
|
||||
Some(contained) => Requirement::UnterformularReference(contained),
|
||||
None => Requirement::ExternalUnterformularReference(entry.to_string()),
|
||||
},
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
referenced_forms.sort_unstable_by_key(|item| item.sorting_key());
|
||||
result.append(referenced_forms);
|
||||
|
||||
if inner.is_empty() {
|
||||
Some(format!(" + {}\n", x.to_listed_string()))
|
||||
} else {
|
||||
Some(format!(" + {}\n{}", x.to_listed_string(), inner))
|
||||
}
|
||||
}
|
||||
Requirement::ExternalDataCatalogue(_) => {
|
||||
Some(format!(" + {}\n", entry.to_string()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.flatten()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
)
|
||||
let sub_forms = &mut self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|&entry| entry.get_type() == "subform")
|
||||
.filter_map(|entry| match &entry.referenced_data_form {
|
||||
Some(name) => Some(name),
|
||||
None => None,
|
||||
})
|
||||
.collect::<HashSet<_>>()
|
||||
.into_iter()
|
||||
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||
Some(contained) => Requirement::DataFormSubform(contained),
|
||||
None => match all.find_unterformular(entry.as_str()) {
|
||||
Some(contained) => Requirement::UnterformularSubform(contained),
|
||||
None => Requirement::ExternalUnterformularSubform(entry.to_string()),
|
||||
},
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
sub_forms.sort_unstable_by_key(|item| item.sorting_key());
|
||||
result.append(sub_forms);
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,6 +550,9 @@ pub struct Entry {
|
||||
direction_pat_modul: String,
|
||||
#[serde(rename = "SeitenumbruchPatModul")]
|
||||
seitenumbruch_pat_modul: bool,
|
||||
#[serde(rename = "Kontaktliste")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
kontaktliste: Option<String>,
|
||||
#[serde(rename = "MarkierungIgnorieren")]
|
||||
markierung_ignorieren: bool,
|
||||
#[serde(rename = "SucheArt")]
|
||||
|
||||
@@ -22,10 +22,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use crate::model::requirements::Requires;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::profile::{FormField, FormReference, Profile};
|
||||
@@ -251,6 +253,7 @@ pub trait Listable {
|
||||
|
||||
pub trait Sortable {
|
||||
fn sorting_key(&self) -> String;
|
||||
|
||||
fn sorted(&mut self) -> &Self
|
||||
where
|
||||
Self: Sized,
|
||||
@@ -267,6 +270,12 @@ pub trait Comparable: Debug {
|
||||
format!("{:?}", self).hash(&mut h);
|
||||
h.finish().to_string()
|
||||
}
|
||||
fn compare_by_requirement(_: &Self, _: &Self) -> Ordering
|
||||
where
|
||||
Self: Requires,
|
||||
{
|
||||
Ordering::Equal
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FormEntry {
|
||||
|
||||
@@ -74,6 +74,32 @@ impl OnkostarEditor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_data_form<'a>(&'a self, name: &str) -> Option<&'a DataForm> {
|
||||
match self
|
||||
.editor
|
||||
.data_form
|
||||
.iter()
|
||||
.filter(|&item| item.get_name().eq_ignore_ascii_case(name))
|
||||
.nth(0)
|
||||
{
|
||||
Some(x) => Some(x),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_unterformular<'a>(&'a self, name: &str) -> Option<&'a Unterformular> {
|
||||
match self
|
||||
.editor
|
||||
.unterformular
|
||||
.iter()
|
||||
.filter(|&item| item.get_name().eq_ignore_ascii_case(name))
|
||||
.nth(0)
|
||||
{
|
||||
Some(x) => Some(x),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_profile(&mut self, profile: &Profile) {
|
||||
self.editor
|
||||
.data_form
|
||||
@@ -104,6 +130,37 @@ impl OnkostarEditor {
|
||||
Self::print_items("Unterformulare", &self.editor.unterformular);
|
||||
}
|
||||
|
||||
fn filter_by_name_contains(&mut self, name: &str) {
|
||||
self.editor
|
||||
.property_catalogue
|
||||
.retain(|e| e.get_name().contains(name));
|
||||
self.editor
|
||||
.data_catalogue
|
||||
.retain(|e| e.get_name().contains(name));
|
||||
self.editor
|
||||
.data_form
|
||||
.retain(|e| e.get_name().contains(name));
|
||||
self.editor
|
||||
.unterformular
|
||||
.retain(|e| e.get_name().contains(name));
|
||||
}
|
||||
pub fn print_list_filtered(&mut self, name: &str) {
|
||||
println!(
|
||||
"Die Datei wurde am {} mit {} in Version {} erstellt.\n\nFolgende Inhalte für '{}' sind gespeichert",
|
||||
style(&self.info_xml.datum_xml).yellow(),
|
||||
style(&self.info_xml.name).yellow(),
|
||||
style(&self.info_xml.version).yellow(),
|
||||
name
|
||||
);
|
||||
|
||||
self.filter_by_name_contains(name);
|
||||
|
||||
Self::print_items("Merkmalskataloge", &self.editor.property_catalogue);
|
||||
Self::print_items("Datenkataloge", &self.editor.data_catalogue);
|
||||
Self::print_items("Formulare", &self.editor.data_form);
|
||||
Self::print_items("Unterformulare", &self.editor.unterformular);
|
||||
}
|
||||
|
||||
fn print_items(title: &str, list: &[impl Listable]) {
|
||||
print!("\n{} {}", list.len(), style(title).underlined());
|
||||
println!(
|
||||
@@ -128,6 +185,23 @@ impl OnkostarEditor {
|
||||
self.print_items_tree("Unterformulare", &self.editor.unterformular);
|
||||
}
|
||||
|
||||
pub fn print_tree_filtered(&mut self, name: &str) {
|
||||
println!(
|
||||
"Die Datei wurde am {} mit {} in Version {} erstellt.\n\nFolgende Inhalte für '{}' sind gespeichert",
|
||||
style(&self.info_xml.datum_xml).yellow(),
|
||||
style(&self.info_xml.name).yellow(),
|
||||
style(&self.info_xml.version).yellow(),
|
||||
name
|
||||
);
|
||||
|
||||
self.filter_by_name_contains(name);
|
||||
|
||||
Self::print_items("Merkmalskataloge", &self.editor.property_catalogue);
|
||||
self.print_items_tree("Datenkataloge", &self.editor.data_catalogue);
|
||||
self.print_items_tree("Formulare", &self.editor.data_form);
|
||||
self.print_items_tree("Unterformulare", &self.editor.unterformular);
|
||||
}
|
||||
|
||||
fn print_items_tree(&self, title: &str, list: &[impl Requires]) {
|
||||
print!("\n{} {}", list.len(), style(title).underlined());
|
||||
println!(
|
||||
@@ -155,17 +229,25 @@ impl OnkostarEditor {
|
||||
item.sorted();
|
||||
});
|
||||
|
||||
/*self.editor
|
||||
.data_form
|
||||
.sort_unstable_by_key(|e| e.sorting_key());*/
|
||||
|
||||
self.editor
|
||||
.data_form
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
.sort_unstable_by(DataForm::compare_by_requirement);
|
||||
|
||||
self.editor.data_form.iter_mut().for_each(|item| {
|
||||
item.sorted();
|
||||
});
|
||||
|
||||
/*self.editor
|
||||
.unterformular
|
||||
.sort_unstable_by_key(|e| e.sorting_key());*/
|
||||
|
||||
self.editor
|
||||
.unterformular
|
||||
.sort_unstable_by_key(|e| e.sorting_key());
|
||||
.sort_unstable_by(Unterformular::compare_by_requirement);
|
||||
|
||||
self.editor.unterformular.iter_mut().for_each(|item| {
|
||||
item.sorted();
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
*/
|
||||
|
||||
use crate::model::data_catalogue::DataCatalogue;
|
||||
use crate::model::data_form::DataForm;
|
||||
use crate::model::onkostar_editor::OnkostarEditor;
|
||||
use crate::model::property_catalogue::PropertyCatalogue;
|
||||
use crate::model::Listable;
|
||||
use crate::model::unterformular::Unterformular;
|
||||
use crate::model::{Comparable, Listable, Sortable};
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum Requirement<'a> {
|
||||
@@ -33,6 +35,36 @@ pub enum Requirement<'a> {
|
||||
DataCatalogue(&'a DataCatalogue),
|
||||
ExternalPropertyCatalogue(String),
|
||||
ExternalDataCatalogue(String),
|
||||
DataFormReference(&'a DataForm),
|
||||
UnterformularReference(&'a Unterformular),
|
||||
#[allow(dead_code)]
|
||||
ExternalDataFormReference(String),
|
||||
ExternalUnterformularReference(String),
|
||||
|
||||
DataFormSubform(&'a DataForm),
|
||||
UnterformularSubform(&'a Unterformular),
|
||||
#[allow(dead_code)]
|
||||
ExternalDataFormSubform(String),
|
||||
ExternalUnterformularSubform(String),
|
||||
}
|
||||
|
||||
impl Sortable for Requirement<'_> {
|
||||
fn sorting_key(&self) -> String {
|
||||
match self {
|
||||
Requirement::PropertyCatalogue(item) => item.get_name(),
|
||||
Requirement::DataCatalogue(item) => item.get_name(),
|
||||
Requirement::DataFormReference(item) => item.get_name(),
|
||||
Requirement::UnterformularReference(item) => item.get_name(),
|
||||
Requirement::DataFormSubform(item) => item.get_name(),
|
||||
Requirement::UnterformularSubform(item) => item.get_name(),
|
||||
Requirement::ExternalPropertyCatalogue(name)
|
||||
| Requirement::ExternalDataCatalogue(name)
|
||||
| Requirement::ExternalDataFormReference(name)
|
||||
| Requirement::ExternalDataFormSubform(name)
|
||||
| Requirement::ExternalUnterformularReference(name)
|
||||
| Requirement::ExternalUnterformularSubform(name) => name.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for Requirement<'_> {
|
||||
@@ -40,18 +72,92 @@ impl ToString for Requirement<'_> {
|
||||
match self {
|
||||
Requirement::PropertyCatalogue(item) => item.to_listed_string(),
|
||||
Requirement::DataCatalogue(item) => item.to_listed_string(),
|
||||
Requirement::DataFormReference(item) => item.to_listed_string(),
|
||||
Requirement::UnterformularReference(item) => item.to_listed_string(),
|
||||
Requirement::DataFormSubform(item) => item.to_listed_string(),
|
||||
Requirement::UnterformularSubform(item) => item.to_listed_string(),
|
||||
Requirement::ExternalPropertyCatalogue(name) => {
|
||||
format!("Merkmalskatalog (-) '{}' - hier nicht enthalten", name)
|
||||
}
|
||||
Requirement::ExternalDataCatalogue(name) => {
|
||||
format!("Datenkatalog (-) '{}' - hier nicht enthalten", name)
|
||||
}
|
||||
Requirement::ExternalDataFormReference(name)
|
||||
| Requirement::ExternalDataFormSubform(name) => {
|
||||
format!("Formular (-) '{}' - hier nicht enthalten", name)
|
||||
}
|
||||
Requirement::ExternalUnterformularReference(name)
|
||||
| Requirement::ExternalUnterformularSubform(name) => {
|
||||
format!("Unterformular (-) '{}' - hier nicht enthalten", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Requires {
|
||||
pub trait Requires
|
||||
where
|
||||
Self: Listable,
|
||||
{
|
||||
fn requires_form_reference(&self, _: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn requires_subform(&self, _: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn get_required_entries<'a>(&'a self, all: &'a OnkostarEditor) -> Vec<Requirement>;
|
||||
|
||||
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String;
|
||||
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
|
||||
format!(
|
||||
"{}\n{}",
|
||||
self.to_listed_string(),
|
||||
self.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
Requirement::DataCatalogue(x) => {
|
||||
let inner = x
|
||||
.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|inner_entry| match inner_entry {
|
||||
Requirement::PropertyCatalogue(_) => Some(inner_entry.to_string()),
|
||||
Requirement::ExternalPropertyCatalogue(_) => {
|
||||
Some(inner_entry.to_string())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.map(|item| format!(" - {}\n", item.unwrap()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
|
||||
if inner.is_empty() {
|
||||
Some(format!(" + {}\n", x.to_listed_string()))
|
||||
} else {
|
||||
Some(format!(" + {}\n{}", x.to_listed_string(), inner))
|
||||
}
|
||||
}
|
||||
Requirement::ExternalDataCatalogue(_) => {
|
||||
Some(format!(" + {}\n", entry.to_string()))
|
||||
}
|
||||
Requirement::DataFormReference(_)
|
||||
| Requirement::ExternalDataFormReference(_)
|
||||
| Requirement::UnterformularReference(_)
|
||||
| Requirement::ExternalUnterformularReference(_) => {
|
||||
Some(format!(" > {}\n", entry.to_string()))
|
||||
}
|
||||
Requirement::DataFormSubform(_)
|
||||
| Requirement::ExternalDataFormSubform(_)
|
||||
| Requirement::UnterformularSubform(_)
|
||||
| Requirement::ExternalUnterformularSubform(_) => {
|
||||
Some(format!(" * {}\n", entry.to_string()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.flatten()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use console::style;
|
||||
@@ -202,26 +203,19 @@ impl FormEntryContainer for Unterformular {
|
||||
|
||||
impl Listable for Unterformular {
|
||||
fn to_listed_string(&self) -> String {
|
||||
if self.hat_unterformulare {
|
||||
return format!(
|
||||
"Unterformular ({}) '{}' in Revision '{}' {}",
|
||||
match self.is_system_library_content() {
|
||||
true => style("S").yellow(),
|
||||
_ => style("u"),
|
||||
},
|
||||
style(&self.name).yellow(),
|
||||
style(&self.revision).yellow(),
|
||||
style("Unterformular mit Markierung 'hat Unterformulare'!").red()
|
||||
);
|
||||
}
|
||||
format!(
|
||||
"Unterformular ({}) '{}' in Revision '{}'",
|
||||
"Unterformular ({}) '{}' in Revision '{}' {}",
|
||||
match self.is_system_library_content() {
|
||||
true => style("S").yellow(),
|
||||
_ => style("u"),
|
||||
},
|
||||
style(&self.name).yellow(),
|
||||
style(&self.revision).yellow()
|
||||
style(&self.revision).yellow(),
|
||||
if self.hat_unterformulare {
|
||||
style("Unterformular mit Markierung 'hat Unterformulare'!").red()
|
||||
} else {
|
||||
style("")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -263,11 +257,58 @@ impl Comparable for Unterformular {
|
||||
fn get_revision(&self) -> u16 {
|
||||
self.revision
|
||||
}
|
||||
|
||||
fn compare_by_requirement(a: &Self, b: &Self) -> Ordering {
|
||||
if a.get_name() == b.get_name()
|
||||
|| a.is_system_library_content()
|
||||
|| b.is_system_library_content()
|
||||
{
|
||||
return Ordering::Equal;
|
||||
}
|
||||
|
||||
if a.requires_form_reference(&b.get_name()) || a.requires_subform(&b.get_name()) {
|
||||
return Ordering::Greater;
|
||||
}
|
||||
|
||||
Ordering::Less
|
||||
}
|
||||
}
|
||||
|
||||
impl Requires for Unterformular {
|
||||
fn requires_form_reference(&self, name: &str) -> bool {
|
||||
self.entries
|
||||
.entry
|
||||
.iter()
|
||||
.map(|item| {
|
||||
item.type_ == "formReference"
|
||||
&& match item.referenced_data_form.as_ref() {
|
||||
Some(refname) => refname == name,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
.filter(|&it| it)
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
fn requires_subform(&self, name: &str) -> bool {
|
||||
self.entries
|
||||
.entry
|
||||
.iter()
|
||||
.map(|item| {
|
||||
item.type_ == "subform"
|
||||
&& match item.referenced_data_form.as_ref() {
|
||||
Some(refname) => refname == name,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
.filter(|&it| it)
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn get_required_entries<'a>(&'a self, all: &'a OnkostarEditor) -> Vec<Requirement> {
|
||||
self.data_catalogues
|
||||
let mut result = self
|
||||
.data_catalogues
|
||||
.data_catalogue
|
||||
.iter()
|
||||
.collect::<HashSet<_>>()
|
||||
@@ -276,48 +317,54 @@ impl Requires for Unterformular {
|
||||
Some(contained) => Requirement::DataCatalogue(contained),
|
||||
None => Requirement::ExternalDataCatalogue(entry.to_string()),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
.collect::<Vec<_>>();
|
||||
result.sort_unstable_by_key(|item| item.sorting_key());
|
||||
|
||||
fn to_requirement_string<'a>(&'a self, all: &'a OnkostarEditor) -> String {
|
||||
format!(
|
||||
"{}\n{}",
|
||||
self.to_listed_string(),
|
||||
self.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|entry| match entry {
|
||||
Requirement::DataCatalogue(x) => {
|
||||
let inner = x
|
||||
.get_required_entries(all)
|
||||
.iter()
|
||||
.map(|inner_entry| match inner_entry {
|
||||
Requirement::PropertyCatalogue(_) => Some(inner_entry.to_string()),
|
||||
Requirement::ExternalPropertyCatalogue(_) => {
|
||||
Some(inner_entry.to_string())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.map(|item| format!(" - {}\n", item.unwrap()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
let referenced_forms = &mut self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|&entry| entry.get_type() == "formReference")
|
||||
.filter_map(|entry| match &entry.referenced_data_form {
|
||||
Some(name) => Some(name),
|
||||
None => None,
|
||||
})
|
||||
.collect::<HashSet<_>>()
|
||||
.into_iter()
|
||||
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||
Some(contained) => Requirement::DataFormReference(contained),
|
||||
None => match all.find_unterformular(entry.as_str()) {
|
||||
Some(contained) => Requirement::UnterformularReference(contained),
|
||||
None => Requirement::ExternalUnterformularReference(entry.to_string()),
|
||||
},
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
referenced_forms.sort_unstable_by_key(|item| item.sorting_key());
|
||||
result.append(referenced_forms);
|
||||
|
||||
if inner.is_empty() {
|
||||
Some(format!(" + {}\n", x.to_listed_string()))
|
||||
} else {
|
||||
Some(format!(" + {}\n{}", x.to_listed_string(), inner))
|
||||
}
|
||||
}
|
||||
Requirement::ExternalDataCatalogue(_) => {
|
||||
Some(format!(" + {}\n", entry.to_string()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.filter(Option::is_some)
|
||||
.flatten()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
)
|
||||
let sub_forms = &mut self
|
||||
.entries
|
||||
.entry
|
||||
.iter()
|
||||
.filter(|&entry| entry.get_type() == "subform")
|
||||
.filter_map(|entry| match &entry.referenced_data_form {
|
||||
Some(name) => Some(name),
|
||||
None => None,
|
||||
})
|
||||
.collect::<HashSet<_>>()
|
||||
.into_iter()
|
||||
.map(|entry| match all.find_data_form(entry.as_str()) {
|
||||
Some(contained) => Requirement::DataFormSubform(contained),
|
||||
None => match all.find_unterformular(entry.as_str()) {
|
||||
Some(contained) => Requirement::UnterformularSubform(contained),
|
||||
None => Requirement::ExternalUnterformularSubform(entry.to_string()),
|
||||
},
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
sub_forms.sort_unstable_by_key(|item| item.sorting_key());
|
||||
result.append(sub_forms);
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,6 +556,9 @@ pub struct Entry {
|
||||
direction_pat_modul: String,
|
||||
#[serde(rename = "SeitenumbruchPatModul")]
|
||||
seitenumbruch_pat_modul: bool,
|
||||
#[serde(rename = "Kontaktliste")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
kontaktliste: Option<String>,
|
||||
#[serde(rename = "MarkierungIgnorieren")]
|
||||
markierung_ignorieren: bool,
|
||||
#[serde(rename = "SucheArt")]
|
||||
|
||||
Reference in New Issue
Block a user