Replace clap with custom CLI parser
Replaced the CLI parser based on clap with a custom parser and removed clap as a dependency. Note that the remaining integration test for the cli has been enabled and the new implementations is shorter (in loc) than the previous version using clap.
Number of dependencies and binary size impact report
| Metric | main | PR #287 | Delta |
|---|---|---|---|
| Direct dependencies | 8 | 8 | - |
| Total dependencies | 116 | 85 | -26.7% |
| Binary size | 1.3 MiB | 969 KiB | -27.6% |
| Text size | 780.9 KiB | 556.5 KiB | -28.7% |
Dependencies diff
└─ sudo [v0.1.0-alpha.1]
├─ sudo-cli [v0.1.0-alpha.1]
- | └─ clap [v4.2.7]
- | ├─ clap_builder [v4.2.7]
- | | ├─ anstream [v0.3.2]
- | | | ├─ anstyle [v1.0.0]
- | | | ├─ anstyle-parse [v0.2.0]
- | | | | └─ utf8parse [v0.2.1]
- | | | ├─ anstyle-query [v1.0.0]
- | | | ├─ colorchoice [v1.0.0]
- | | | ├─ is-terminal [v0.4.7]
- | | | | ├─ io-lifetimes [v1.0.10]
- | | | | | └─ libc [v0.2.144]
- | | | | └─ rustix [v0.37.19]
- | | | | ├─ bitflags [v1.3.2]
- | | | | ├─ io-lifetimes [v1.0.10]
- | | | | ├─ libc [v0.2.144]
- | | | | └─ linux-raw-sys [v0.3.7]
- | | | └─ utf8parse [v0.2.1]
- | | ├─ anstyle [v1.0.0]
- | | ├─ bitflags [v1.3.2]
- | | ├─ clap_lex [v0.4.1]
- | | ├─ once_cell [v1.17.1]
- | | └─ strsim [v0.10.0]
- | ├─ clap_derive [v4.2.0]
- | | ├─ heck [v0.4.1]
- | | ├─ proc-macro2 [v1.0.56]
- | | | └─ unicode-ident [v1.0.8]
- | | ├─ quote [v1.0.27]
- | | | └─ proc-macro2 [v1.0.56]
- | | └─ syn [v2.0.15]
- | | ├─ proc-macro2 [v1.0.56]
- | | ├─ quote [v1.0.27]
- | | └─ unicode-ident [v1.0.8]
- | └─ once_cell [v1.17.1]
-
├─ sudo-common [v0.1.0-alpha.1]
| ├─ libc [v0.2.144]
| ├─ sudo-cli [v0.1.0-alpha.1]
| ├─ sudo-pam [v0.1.0-alpha.1]
| | ├─ libc [v0.2.144]
| | ├─ sudo-cutils [v0.1.0-alpha.1]
| | | └─ libc [v0.2.144]
| | └─ sudo-pam-sys [v0.1.0-alpha.1]
| | ├─ libc [v0.2.144]
| | └─ bindgen [v0.63.0]
| | ├─ bitflags [v1.3.2]
| | ├─ cexpr [v0.6.0]
| | | └─ nom [v7.1.3]
| | | ├─ memchr [v2.5.0]
| | | └─ minimal-lexical [v0.2.1]
| | ├─ clang-sys [v1.6.1]
| | | ├─ glob [v0.3.1]
| | | ├─ libc [v0.2.144]
| | | ├─ libloading [v0.7.4]
| | | | └─ cfg-if [v1.0.0]
| | | └─ glob [v0.3.1]
| | ├─ lazy_static [v1.4.0]
| | ├─ lazycell [v1.3.0]
| | ├─ log [v0.4.17]
| | | └─ cfg-if [v1.0.0]
| | ├─ peeking_take_while [v0.1.2]
- | | ├─ proc-macro2 [v1.0.56]
-
+ | | ├─ proc-macro2 [v1.0.57]
+ | | | └─ unicode-ident [v1.0.8]
+
| | ├─ quote [v1.0.27]
+ | | | └─ proc-macro2 [v1.0.57]
+
| | ├─ regex [v1.8.1]
| | | └─ regex-syntax [v0.7.1]
| | ├─ rustc-hash [v1.1.0]
| | ├─ shlex [v1.1.0]
| | ├─ syn [v1.0.109]
- | | | ├─ proc-macro2 [v1.0.56]
-
+ | | | ├─ proc-macro2 [v1.0.57]
+
| | | ├─ quote [v1.0.27]
| | | └─ unicode-ident [v1.0.8]
| | └─ which [v4.4.0]
| | ├─ either [v1.8.1]
| | └─ libc [v0.2.144]
| └─ sudo-system [v0.1.0-alpha.1]
| ├─ libc [v0.2.144]
| ├─ sudo-cutils [v0.1.0-alpha.1]
| └─ sudo-log [v0.1.0-alpha.1]
| ├─ env_logger [v0.9.3]
| | └─ log [v0.4.17]
| | └─ cfg-if [v1.0.0]
| ├─ log [v0.4.17]
| └─ syslog [v6.1.0]
| ├─ error-chain [v0.12.4]
| | └─ version_check [v0.9.4]
| ├─ hostname [v0.3.1]
| | ├─ libc [v0.2.144]
| | └─ match_cfg [v0.1.0]
| ├─ libc [v0.2.144]
| ├─ log [v0.4.17]
| └─ time [v0.3.21]
| ├─ itoa [v1.0.6]
| ├─ libc [v0.2.144]
| ├─ num_threads [v0.1.6]
| └─ time-core [v0.1.1]
├─ sudo-env [v0.1.0-alpha.1]
| ├─ sudo-common [v0.1.0-alpha.1]
| ├─ sudo-system [v0.1.0-alpha.1]
| └─ sudoers [v0.1.0-alpha.1]
| ├─ glob [v0.3.1]
| ├─ sudo-defaults [v0.1.0-alpha.1]
| ├─ sudo-log [v0.1.0-alpha.1]
| └─ sudo-system [v0.1.0-alpha.1]
├─ sudo-exec [v0.1.0-alpha.1]
| ├─ signal-hook [v0.3.15]
| | ├─ libc [v0.2.144]
| | ├─ signal-hook-registry [v1.4.1]
| | | └─ libc [v0.2.144]
| | └─ cc [v1.0.79]
| ├─ sudo-common [v0.1.0-alpha.1]
| ├─ sudo-log [v0.1.0-alpha.1]
| └─ sudo-system [v0.1.0-alpha.1]
├─ sudo-log [v0.1.0-alpha.1]
├─ sudo-pam [v0.1.0-alpha.1]
├─ sudo-system [v0.1.0-alpha.1]
└─ sudoers [v0.1.0-alpha.1]
Codecov Report
Patch coverage: 88.93% and project coverage change: +1.40 :tada:
Comparison is base (
e22e48f) 73.65% compared to head (82763ff) 75.06%.
Additional details and impacted files
@@ Coverage Diff @@
## main #287 +/- ##
==========================================
+ Coverage 73.65% 75.06% +1.40%
==========================================
Files 39 39
Lines 4829 4865 +36
==========================================
+ Hits 3557 3652 +95
+ Misses 1272 1213 -59
| Impacted Files | Coverage Δ | |
|---|---|---|
| lib/sudo-common/src/command.rs | 98.00% <0.00%> (+0.35%) |
:arrow_up: |
| sudo/src/main.rs | 1.01% <0.00%> (-0.13%) |
:arrow_down: |
| lib/sudo-common/src/context.rs | 92.68% <80.00%> (-2.06%) |
:arrow_down: |
| lib/sudo-cli/src/lib.rs | 95.68% <95.51%> (+21.46%) |
:arrow_up: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
FYI I expect to do another iteration over this code. So please be critical while reviewing this.