#command-line #diagnostics #cli

medic

Library for self-diagnostic output for command line tools

4 releases

0.3.2 Nov 11, 2024
0.3.1 Sep 6, 2024
0.3.0 May 26, 2024
0.2.0 Mar 11, 2024

#243 in Command-line interface

Download history 109/week @ 2024-08-23 250/week @ 2024-08-30 365/week @ 2024-09-06 176/week @ 2024-09-13 161/week @ 2024-09-20 255/week @ 2024-09-27 21/week @ 2024-10-04 99/week @ 2024-10-11 107/week @ 2024-10-18 346/week @ 2024-10-25 144/week @ 2024-11-01 432/week @ 2024-11-08 183/week @ 2024-11-15 92/week @ 2024-11-22 120/week @ 2024-11-29 230/week @ 2024-12-06

630 downloads per month
Used in chezmoi_modify_manager

MPL-2.0 license

16KB
199 lines

Medic - helper library for self diagnostic output in CLIs

[ lib.rs ] [ crates.io ]

This is a helper for command line programs to output information on the environment. The intended use is to mention in your bug reporting template that you want the output of --medic, --doctor or similar. This library will help generate that output, supplemented by your own checks specific to your program.

Your checks might be able to catch common mistakes so that the user doesn't even need to report a bug in the first place. But even if not, now you have some basic info (such as platform, rust version etc) to go on.

Example output (from chezmoi_modify_manager):

RESULT   CHECK             MESSAGE
Info     version           3.1.2
Warning  build             Github CI build (not official release)
Info     rustc-version     1.76.0
Info     host              os=linux, arch=x86_64, info=Arch Linux Rolling Release [64-bit]
Ok       has-chezmoi       Chezmoi found. Version: chezmoi version v2.46.1, built at 2024-02-12T09:19:56Z
Ok       chezmoi-override  CHEZMOI_MODIFY_MANAGER_ASSUME_CHEZMOI_VERSION is not set
Ok       in-path           chezmoi_modify_manager is in PATH at /home/user/bin/chezmoi_modify_manager
Ok       has-ignore        Ignore of **/*.src.ini found
Ok       no-hook-script    No legacy hook script found

Warning: Warning(s) found, consider investigating (especially if you have issues)

The actual output is uses ANSI colour codes as well.

MSRV

Current minimum supported Rust version is 1.75.0. This may be updated as needed. MSRV bump is not considered a semver breaking change.

Credits

The idea was inspired by chezmoi doctor and implemented in chezmoi_modify_manager, then extracted into a separate crate to allow for reuse later on.

Dependencies

~0.8–8MB
~65K SLoC