11use crate :: exp:: Exp ;
22use crate :: token:: { Token , Tokenizer } ;
33use crate :: utils:: { random_value, str_to_principal} ;
4- use ansi_term:: Color ;
54use candid:: {
65 types:: value:: { IDLField , IDLValue , VariantValue } ,
76 types:: { Function , Label , Type , TypeInner } ,
@@ -90,7 +89,6 @@ pub struct MyHelper {
9089 pub env : Env ,
9190 pub func_env : FuncEnv ,
9291 pub base_path : std:: path:: PathBuf ,
93- pub history : Vec < String > ,
9492 pub messages : RefCell < Vec < crate :: offline:: IngressWithStatus > > ,
9593}
9694
@@ -102,7 +100,6 @@ impl MyHelper {
102100 hinter : HistoryHinter { } ,
103101 colored_prompt : "" . to_owned ( ) ,
104102 validator : MatchingBracketValidator :: new ( ) ,
105- history : Vec :: new ( ) ,
106103 config : Configs :: from_dhall ( "{=}" ) . unwrap ( ) ,
107104 canister_map : self . canister_map . clone ( ) ,
108105 identity_map : self . identity_map . clone ( ) ,
@@ -130,7 +127,6 @@ impl MyHelper {
130127 env : Env :: default ( ) ,
131128 func_env : FuncEnv :: default ( ) ,
132129 base_path : std:: env:: current_dir ( ) . unwrap ( ) ,
133- history : Vec :: new ( ) ,
134130 messages : Vec :: new ( ) . into ( ) ,
135131 agent,
136132 agent_url,
@@ -448,7 +444,7 @@ impl Highlighter for MyHelper {
448444 }
449445
450446 fn highlight_hint < ' h > ( & self , hint : & ' h str ) -> Cow < ' h , str > {
451- let s = format ! ( "{}" , Color :: White . dimmed ( ) . paint ( hint ) ) ;
447+ let s = format ! ( "{}" , console :: style ( hint ) . black ( ) . bright ( ) ) ;
452448 Owned ( s)
453449 }
454450
@@ -577,6 +573,19 @@ pub fn find_init_args(env: &TypeEnv, actor: &Type) -> Option<Vec<Type>> {
577573 }
578574}
579575
576+ impl Env {
577+ pub fn dump_principals ( & self ) -> BTreeMap < String , String > {
578+ self . 0
579+ . iter ( )
580+ . filter_map ( |( name, value) | match value {
581+ IDLValue :: Principal ( id) => Some ( ( name, id) ) ,
582+ _ => None ,
583+ } )
584+ . map ( |( name, id) | ( name. clone ( ) , id. to_text ( ) ) )
585+ . collect ( )
586+ }
587+ }
588+
580589#[ test]
581590fn test_partial_parse ( ) -> anyhow:: Result < ( ) > {
582591 use candid_parser:: parse_idl_value;
0 commit comments