@@ -22,37 +22,41 @@ fn collection_templates_and_features(oci_reference: &str, collection: &Collectio
2222 println ! ( "Repository: {}" , & source_information. repository) ;
2323 println ! ( "OCI Reference: {}" , & source_information. oci_reference) ;
2424
25- let search_results = {
26- let features = collection. features . iter ( ) . map ( search:: SearchResult :: from) ;
27- let templates = collection. templates . iter ( ) . map ( search:: SearchResult :: from) ;
28- features. chain ( templates)
29- } ;
30- let data: Vec < [ String ; 5 ] > = search_results
31- . enumerate ( )
32- . map ( |( i, r) | {
33- let description = r
34- . description
35- . as_ref ( )
36- . and_then ( |d| d. lines ( ) . next ( ) )
37- . unwrap_or_default ( ) ;
38- [
39- ( i + 1 ) . to_string ( ) ,
40- r. collection . to_string ( ) ,
41- r. id . replace ( oci_reference, "~" ) ,
42- r. name . to_string ( ) ,
43- description. to_string ( ) ,
44- ]
45- } )
46- . collect ( ) ;
47- let mut table = ascii_table:: AsciiTable :: default ( ) ;
48-
49- table. column ( 0 ) . set_align ( ascii_table:: Align :: Right ) ;
50- table. column ( 1 ) . set_header ( "Type" ) ;
51- table. column ( 2 ) . set_header ( "OCI Reference" ) ;
52- table. column ( 3 ) . set_header ( "Name" ) . set_max_width ( 40 ) ;
53- table. column ( 4 ) . set_header ( "Description" ) . set_max_width ( 75 ) ;
54-
55- table. print ( data) ;
25+ let count = collection. features . len ( ) + collection. templates . len ( ) ;
26+
27+ if count > 0 {
28+ let search_results = {
29+ let features = collection. features . iter ( ) . map ( search:: SearchResult :: from) ;
30+ let templates = collection. templates . iter ( ) . map ( search:: SearchResult :: from) ;
31+ features. chain ( templates)
32+ } ;
33+ let data: Vec < [ String ; 5 ] > = search_results
34+ . enumerate ( )
35+ . map ( |( i, r) | {
36+ let description = r
37+ . description
38+ . as_ref ( )
39+ . and_then ( |d| d. lines ( ) . next ( ) )
40+ . unwrap_or_default ( ) ;
41+ [
42+ ( i + 1 ) . to_string ( ) ,
43+ r. collection . to_string ( ) ,
44+ r. id . replace ( oci_reference, "~" ) ,
45+ r. name . to_string ( ) ,
46+ description. to_string ( ) ,
47+ ]
48+ } )
49+ . collect ( ) ;
50+ let mut table = ascii_table:: AsciiTable :: default ( ) ;
51+
52+ table. column ( 0 ) . set_align ( ascii_table:: Align :: Right ) ;
53+ table. column ( 1 ) . set_header ( "Type" ) ;
54+ table. column ( 2 ) . set_header ( "OCI Reference" ) ;
55+ table. column ( 3 ) . set_header ( "Name" ) . set_max_width ( 40 ) ;
56+ table. column ( 4 ) . set_header ( "Description" ) . set_max_width ( 75 ) ;
57+
58+ table. print ( data) ;
59+ }
5660}
5761
5862fn overview_collections ( index : & DevcontainerIndex ) {
0 commit comments