-
Notifications
You must be signed in to change notification settings - Fork 372
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
Rework the mullvad status listen
command
#6678
Conversation
31ab848
to
d66aae5
Compare
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.
Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @Serock3)
mullvad-cli/src/format.rs
line 31 at r1 (raw file):
// graphical frontends updating the drawn state with an identical one is // invisible, so this is only an issue for the CLI. match (&previous_state, &state) {
I like what you're doing here, and I generally prefer not nesting match statements if possible, but in this case the patterns are quite verbose. Have you considered only matching on state
, and matching again on previous_state
in the individual branches where needed? That could also help to get rid of the unreachable!
statement below.
mullvad-cli/src/format.rs
line 96 at r1 (raw file):
} _ => {} }
nit: if let
would look better here imo
mullvad-cli/src/format.rs
line 101 at r1 (raw file):
println!( "Updated features: {}", format_feature_indicators(feature_indicators)
Maybe we should do a pass over impl Display for FeatureIndicator
and make sure we match what the graphical client is showing
mullvad-cli/src/format.rs
line 211 at r2 (raw file):
} pub fn print_location(location: &GeoIpLocation) {
This prints "Your connection appears to be from ", but it's sometimes used to print where you are connected to
d786bff
to
aee338f
Compare
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.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @hulthe)
mullvad-cli/src/format.rs
line 31 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
I like what you're doing here, and I generally prefer not nesting match statements if possible, but in this case the patterns are quite verbose. Have you considered only matching on
state
, and matching again onprevious_state
in the individual branches where needed? That could also help to get rid of theunreachable!
statement below.
I swapped to nested match
es, but I also basically re-wrote the entire thing. It ended up much nicer in my opinion. Take a look!
mullvad-cli/src/format.rs
line 101 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
Maybe we should do a pass over
impl Display for FeatureIndicator
and make sure we match what the graphical client is showing
Don't think that the GUI can make use the Display
impl, but it's a good idea anyway, so I did it.
mullvad-cli/src/format.rs
line 211 at r2 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
This prints "Your connection appears to be from ", but it's sometimes used to print where you are connected to
I replaced it with the much simpler "Visible location"
63dbedc
to
dc38595
Compare
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.
Reviewed 1 of 2 files at r4.
Reviewable status: 1 of 5 files reviewed, 2 unresolved discussions (waiting on @Serock3)
mullvad-cli/src/format.rs
line 31 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
I swapped to nested
match
es, but I also basically re-wrote the entire thing. It ended up much nicer in my opinion. Take a look!
Nice, i like the changes you made
mullvad-cli/src/format.rs
line 202 at r4 (raw file):
(Some(value), Some(_)) if verbose => print_option!(name, value), (None, None) if verbose => print_option!(name, "None"), (None, Some(_)) => print_option!(format!("{name} (updated):"), "None"),
The colon here is redundant, print_option already prints a colon
Also it looks like some of the option names are too long (> 24 characters) with the " (updated)" postfix, which breaks the space alignment of print_option
mullvad-types/src/features.rs
line 72 at r4 (raw file):
impl FeatureIndicator { const fn to_str(&self) -> &str {
Should return a &'static str
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.
Reviewable status: 1 of 5 files reviewed, 3 unresolved discussions (waiting on @Serock3)
mullvad-cli/src/format.rs
line 152 at r4 (raw file):
feature_indicators: Option<&FeatureIndicators>, verbose: bool, ) -> HashMap<&'static str, Option<String>> {
Hmm. since you're using a HashMap, this will print stuff in a random order no?
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.
Reviewable status: 1 of 5 files reviewed, 3 unresolved discussions (waiting on @hulthe)
mullvad-cli/src/format.rs
line 152 at r4 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
Hmm. since you're using a HashMap, this will print stuff in a random order no?
Yup, considered sorting the output, but didn't see a good reason for it. Do you think it's necessary?
mullvad-cli/src/format.rs
line 202 at r4 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
The colon here is redundant, print_option already prints a colon
Also it looks like some of the option names are too long (> 24 characters) with the " (updated)" postfix, which breaks the space alignment of print_option
Fixed the colon.
dc38595
to
f95f737
Compare
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.
Reviewable status: 1 of 5 files reviewed, 3 unresolved discussions (waiting on @hulthe)
mullvad-types/src/features.rs
line 72 at r4 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
Should return a
&'static str
Done.
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.
Reviewable status: 1 of 5 files reviewed, all discussions resolved
f95f737
to
c6da720
Compare
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.
Reviewed 1 of 1 files at r6.
Reviewable status: 1 of 5 files reviewed, all discussions resolved
f95f737
to
15c5b5b
Compare
15c5b5b
to
485e931
Compare
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.
Reviewed all commit messages.
Reviewable status: 1 of 5 files reviewed, all discussions resolved
Rework the
mullvad status listen
command--verbose
flag, fields are left out if they are empty or updated to the same value (e.g. when going from connected -> connected with new features, "Relay" is not printed again)Example output:
Example output (with
--verbose
flag):This change is