Construct ExecutionContext in humility-bin#677
Conversation
b85f4b5 to
92ebd5d
Compare
f49aa94 to
20d913b
Compare
jamesmunns
left a comment
There was a problem hiding this comment.
A lot of pedantic nits, feel free to take them or leave them :)
| if let Ok(e) = env::var("HUMILITY_PROBE") { | ||
| cli.probe = Some(e); | ||
| } else if let Ok(e) = env::var("HUMILITY_IP") { | ||
| cli.ip = Some(e.parse().unwrap_or_else(|x| match x {})); |
There was a problem hiding this comment.
Wait how is parse returning Infallible here?
There was a problem hiding this comment.
Over in #668, we made IP parsing lazier – the parse captures a Result<..> which is only checked if we're actually using the IP address.
| // dump. If the user has specified no command line options but | ||
| // multiple of these in the environment, they will get the first in | ||
| // this ordering that we find. | ||
| if cli.dump.is_none() |
There was a problem hiding this comment.
Leaving a note, but it's probably not worth fixating on because this isn't new code:
It feels like there should be a nicer way to specify this, or at least, the semantics of what we've chosen as "the acceptable set of configuration combinations" feels overly complicated. Especially the repeated "is_some", matches, and asserts. I feel like I need a flowchart to follow this now :D
I have no calibration for "necessary complexity" vs "incidental complexity" here, but just leaving a note as an uninformed newcomer that "whew, this feels like a lot". It might be worth having a couple of functions for each acceptable source/combo of options to make it easier to hang documentation off of, so folks know what is/isn't allowed.
There was a problem hiding this comment.
As noted in the rework RFD, i would like to get rid of environments and just have other tooling set HUMILITY_PROBE and HUMILITY_ARCHIVE as appropriate. Environments solved an actual problem for us but I do not think the belong in a humility binary.
| // Cannot specify a dump/probe/IP address and also an | ||
| // environment and target | ||
| // | ||
| assert!(cli.dump.is_none()); |
There was a problem hiding this comment.
Maybe turn these asserts into ExitCode::FAILUREs too, to be polite?
There was a problem hiding this comment.
Mutual exclusion between these options is enforced by clap; I'll add a comment.
| PROBES_ENABLED | ||
| ); | ||
| if cmd.is_some() { | ||
| humility::warn!("ignoring subcommand after printing version"); |
There was a problem hiding this comment.
Already in scope
| humility::warn!("ignoring subcommand after printing version"); | |
| warn!("ignoring subcommand after printing version"); |
There was a problem hiding this comment.
Good catch, it wasn't in scope in the previous file that I copied from
| // The --version (-V) and --list-targets operations are implemented as | ||
| // flags, rather than subcommands, so we'll special-case them here. | ||
| if cli.version { | ||
| eprintln!( |
There was a problem hiding this comment.
When do we use humility::warn!, humility::msg!, and eprintln!?
There was a problem hiding this comment.
Right now, it's purely based on vibes! We'll want to standardize on log, but that's further down the line.
3a25b11 to
bbb641c
Compare
52f87ad to
fa8ee6b
Compare
bbb641c to
c1ffe04
Compare
labbott
left a comment
There was a problem hiding this comment.
Part of me really wants to have a separate binary for dealing with humility dumps simply so the logic here isn't so complicated. I have convinced myself this is fine but it should probably be spot checked against our lab machines for good measure.
| // dump. If the user has specified no command line options but | ||
| // multiple of these in the environment, they will get the first in | ||
| // this ordering that we find. | ||
| if cli.dump.is_none() |
There was a problem hiding this comment.
As noted in the rework RFD, i would like to get rid of environments and just have other tooling set HUMILITY_PROBE and HUMILITY_ARCHIVE as appropriate. Environments solved an actual problem for us but I do not think the belong in a humility binary.
c1ffe04 to
17f9a92
Compare
fa8ee6b to
2b6fcbb
Compare
a32ff10 to
840972b
Compare
840972b to
f1ce3d7
Compare
(staged on #666)
ExecutionContext::newis a weird function: it usually builds anExecutionContext, but sometimes bails out unceremoniously withstd::process::exit. This is because it's also handling a final set of subcommands-as-cli-flags, e.g.--list-targets.In this PR, we move all of that logic into
humility-bin, which is already designed to exit with astd::process::ExitCode(instead of callingexit(..)directly).Logic should be the same, but this moves
--list-targetshandling earlier (which should fix #597).