1
- use std:: { io:: stdout, path:: PathBuf } ;
1
+ use std:: { borrow :: Cow , io:: stdout, path:: PathBuf } ;
2
2
3
3
use clap:: Args ;
4
4
use clap_complete:: ArgValueCompleter ;
5
- use dialoguer:: console:: style;
5
+ use dialoguer:: console:: { StyledObject , style} ;
6
6
use oma_console:: indicatif:: HumanBytes ;
7
7
use oma_pm:: {
8
8
apt:: { AptConfig , OmaApt , OmaAptArgs } ,
@@ -169,9 +169,9 @@ fn display_records(stdout: &mut std::io::Stdout, pkg: &OmaPackage, apt: &OmaApt)
169
169
}
170
170
171
171
let i = if * i == RecordField :: Size {
172
- style ( "Download-Size:" ) . bold ( ) . to_string ( )
172
+ key_style ( Cow :: Borrowed ( "Download-Size:" ) )
173
173
} else {
174
- style ( format ! ( "{i}:" ) ) . bold ( ) . to_string ( )
174
+ key_style ( format ! ( "{i}:" ) . into ( ) )
175
175
} ;
176
176
177
177
writeln ! ( stdout, "{i} {v}" ) . ok ( ) ;
@@ -182,7 +182,7 @@ fn display_records(stdout: &mut std::io::Stdout, pkg: &OmaPackage, apt: &OmaApt)
182
182
. map ( AptSource :: from)
183
183
. collect :: < Vec < _ > > ( ) ;
184
184
185
- write ! ( stdout, "{}" , style ( "APT-Sources:" ) . bold ( ) ) . ok ( ) ;
185
+ write ! ( stdout, "{}" , key_style ( "APT-Sources:" . into ( ) ) ) . ok ( ) ;
186
186
let apt_sources_without_dpkg = apt_sources
187
187
. iter ( )
188
188
. filter ( |x| x. index_type . as_deref ( ) != Some ( "Debian dpkg status file" ) )
@@ -204,11 +204,16 @@ fn display_records(stdout: &mut std::io::Stdout, pkg: &OmaPackage, apt: &OmaApt)
204
204
}
205
205
206
206
if version. is_installed ( ) {
207
- write ! ( stdout, "{}" , style ( "APT-Manual-Installed: " ) . bold ( ) ) . ok ( ) ;
207
+ write ! ( stdout, "{}" , key_style ( "APT-Manual-Installed: " . into ( ) ) ) . ok ( ) ;
208
208
if version. parent ( ) . is_auto_installed ( ) {
209
209
writeln ! ( stdout, "no" ) . ok ( ) ;
210
210
} else {
211
211
writeln ! ( stdout, "yes" ) . ok ( ) ;
212
212
}
213
213
}
214
214
}
215
+
216
+ #[ inline]
217
+ fn key_style ( key : Cow < str > ) -> StyledObject < Cow < str > > {
218
+ style ( key) . bold ( )
219
+ }
0 commit comments