27 Commits

Author SHA1 Message Date
e70b30112b refactor: do not use format!() 2024-01-25 12:20:26 +01:00
10f737cb41 fix: do not use as mut variable 2024-01-24 13:07:35 +01:00
a6657842c4 feat: show current file name in progress bar 2024-01-24 13:05:07 +01:00
adcce76f5c docs: ad some information about sorting and OBS files 2024-01-24 12:34:25 +01:00
f904f62d45 do not propagate version when using sub commands 2024-01-17 09:36:13 +01:00
47be1c7caf build: update dependencies 2024-01-17 09:28:41 +01:00
bf5a3a697f refactor: Cleanup command handling 2024-01-17 09:25:38 +01:00
0ec9c85e3a docs: add applications help output 2024-01-16 09:44:28 +01:00
221b2c6a2f feat: add shortcut methods to read OSC and Profile files 2023-12-31 18:34:42 +01:00
dc62454a74 feat: read YAML files containing profile using new file io 2023-12-31 17:09:57 +01:00
ee600436f9 refactor: reorganize features in file handling and errors 2023-12-31 16:57:32 +01:00
f858ecb9d4 fix: add missing feature flag 2023-12-31 16:44:00 +01:00
8c44e623f6 refactor: extract cli command handling 2023-12-30 07:54:49 +01:00
42d1151a6c feat: add note for OSB files within tree subcommand 2023-12-30 07:40:36 +01:00
2d2fb0dc61 Merge pull request #25 from CCC-MF/issue_24
feat #24: List content of OSB files
2023-12-30 07:35:52 +01:00
036dc80ad0 feat #24: List content of OSB files 2023-12-30 07:30:44 +01:00
fccfe4a880 chore: update dependencies 2023-12-28 13:50:06 +01:00
9ab00ce192 feat: remove error messages from list subcommand 2023-12-06 12:01:18 +01:00
70562f99ca style: code cleanup in file extension check 2023-12-06 12:00:28 +01:00
dcfc50878e feat: check file extension before reading OSC files 2023-12-06 11:44:49 +01:00
2358f6410f build: update dependencies 2023-12-06 11:25:36 +01:00
8f6bbc1692 feat: add script code to Klinik/Anamnese-MTB in ukw profile 2023-12-06 11:24:00 +01:00
0a3ca817c6 Code cleanup: Remove needless borrowed reference 2023-11-23 10:26:46 +01:00
172a2cc692 Code cleanup: Entry implements Display trait - remove 'to_string()' 2023-11-23 10:16:12 +01:00
7021f94891 Code cleanup: Use 'matches!()' macro 2023-11-23 10:13:55 +01:00
6589349b8d Implement Display trait for Requirement 2023-11-23 10:10:07 +01:00
2808cc3556 Code cleanup 2023-11-23 10:07:26 +01:00
14 changed files with 718 additions and 500 deletions

272
Cargo.lock generated
View File

@@ -36,9 +36,9 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]]
name = "async-trait"
version = "0.1.74"
version = "0.1.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9"
checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
@@ -74,9 +74,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
[[package]]
name = "block-buffer"
@@ -148,9 +148,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.4.7"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b"
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
dependencies = [
"clap_builder",
"clap_derive",
@@ -158,9 +158,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.7"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663"
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
dependencies = [
"anstyle",
"clap_lex",
@@ -168,9 +168,9 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "4.4.4"
version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae"
checksum = "dfb0d4825b75ff281318c393e8e1b80c4da9fb75a6b1d98547d389d6fe1f48d2"
dependencies = [
"clap",
]
@@ -195,15 +195,15 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
name = "console"
version = "0.15.7"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"unicode-width",
"windows-sys 0.45.0",
"windows-sys",
]
[[package]]
@@ -214,9 +214,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "cpufeatures"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0"
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
dependencies = [
"libc",
]
@@ -232,12 +232,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.16"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if",
]
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "crypto-common"
@@ -258,9 +255,9 @@ dependencies = [
[[package]]
name = "deranged"
version = "0.3.9"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
dependencies = [
"powerfmt",
]
@@ -303,12 +300,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.48.0",
"windows-sys",
]
[[package]]
@@ -339,15 +336,15 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.28.0"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "hashbrown"
version = "0.14.2"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "heck"
@@ -413,9 +410,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "jobserver"
@@ -434,21 +431,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.150"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "linux-raw-sys"
version = "0.4.11"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "memchr"
version = "2.6.4"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "miniz_oxide"
@@ -467,9 +464,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "object"
version = "0.32.1"
version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
@@ -478,6 +475,7 @@ dependencies = [
name = "osc-variant"
version = "0.7.0"
dependencies = [
"bytes",
"clap",
"clap_complete",
"console",
@@ -522,15 +520,15 @@ checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pkg-config"
version = "0.3.27"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
[[package]]
name = "portable-atomic"
version = "1.5.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
[[package]]
name = "powerfmt"
@@ -540,9 +538,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "proc-macro2"
version = "1.0.69"
version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
dependencies = [
"unicode-ident",
]
@@ -559,9 +557,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.33"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@@ -589,37 +587,37 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.21"
version = "0.38.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.48.0",
"windows-sys",
]
[[package]]
name = "ryu"
version = "1.0.15"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "serde"
version = "1.0.192"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.192"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
dependencies = [
"proc-macro2",
"quote",
@@ -628,9 +626,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.9.27"
version = "0.9.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c"
checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38"
dependencies = [
"indexmap",
"itoa",
@@ -663,9 +661,9 @@ dependencies = [
[[package]]
name = "sha256"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7895c8ae88588ccead14ff438b939b0c569cd619116f14b4d13fdff7b8333386"
checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0"
dependencies = [
"async-trait",
"bytes",
@@ -688,9 +686,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "syn"
version = "2.0.39"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
@@ -699,31 +697,31 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.8.1"
version = "3.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
dependencies = [
"cfg-if",
"fastrand",
"redox_syscall",
"rustix",
"windows-sys 0.48.0",
"windows-sys",
]
[[package]]
name = "thiserror"
version = "1.0.50"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.50"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
@@ -732,9 +730,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.30"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5"
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
dependencies = [
"deranged",
"powerfmt",
@@ -750,9 +748,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "tokio"
version = "1.34.0"
version = "1.35.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
dependencies = [
"backtrace",
"bytes",
@@ -779,9 +777,9 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "unsafe-libyaml"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa"
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
[[package]]
name = "version_check"
@@ -791,141 +789,75 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "windows-sys"
version = "0.45.0"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "zeroize"
version = "1.6.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
[[package]]
name = "zip"

View File

@@ -24,6 +24,7 @@ indicatif = "0.17"
deob = { path = "./libs/deob", optional = true }
zip = { version = "0.6", optional = true }
bytes = "1.5.0"
[features]
# Requires env var OSB_KEY to be present at build time

View File

@@ -18,6 +18,25 @@ unvollständigen Ausgabedateien zu erzeugen.
Die folgenden Unterbefehle sind verfügbar
```
Anwendung zum Anpassen einer OSC-Datei an einen Standort
Usage: osc-variant <COMMAND>
Commands:
sha256sum Berechne SHA256 Prüfsumme für die angegebene Datei
list Zeigt alle enthaltenen Kataloge und Formulare mit Revision an.
tree Zeigt Kataloge und Formulare mit Revision und Abhängigkeiten an.
modify Modifiziert die angegebene Datei anhand der Profildatei
diff Vergleiche zwei Dateien anhand der Revision der enthaltenen Inhalte
check Prüfe eine OSC-Datei auf bekannte Problemen
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```
#### Unterbefehl `sha256sum`
Das Berechnen der SHA256 Prüfsumme ist mit dem Unterbefehl `sha256sum` auch unter Windows einfach möglich
@@ -37,6 +56,8 @@ osc-variant list meine-beispieldatei.osc
Mit der Option `--filter` kann die Ausgabe eingeschränkt werden.
*Bei Verwendung der OSB-Funktionalität kann die Eingabe eines Passworts erforderlich sein.*
#### Unterbefehl `tree`
Zum Auflisten der Inhalte mit allen Abhängigkeiten, z.B. Daten- und Merkmalskataloge und bei Formularen wird der Befehl
@@ -119,6 +140,8 @@ Der Unterbefehl `check` prüft eine OSC-Datei auf bekannte Probleme und gibt ein
Eine Liste mit bekannten Problemen wird mit `check --list` ausgegeben.
*Bei Verwendung der OSB-Funktionalität kann die Eingabe eines Passworts erforderlich sein.*
#### Kompakte Ausgabe
OSC-Dateien sind XML-Dateien. Diese Anwendung ermöglicht optional die Ausgabe als kompaktere XML-Datei ohne Zeilenumbrüche.
@@ -143,6 +166,8 @@ da Onkostar einen Formularimport sequenziell, ohne Berücksichtigung von Abhäng
Dies erlaubt eine konsistente Reihenfolge der Einträge, wodurch ein direkter Vergleich mit Vorversionen ermöglicht wird.
*Die Einteilung in Formualre und Unterformualare wird hierdurch nicht angepasst.*
##### Entfernen von Inhalten der Systembibliothek bei Modifikation
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.

View File

@@ -4,6 +4,13 @@ forms:
- name: MTB
referenced_data_form: 'OS.Tumorkonferenz.VarianteUKW'
anzeige_auswahl: 'MTB vom {Datum}'
script_code: |
// Keine Übernahme des Datums des MTBs bei Verwendung
// des Formulars 'OS.Tumorkonferenz'.
// Gewollt ist das Datum, an der die Anmeldung stattgefunden hat.
//setFieldValue('AnmeldedatumMTB', getFieldValue('MTB').Datum);
setFieldValue('WHOGrad', getFieldValue('MTB').WHOGrad);
- name: 'DNPM Therapieplan'
form_references:
- name: referstemtb

View File

@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2023 Comprehensive Cancer Center Mainfranken
* Copyright (c) 2024 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
@@ -26,7 +26,7 @@ use std::fs;
use std::io::Read;
use std::path::Path;
use indicatif::ProgressBar;
use indicatif::{ProgressBar, ProgressStyle};
use crate::checks::{osc, CheckNotice};
@@ -54,11 +54,16 @@ pub fn check_file(file: &Path, password: &str) -> Result<Vec<CheckNotice>, Check
let mut result = vec![];
let progress_bar = ProgressBar::new(archive.len() as u64);
let progress_bar = ProgressBar::new(archive.len() as u64).with_style(
ProgressStyle::default_bar()
.template("{wide_bar} {msg:32} {pos}/{len}")
.unwrap(),
);
for i in 0..archive.len() {
progress_bar.inc(1);
if let Ok(Ok(mut zip_file)) = archive.by_index_decrypt(i, password.as_bytes()) {
progress_bar.set_message(zip_file.name().to_string());
if zip_file.is_file() && zip_file.name().ends_with(".osc") {
let mut buf = String::new();
let _ = zip_file.read_to_string(&mut buf);
@@ -97,7 +102,7 @@ pub fn check_file(file: &Path, password: &str) -> Result<Vec<CheckNotice>, Check
}
} else {
return Err(CheckNotice::Error {
description: format!("Kann Datei nicht lesen"),
description: "Kann Datei nicht lesen".to_string(),
line: None,
});
}

View File

@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2023 Comprehensive Cancer Center Mainfranken
* Copyright (c) 2024 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
@@ -30,8 +30,8 @@ fn build_cli() -> Command {
}
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true, arg_required_else_help(true))]
#[command(author, version, about)]
#[command(arg_required_else_help(true))]
pub struct Cli {
#[command(subcommand)]
pub cmd: SubCommand,

316
src/commands.rs Normal file
View File

@@ -0,0 +1,316 @@
/*
* MIT License
*
* Copyright (c) 2024 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::error::Error;
use std::fs;
use std::fs::OpenOptions;
use std::io::Write;
use std::ops::Add;
use std::path::{Path, PathBuf};
use console::style;
use dialoguer::Confirm;
use quick_xml::se::Serializer;
use serde::Serialize;
use sha256::digest;
use crate::checks::{check_file, print_checks, CheckNotice};
use crate::cli::SubCommand;
use crate::file_io::{FileError, FileReader, InputFile};
use crate::model::onkostar_editor::OnkostarEditor;
use crate::profile::Profile;
fn write_outputfile(filename: String, content: &String) -> Result<(), FileError> {
OpenOptions::new()
.read(false)
.write(true)
.create(true)
.truncate(true)
.open(filename.clone())
.map_err(|err| FileError::Writing(filename.clone(), err.to_string()))?
.write_all(content.as_bytes())
.map_err(|err| FileError::Writing(filename, err.to_string()))?;
Ok(())
}
pub fn handle(command: SubCommand) -> Result<(), Box<dyn Error>> {
match command {
SubCommand::List {
inputfile,
sorted,
filter,
} => match InputFile::read(inputfile, None)? {
osc @ InputFile::Osc { .. } => {
let mut content: OnkostarEditor = osc.try_into()?;
if sorted {
content.sorted()
}
if let Some(name) = filter {
OnkostarEditor::print_list_filtered(&mut content, name.as_str());
return Ok(());
}
content.print_list();
}
InputFile::Osb { content, .. } => {
for file in content {
match file {
InputFile::Osc { .. } => {
println!(
"{}{}",
style("OSB-Paketinhalt: ").bold().yellow(),
style(file.filename()).bold()
);
let mut content: OnkostarEditor = match file.try_into() {
Ok(oe) => oe,
Err(err) => {
println!("{}", err);
continue;
}
};
if sorted {
content.sorted()
}
if let Some(name) = filter {
OnkostarEditor::print_list_filtered(&mut content, name.as_str());
return Ok(());
}
content.print_list();
println!()
}
_ => {
println!(
"{}{}{}",
style("OSB-Paketinhalt: ").bold().yellow(),
style(file.filename()).bold(),
style(" ignoriert").yellow()
);
}
}
}
}
InputFile::Yaml { filename, .. } | InputFile::Other { filename, .. } => {
return Err(Box::new(FileError::Reading(
filename,
"Nur OSB- und OSC-Dateien werden unterstützt".to_string(),
)))
}
},
SubCommand::Tree {
inputfile,
sorted,
filter,
} => match InputFile::read(inputfile, None)? {
osc @ InputFile::Osc { .. } => {
let mut content: OnkostarEditor = osc.try_into()?;
if sorted {
content.sorted()
}
if let Some(name) = filter {
OnkostarEditor::print_tree_filtered(&mut content, name.as_str());
return Ok(());
}
OnkostarEditor::print_tree(&content);
}
InputFile::Osb { filename, .. } => return Err(Box::new(FileError::Reading(
filename,
"Nur OSC-Dateien werden unterstützt. OSB-Dateien erzeugen eine zu lange Ausgabe."
.to_string(),
))),
InputFile::Yaml { filename, .. } | InputFile::Other { filename, .. } => {
return Err(Box::new(FileError::Reading(
filename,
"Nur OSC-Dateien werden unterstützt".to_string(),
)))
}
},
SubCommand::Modify {
inputfile,
profile,
outputfile,
compact,
sorted,
strip,
interactive,
fix,
} => {
let mut data: OnkostarEditor = InputFile::read(inputfile, None)?.try_into()?;
if let Some(profile) = profile {
let profile = if profile.contains('.') {
FileReader::<Profile>::read(profile)?
} else {
Profile::embedded_profile(profile.as_str())?
};
data.apply_profile(&profile);
}
let mut compact = compact;
let mut sorted = sorted;
let mut strip = strip;
if interactive {
compact = Confirm::new()
.with_prompt("Kompakte Ausgabe, ohne Einrücken?")
.default(compact)
.interact()
.unwrap();
sorted = Confirm::new()
.with_prompt("Sortiere Kataloge und Formulare nach Name und Abhängigkeiten?")
.default(sorted)
.interact()
.unwrap();
strip = Confirm::new()
.with_prompt(
"Entferne Einträge aus der Systembibliothek die nicht importiert werden?",
)
.default(strip)
.interact()
.unwrap();
}
if fix {
// No operation as of now
}
if sorted {
data.sorted();
}
if strip {
data.strip_system_library_content();
}
let mut buf = String::new();
let mut serializer = Serializer::new(&mut buf);
if !compact {
serializer.indent(' ', 2);
}
data.serialize(serializer).expect("Generated XML");
let output = &"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
.to_string()
.add(
buf
// Replace &apos; and &quot; as used in original file
.replace("&apos;", "'")
.replace("&quot;", "\"")
.as_str(),
);
match outputfile {
Some(filename) => write_outputfile(filename, output)?,
None => {
println!("{}", output)
}
}
}
SubCommand::Diff {
inputfile_a,
inputfile_b,
strict,
} => {
println!(
"Vergleiche Datei A ({}) mit Datei B ({})",
style(&inputfile_a).yellow(),
style(&inputfile_b).yellow()
);
let data_a = &mut FileReader::<OnkostarEditor>::read(inputfile_a)?;
let data_b = &mut FileReader::<OnkostarEditor>::read(inputfile_b)?;
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()));
}
},
SubCommand::Check {
file,
list,
password,
} => {
if list {
print_checks();
} else {
match check_file(Path::new(file.unwrap_or_default().as_str()), password) {
Ok(notices) => {
println!(
"Es wurden {} Probleme gefunden\n",
notices
.iter()
.filter(|notice| matches!(
notice,
CheckNotice::ErrorWithCode { .. } | CheckNotice::Error { .. }
))
.count()
);
notices
.iter()
.for_each(|check_notice| println!("{}", check_notice));
}
Err(err) => {
println!("{}", err)
}
}
}
}
#[cfg(feature = "unzip-osb")]
SubCommand::UnzipOsb {
file,
password,
dir,
} => {
use crate::unzip_osb::{unzip_osb, unzip_osb_using_password};
match password {
Some(password) => unzip_osb_using_password(
file.as_str(),
dir.unwrap_or_default().as_str(),
password.as_str(),
),
None => unzip_osb(file.as_str(), dir.unwrap_or_default().as_str()),
}
}
}
Ok(())
}

226
src/file_io.rs Normal file
View File

@@ -0,0 +1,226 @@
/*
* MIT License
*
* Copyright (c) 2024 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::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::fs;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;
use crate::model::onkostar_editor::OnkostarEditor;
use crate::profile::Profile;
pub enum FileError {
Reading(String, String),
Writing(String, String),
Parsing(String, String),
}
impl Error for FileError {}
impl Debug for FileError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(self, f)
}
}
impl Display for FileError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match &self {
FileError::Reading(filename, err) => format!("Kann Datei '{}' nicht lesen: {}", filename, err),
FileError::Writing(filename, err) => format!("Kann Datei '{}' nicht schreiben: {}", filename, err),
FileError::Parsing(filename, err) => format!(
"Die Datei '{}' wird nicht unterstützt, ist fehlerhaft oder enthält zusätzliche Inhalte\n{}",
filename,
err
)
}
)
}
}
#[allow(dead_code)]
pub enum InputFile {
Osc {
filename: String,
content: String,
},
Osb {
filename: String,
content: Vec<InputFile>,
},
Yaml {
filename: String,
content: String,
},
Other {
filename: String,
content: Vec<u8>,
},
}
impl InputFile {
pub fn filename(&self) -> String {
match self {
InputFile::Osc { filename, .. } => filename,
InputFile::Osb { filename, .. } => filename,
InputFile::Yaml { filename, .. } => filename,
InputFile::Other { filename, .. } => filename,
}
.to_string()
}
pub fn read(filename: String, _password: Option<String>) -> Result<Self, FileError> {
if let Some(extension) = Path::new(filename.as_str()).extension() {
return match extension.to_str() {
Some("osc") => match fs::read_to_string(filename.clone()) {
Ok(content) => Ok(InputFile::Osc { filename, content }),
Err(err) => Err(FileError::Reading(filename, err.to_string())),
},
#[cfg(feature = "unzip-osb")]
Some("osb") => {
use bytes::BytesMut;
use deob::deobfuscate;
use std::io::Read;
let file = match fs::File::open(filename.clone()) {
Ok(file) => file,
Err(err) => return Err(FileError::Reading(filename, err.to_string())),
};
let mut archive = match zip::ZipArchive::new(file) {
Ok(file) => file,
Err(err) => return Err(FileError::Reading(filename, err.to_string())),
};
let mut result = vec![];
let password = _password.unwrap_or_else(|| deobfuscate(env!("OSB_KEY").trim()));
for i in 0..archive.len() {
if let Ok(Ok(mut zip_file)) =
archive.by_index_decrypt(i, password.as_bytes())
{
if zip_file.is_file() && zip_file.name().ends_with(".osc") {
let mut buf = String::new();
let _ = zip_file.read_to_string(&mut buf);
result.push(InputFile::Osc {
filename: zip_file.name().to_string(),
content: buf,
})
} else {
let mut buf = BytesMut::new();
let _ = zip_file.read(&mut buf);
result.push(InputFile::Other {
filename: zip_file.name().to_string(),
content: buf.to_vec(),
})
}
} else {
return Err(FileError::Parsing(
filename.into(),
"Kann OSB-Datei nicht lesen".to_string(),
));
}
}
Ok(InputFile::Osb {
filename,
content: result,
})
}
Some("yml") | Some("yaml") => match fs::read_to_string(filename.clone()) {
Ok(content) => Ok(InputFile::Yaml { filename, content }),
Err(err) => Err(FileError::Reading(filename, err.to_string())),
},
_ => Err(FileError::Parsing(
filename,
"Kein unterstütztes Dateiformat".to_string(),
)),
};
}
Err(FileError::Reading(filename, String::new()))
}
}
impl TryFrom<InputFile> for OnkostarEditor {
type Error = FileError;
fn try_from(value: InputFile) -> Result<Self, Self::Error> {
return match value {
InputFile::Osc {
filename, content, ..
} => match OnkostarEditor::from_str(content.as_str()) {
Ok(data) => Ok(data),
Err(err) => Err(FileError::Parsing(filename, err)),
},
InputFile::Osb { filename, .. }
| InputFile::Yaml { filename, .. }
| InputFile::Other { filename, .. } => {
Err(FileError::Parsing(filename, "Keine OSC-Datei".to_string()))
}
};
}
}
impl TryFrom<InputFile> for Profile {
type Error = FileError;
fn try_from(value: InputFile) -> Result<Self, Self::Error> {
match value {
InputFile::Yaml { filename, content } => match Profile::from_str(&content) {
Ok(profile) => Ok(profile),
Err(err) => Err(FileError::Parsing(filename, err)),
},
InputFile::Osc { filename, .. }
| InputFile::Osb { filename, .. }
| InputFile::Other { filename, .. } => Err(FileError::Parsing(
filename,
"Keine Profildatei".to_string(),
)),
}
}
}
/// Shortcut methods for OSC and Profile files
pub struct FileReader<FileType> {
file_type: PhantomData<FileType>,
}
impl FileReader<OnkostarEditor> {
pub fn read(filename: String) -> Result<OnkostarEditor, FileError> {
TryInto::<OnkostarEditor>::try_into(InputFile::read(filename.to_string(), None)?)
}
}
impl FileReader<Profile> {
pub fn read(filename: String) -> Result<Profile, FileError> {
TryInto::<Profile>::try_into(InputFile::read(filename.to_string(), None)?)
}
}

View File

@@ -22,301 +22,22 @@
* SOFTWARE.
*/
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::fs;
use std::fs::OpenOptions;
use std::io::Write;
use std::ops::Add;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use crate::checks::{check_file, print_checks, CheckNotice};
use crate::cli::Cli;
use crate::commands::handle;
use clap::Parser;
use console::style;
use dialoguer::Confirm;
use quick_xml::se::Serializer;
use serde::Serialize;
use sha256::digest;
use crate::cli::{Cli, SubCommand};
use crate::model::onkostar_editor::OnkostarEditor;
use crate::profile::Profile;
use std::error::Error;
mod checks;
mod cli;
mod commands;
mod file_io;
mod model;
mod profile;
#[cfg(feature = "unzip-osb")]
mod unzip_osb;
enum FileError {
Reading(String, String),
Writing(String, String),
Parsing(String, String),
}
impl Error for FileError {}
impl Debug for FileError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(self, f)
}
}
impl Display for FileError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match &self {
FileError::Reading(filename, err) => format!("Kann Datei '{}' nicht lesen: {}", filename, err),
FileError::Writing(filename, err) => format!("Kann Datei '{}' nicht schreiben: {}", filename, err),
FileError::Parsing(filename, err) => format!(
"Die Datei '{}' ist entweder keine OSC-Datei, fehlerhaft oder enthält zusätzliche Inhalte\n{}",
filename,
err
),
}
)
}
}
fn read_inputfile(inputfile: String) -> Result<OnkostarEditor, FileError> {
return match fs::read_to_string(inputfile.clone()) {
Ok(content) => match OnkostarEditor::from_str(content.as_str()) {
Ok(data) => Ok(data),
Err(err) => Err(FileError::Parsing(inputfile, err)),
},
Err(err) => Err(FileError::Reading(inputfile, err.to_string())),
};
}
fn write_outputfile(filename: String, content: &String) -> Result<(), FileError> {
OpenOptions::new()
.read(false)
.write(true)
.create(true)
.truncate(true)
.open(filename.clone())
.map_err(|err| FileError::Writing(filename.clone(), err.to_string()))?
.write_all(content.as_bytes())
.map_err(|err| FileError::Writing(filename, err.to_string()))?;
Ok(())
}
fn read_profile(filename: String) -> Result<Profile, FileError> {
let profile = fs::read_to_string(filename.clone())
.map_err(|err| FileError::Reading(filename.clone(), err.to_string()))?;
let profile =
Profile::from_str(profile.as_str()).map_err(|err| FileError::Reading(filename, err))?;
Ok(profile)
}
fn main() -> Result<(), Box<dyn Error>> {
let cli = Cli::parse();
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();
}
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);
}
SubCommand::Modify {
inputfile,
profile,
outputfile,
compact,
sorted,
strip,
interactive,
fix,
} => {
let data = &mut read_inputfile(inputfile)?;
if let Some(profile) = profile {
let profile = if profile.contains(".") {
read_profile(profile.clone()).map_err(|_| {
FileError::Reading(profile, "Kann Profildatei nicht lesen!".into())
})?
} else {
Profile::embedded_profile(profile.as_str())?
};
data.apply_profile(&profile);
}
let mut compact = compact;
let mut sorted = sorted;
let mut strip = strip;
if interactive {
compact = Confirm::new()
.with_prompt("Kompakte Ausgabe, ohne Einrücken?")
.default(compact)
.interact()
.unwrap();
sorted = Confirm::new()
.with_prompt("Sortiere Kataloge und Formulare nach Name und Abhängigkeiten?")
.default(sorted)
.interact()
.unwrap();
strip = Confirm::new()
.with_prompt(
"Entferne Einträge aus der Systembibliothek die nicht importiert werden?",
)
.default(strip)
.interact()
.unwrap();
}
if fix {
// No operation as of now
}
if sorted {
data.sorted();
}
if strip {
data.strip_system_library_content();
}
let mut buf = String::new();
let mut serializer = Serializer::new(&mut buf);
if !compact {
serializer.indent(' ', 2);
}
data.serialize(serializer).expect("Generated XML");
let output = &"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
.to_string()
.add(
buf
// Replace &apos; and &quot; as used in original file
.replace("&apos;", "'")
.replace("&quot;", "\"")
.as_str(),
);
match outputfile {
Some(filename) => write_outputfile(filename, output)?,
None => {
println!("{}", output)
}
}
}
SubCommand::Diff {
inputfile_a,
inputfile_b,
strict,
} => {
println!(
"Vergleiche Datei A ({}) mit Datei B ({})",
style(&inputfile_a).yellow(),
style(&inputfile_b).yellow()
);
let data_a = &mut read_inputfile(inputfile_a)?;
let data_b = &mut read_inputfile(inputfile_b)?;
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()));
}
};
}
SubCommand::Check {
file,
list,
password,
} => {
if list {
print_checks();
} else {
match check_file(Path::new(file.unwrap_or_default().as_str()), password) {
Ok(notices) => {
println!(
"Es wurden {} Probleme gefunden\n",
notices
.iter()
.filter(|notice| match notice {
CheckNotice::ErrorWithCode { .. }
| CheckNotice::Error { .. } => true,
_ => false,
})
.count()
);
notices
.iter()
.for_each(|check_notice| println!("{}", check_notice));
}
Err(err) => {
println!("{}", err)
}
}
}
}
#[cfg(feature = "unzip-osb")]
SubCommand::UnzipOsb {
file,
password,
dir,
} => {
use crate::unzip_osb::{unzip_osb, unzip_osb_using_password};
match password {
Some(password) => unzip_osb_using_password(
file.as_str(),
dir.unwrap_or_default().as_str(),
password.as_str(),
),
None => unzip_osb(file.as_str(), dir.unwrap_or_default().as_str()),
}
}
};
handle(cli.cmd)?;
Ok(())
}

View File

@@ -134,10 +134,10 @@ impl Requires for DataCatalogue {
.iter()
.map(|entry| match entry {
Requirement::PropertyCatalogue(_) => {
Some(format!(" - {}\n", entry.to_string()))
Some(format!(" - {}\n", entry))
}
Requirement::ExternalPropertyCatalogue(_) => {
Some(format!(" - {}\n", entry.to_string()))
Some(format!(" - {}\n", entry))
}
_ => None,
})

View File

@@ -209,25 +209,13 @@ 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(),
if self
.entries
.entry
.iter()
.filter(|entry| entry.procedure_date_status != "none")
.count()
== 0
{
style("Formular hat keine Angabe zum Prozedurdatum!").red()
} else {
style("")
}
style(&self.revision).yellow()
)
}
}

View File

@@ -456,14 +456,14 @@ impl Checkable for OnkostarEditor {
form.get_required_entries(self)
.iter()
.for_each(|entry| match entry {
Requirement::DataFormReference(&ref item) => {
Requirement::DataFormReference(item) => {
if !requirement_checked_forms.contains(&item.get_name()) {
result.push(requirement_error(form, item, "Formular"))
result.push(requirement_error(form, *item, "Formular"))
}
}
Requirement::UnterformularReference(&ref item) => {
Requirement::UnterformularReference(item) => {
if !requirement_checked_forms.contains(&item.get_name()) {
result.push(requirement_error(form, item, "Unterformular"))
result.push(requirement_error(form, *item, "Unterformular"))
}
}
_ => {}
@@ -475,14 +475,14 @@ impl Checkable for OnkostarEditor {
form.get_required_entries(self)
.iter()
.for_each(|entry| match entry {
Requirement::DataFormReference(&ref item) => {
Requirement::DataFormReference(item) => {
if !requirement_checked_forms.contains(&item.get_name()) {
result.push(requirement_error(form, item, "Formular"))
result.push(requirement_error(form, *item, "Formular"))
}
}
Requirement::UnterformularReference(&ref item) => {
Requirement::UnterformularReference(item) => {
if !requirement_checked_forms.contains(&item.get_name()) {
result.push(requirement_error(form, item, "Unterformular"))
result.push(requirement_error(form, *item, "Unterformular"))
}
}
_ => {}

View File

@@ -28,6 +28,7 @@ use crate::model::onkostar_editor::OnkostarEditor;
use crate::model::property_catalogue::PropertyCatalogue;
use crate::model::unterformular::Unterformular;
use crate::model::{Comparable, Listable, Sortable};
use std::fmt::Display;
#[allow(clippy::enum_variant_names)]
pub enum Requirement<'a> {
@@ -67,9 +68,9 @@ impl Sortable for Requirement<'_> {
}
}
impl ToString for Requirement<'_> {
fn to_string(&self) -> String {
match self {
impl Display for Requirement<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
Requirement::PropertyCatalogue(item) => item.to_listed_string(),
Requirement::DataCatalogue(item) => item.to_listed_string(),
Requirement::DataFormReference(item) => item.to_listed_string(),
@@ -90,7 +91,8 @@ impl ToString for Requirement<'_> {
| Requirement::ExternalUnterformularSubform(name) => {
format!("Unterformular (-) '{}' - hier nicht enthalten", name)
}
}
};
write!(f, "{}", str)
}
}
@@ -138,19 +140,19 @@ where
}
}
Requirement::ExternalDataCatalogue(_) => {
Some(format!(" + {}\n", entry.to_string()))
Some(format!(" + {}\n", entry))
}
Requirement::DataFormReference(_)
| Requirement::ExternalDataFormReference(_)
| Requirement::UnterformularReference(_)
| Requirement::ExternalUnterformularReference(_) => {
Some(format!(" > {}\n", entry.to_string()))
Some(format!(" > {}\n", entry))
}
Requirement::DataFormSubform(_)
| Requirement::ExternalDataFormSubform(_)
| Requirement::UnterformularSubform(_)
| Requirement::ExternalUnterformularSubform(_) => {
Some(format!(" * {}\n", entry.to_string()))
Some(format!(" * {}\n", entry))
}
_ => None,
})

View File

@@ -212,18 +212,13 @@ impl FormEntryContainer for Unterformular {
impl Listable for Unterformular {
fn to_listed_string(&self) -> String {
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(),
if self.hat_unterformulare {
style("Unterformular mit Markierung 'hat Unterformulare'!").red()
} else {
style("")
}
)
}
}