@@ -172,7 +172,7 @@ async fn run_set(args: AliasSetArgs) -> Result<()> {
172172
173173 println ! ( "Alias '{}' set to: {}" , args. name, args. command) ;
174174 if let Some ( desc) = & args. description {
175- println ! ( " Description: {} " , desc) ;
175+ print_multiline_description ( " Description: " , " ", desc) ;
176176 }
177177
178178 Ok ( ( ) )
@@ -203,7 +203,7 @@ async fn run_list(args: AliasListArgs) -> Result<()> {
203203 for alias in aliases {
204204 println ! ( " {} = {}" , alias. name, alias. command) ;
205205 if let Some ( desc) = & alias. description {
206- println ! ( " {} " , desc) ;
206+ print_multiline_description ( " " , " ", desc) ;
207207 }
208208 }
209209
@@ -265,12 +265,42 @@ async fn run_show(args: AliasShowArgs) -> Result<()> {
265265 println ! ( "{}" , "-" . repeat( 40 ) ) ;
266266 println ! ( " Command: {}" , alias. command) ;
267267 if let Some ( desc) = & alias. description {
268- println ! ( " Description: {} " , desc) ;
268+ print_multiline_description ( " Description: " , " ", desc) ;
269269 }
270270
271271 Ok ( ( ) )
272272}
273273
274+ fn format_multiline_description (
275+ first_prefix : & str ,
276+ continuation_prefix : & str ,
277+ desc : & str ,
278+ ) -> String {
279+ let mut output = String :: new ( ) ;
280+
281+ for ( index, line) in desc. lines ( ) . enumerate ( ) {
282+ if index > 0 {
283+ output. push ( '\n' ) ;
284+ }
285+
286+ if index == 0 {
287+ output. push_str ( first_prefix) ;
288+ } else {
289+ output. push_str ( continuation_prefix) ;
290+ }
291+ output. push_str ( line) ;
292+ }
293+
294+ output
295+ }
296+
297+ fn print_multiline_description ( first_prefix : & str , continuation_prefix : & str , desc : & str ) {
298+ println ! (
299+ "{}" ,
300+ format_multiline_description( first_prefix, continuation_prefix, desc)
301+ ) ;
302+ }
303+
274304#[ cfg( test) ]
275305mod tests {
276306 use super :: * ;
@@ -299,6 +329,25 @@ mod tests {
299329 ) ;
300330 }
301331
332+ #[ test]
333+ fn test_format_multiline_description_indents_every_line ( ) {
334+ let formatted =
335+ format_multiline_description ( " " , " " , "First line\n Second line\n Third line" ) ;
336+
337+ assert_eq ! (
338+ formatted,
339+ " First line\n Second line\n Third line"
340+ ) ;
341+ }
342+
343+ #[ test]
344+ fn test_format_multiline_description_uses_continuation_prefix ( ) {
345+ let formatted =
346+ format_multiline_description ( " Description: " , " " , "First\n Second" ) ;
347+
348+ assert_eq ! ( formatted, " Description: First\n Second" ) ;
349+ }
350+
302351 #[ test]
303352 fn test_alias_definition_without_description_json_roundtrip ( ) {
304353 let alias = AliasDefinition {
0 commit comments