@@ -15,11 +15,15 @@ pub fn metadata() -> Command {
1515 Command :: new ( "plugins" )
1616 . subcommand_required ( true )
1717 . subcommands ( [
18- Command :: new ( "list" )
19- . alias ( "ls" )
20- . args ( [ Arg :: new ( "plugin_name" )
18+ Command :: new ( "list" ) . alias ( "ls" ) . args ( [
19+ Arg :: new ( "plugin_name" )
2120 . help ( "name of the plugin as an additional filter" )
22- . action ( ArgAction :: Set ) ] ) ,
21+ . action ( ArgAction :: Set ) ,
22+ Arg :: new ( "wide" )
23+ . help ( "show a wide table" )
24+ . long ( "wide" )
25+ . action ( ArgAction :: SetTrue ) ,
26+ ] ) ,
2327 Command :: new ( "clean" ) . alias ( "purge" ) ,
2428 Command :: new ( "remove" )
2529 . alias ( "rm" )
@@ -32,8 +36,13 @@ pub fn metadata() -> Command {
3236pub async fn handle ( matches : & ArgMatches ) -> Result < ( ) > {
3337 match matches. subcommand ( ) {
3438 Some ( ( "list" , matches) ) => {
35- super :: print_plugin_versions_header ( ) ;
36- list_local_plugins ( matches. get_one :: < String > ( "plugin_name" ) . map ( String :: as_str) ) . await
39+ let wide = matches. get_flag ( "wide" ) ;
40+ print_local_plugin_header ( wide) ;
41+ list_local_plugins (
42+ matches. get_one :: < String > ( "plugin_name" ) . map ( String :: as_str) ,
43+ wide,
44+ )
45+ . await
3746 }
3847 Some ( ( "remove" , matches) ) => {
3948 let plugin_uris = matches
@@ -62,7 +71,23 @@ pub async fn handle(matches: &ArgMatches) -> Result<()> {
6271 }
6372}
6473
65- async fn list_local_plugins ( plugin_name : Option < & str > ) -> Result < ( ) > {
74+ #[ allow( clippy:: print_literal) ]
75+ #[ inline]
76+ fn print_local_plugin_header ( wide : bool ) {
77+ if !wide {
78+ println ! (
79+ "{0: <16} {1: <16} {2: <12} {3: <4} {4: <8}" ,
80+ "NAME" , "VERSION" , "ARCH" , "ABI" , "DIGEST"
81+ ) ;
82+ } else {
83+ println ! (
84+ "{0: <16} {1: <16} {2: <12} {3: <4} {4: <8} {5: <65} {6:} {7: <64?}" ,
85+ "NAME" , "VERSION" , "ARCH" , "ABI" , "DIGEST" , "DIGEST_LONG" , "CREATED" , "PATH"
86+ ) ;
87+ }
88+ }
89+
90+ async fn list_local_plugins ( plugin_name : Option < & str > , wide : bool ) -> Result < ( ) > {
6691 let plugins = util:: local_plugins ( ) . await ?;
6792 for plugin in plugins. into_iter ( ) {
6893 // optionally filter by plugin name
@@ -72,20 +97,36 @@ async fn list_local_plugins(plugin_name: Option<&str>) -> Result<()> {
7297 }
7398 }
7499
75- println ! (
76- "{0: <16} {1: <16} {2: <12} {3: <4} {4: <8} {5: <65} {6:}" ,
77- plugin. descriptor. name,
78- plugin. descriptor. version,
79- format!(
80- "{:?}/{:?}" ,
81- plugin. descriptor. file_type, plugin. descriptor. architecture
82- )
83- . to_ascii_lowercase( ) ,
84- plugin. descriptor. plugin_version,
85- & plugin. digest[ ..7 ] ,
86- plugin. digest,
87- plugin. created_at,
88- ) ;
100+ if !wide {
101+ println ! (
102+ "{0: <16} {1: <16} {2: <12} {3: <4} {4: <8}" ,
103+ plugin. descriptor. name,
104+ plugin. descriptor. version,
105+ format!(
106+ "{:?}/{:?}" ,
107+ plugin. descriptor. file_type, plugin. descriptor. architecture
108+ )
109+ . to_ascii_lowercase( ) ,
110+ plugin. descriptor. plugin_version,
111+ & plugin. digest[ ..7 ] ,
112+ ) ;
113+ } else {
114+ println ! (
115+ "{0: <16} {1: <16} {2: <12} {3: <4} {4: <8} {5: <65} {6:} {7: <64?}" ,
116+ plugin. descriptor. name,
117+ plugin. descriptor. version,
118+ format!(
119+ "{:?}/{:?}" ,
120+ plugin. descriptor. file_type, plugin. descriptor. architecture
121+ )
122+ . to_ascii_lowercase( ) ,
123+ plugin. descriptor. plugin_version,
124+ & plugin. digest[ ..7 ] ,
125+ plugin. digest,
126+ plugin. created_at,
127+ plugin. plugin_file_name,
128+ ) ;
129+ }
89130 }
90131 Ok ( ( ) )
91132}
0 commit comments