Conversation
swadm/src/link.rs
Outdated
| Ok(()) | ||
| } | ||
|
|
||
| fn fmt_time(mut ms: i64) -> String { |
There was a problem hiding this comment.
lol, a recurring theme this. Maybe we should have this in some common crate. Definitely do not want a dependency to mg-common from dendrite for this. It's unfortunate that the humantime crate does not seem to support not printing durations down to the nanosecond.
There was a problem hiding this comment.
I would recommend we use humantime or something similar wherever we need this sort of thing.
There was a problem hiding this comment.
Done:
root@oxz_switch0:~# ./swadm link history rear14/0
Time Class Subclass Channel Details
51m 5s 422ms PortFSM LinkUp -
51m 5s 533ms PortFSM LinkDown -
51m 5s 791ms PortFSM WaitAutoNegLinkTrainingDone -
51m 5s 964ms MediaFSM LinkDown -
51m 6s 40ms PortFSM WaitAutoNegDone -
51m 6s 58ms LinkAdmin Enable -
51m 6s 58ms MediaFSM WaitLinkSt -
51m 6s 947ms MediaFSM MediaDetected -
51m 7s 279ms QsfpFSM Detected -
51m 12s 847ms QsfpFSM Inserted -
51m 18s 230ms LinkAdmin Create - speed: 100G fec: RS
| .await | ||
| .context("failed to list all links")? | ||
| .into_inner(); | ||
| if !filter.is_empty() { |
There was a problem hiding this comment.
Feels like we need to update this block to operate on known matching links? swadm link ls rear3 blah would still succeed, right? We should consider tracking which filters actually matched at least one link and warn/err on unused ones.
There was a problem hiding this comment.
I think you could argue that it's an error unless each of the filters matches something, or a success if any of the filters match anything. My preference is really to have no errors, and a failure to match just gives you an empty result.
@rmustacc filed the issue, and I think he might be asking for the same thing you are, so I'll let him make the final call.
There was a problem hiding this comment.
Yeah, I was going off the text in the issue too.
fixes #79 Add ls -> list alias for arp subcommand
fixes #121 swadm link history could report better timestamps for link events
fixes #221 swadm link ls filter matching