@@ -206,7 +206,7 @@ use humility::core::Core;
206206use humility:: hubris:: * ;
207207use humility:: reflect:: { self , Load , Value } ;
208208use humility_cli:: ExecutionContext ;
209- use humility_cmd:: { Archive , Attach , Command , CommandKind , Validate } ;
209+ use humility_cmd:: Command ;
210210use humility_doppel:: { CountedRingbuf , CounterVariant , Counters } ;
211211use indexmap:: IndexMap ;
212212use std:: collections:: BTreeMap ;
@@ -324,12 +324,11 @@ const LIST_HINT: &str = "use `humility counters list` to list all \
324324 available counters";
325325
326326fn counters ( context : & mut ExecutionContext ) -> Result < ( ) > {
327- let core = & mut * * context. core . as_mut ( ) . unwrap ( ) ;
328- let hubris = context. archive . as_ref ( ) . unwrap ( ) ;
329-
327+ let hubris = & context. cli . archive ( ) ?;
330328 let subargs = CountersArgs :: try_parse_from ( & context. cli . cmd ) ?;
331329
332330 if let Some ( Subcmd :: Ipc ( ipc) ) = subargs. command {
331+ let core = & mut * context. cli . attach_live_or_dump_match ( hubris) ?;
333332 return ipc. ipc_counter_dump ( hubris, core) ;
334333 }
335334 let name = subargs. name ( ) ;
@@ -428,6 +427,7 @@ fn counters(context: &mut ExecutionContext) -> Result<()> {
428427 }
429428
430429 let mut json: IndexMap < & str , IndexMap < _ , _ > > = IndexMap :: new ( ) ;
430+ let core = & mut * context. cli . attach_live_or_dump_match ( hubris) ?;
431431 for ( t, ctrs) in counters {
432432 // Try not to use `?` here, because it causes one bad counter to make
433433 // them all unavailable. Instead, construct an iterator of
@@ -623,14 +623,5 @@ fn hint() -> impl std::fmt::Display {
623623}
624624
625625pub fn init ( ) -> Command {
626- Command {
627- app : CountersArgs :: command ( ) ,
628- name : "counters" ,
629- run : counters,
630- kind : CommandKind :: Attached {
631- archive : Archive :: Required ,
632- attach : Attach :: Any ,
633- validate : Validate :: Match ,
634- } ,
635- }
626+ Command { app : CountersArgs :: command ( ) , name : "counters" , run : counters }
636627}
0 commit comments