-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Work in Progress: Initial implementation of --doctor
command
#1193
base: main
Are you sure you want to change the base?
Conversation
335a0cc
to
3220722
Compare
11898ce
to
369a044
Compare
src/subcommands/doctor/less.rs
Outdated
impl Diagnostic for Less { | ||
fn report(&self) -> (String, bool) { | ||
match self.version { | ||
Some(n) => match n < self.min_version { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could alternatively use
Some(n) if n < self.min_version
src/subcommands/doctor/report.rs
Outdated
let mut reports = Vec::new(); | ||
for d in diagnostics { | ||
reports.push(build_report_row(d)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More code golf; I think an alternative here is
let reports = diagnostics.into_iter().map(build_report_row).collect();
src/subcommands/doctor/report.rs
Outdated
Ok(()) | ||
} | ||
|
||
fn build_report_row(diagnostic: Box<dyn Diagnostic>) -> Report { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be named build_report
maybe since it returns Report
? Or, should it be Report::from_diagnostic()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I went with the Report::from_diagnostic()
version.
src/subcommands/doctor/report.rs
Outdated
use tabled::{Style, Table, Tabled}; | ||
|
||
#[cfg(not(tarpaulin_include))] | ||
pub fn run_diagnostics() -> std::io::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be called print_doctor_report
since it's the entrypoint.
Thanks for the review @dandavison! I made the updates you suggested. |
Provides the structure for adding checks to the user's environment that might interfere with delta usage. Also includes checks for - `less` version - `GIT_CONFIG*` environment variables - `*PAGER` environment variables
Rebased on master |
This is an initial version of the
--doctor
command, which will check various settings of a user's environment and identify possible incompatibilities withdelta
.This PR is intended to show a potential pattern for adding new
--doctor
checks, so I've intentionally kept the list of handled checks short, in anticipation of structural changes that are suggested during code review.The suggested pattern for adding new checks is to add a new
struct
that implements theDiagnostic
trait, comprised of the following methods:diagnose
: gets the setting in the user's environment, and compares it to allowed settings. Returns aHealth
object with a diagnosis & remedy if the setting is potentially incompatible with delta.remedy
: Suggests a remedy, if theHealth
object returned bydiagnose
indicates that the setting may be incompatible.report
: Reports the value of the setting, whether or not it is "healthy".Currently,
delta --doctor
prints thereport
to stdout.Addresses #1184.