@@ -34,7 +34,7 @@ static int help(int argc, char **argv, struct plugin *plugin)
3434 int i ;
3535
3636 if (argc == 1 ) {
37- general_help (plugin );
37+ general_help (plugin , NULL );
3838 return 0 ;
3939 }
4040
@@ -52,6 +52,9 @@ static int help(int argc, char **argv, struct plugin *plugin)
5252 if (execlp ("man" , "man" , man , (char * )NULL ))
5353 perror (argv [1 ]);
5454 }
55+
56+ general_help (plugin , str );
57+
5558 return 0 ;
5659}
5760
@@ -65,7 +68,7 @@ static void usage_cmd(struct plugin *plugin)
6568 printf ("usage: %s %s\n" , prog -> name , prog -> usage );
6669}
6770
68- void general_help (struct plugin * plugin )
71+ void general_help (struct plugin * plugin , char * str )
6972{
7073 struct program * prog = plugin -> parent ;
7174 struct plugin * extension ;
@@ -88,6 +91,8 @@ void general_help(struct plugin *plugin)
8891 }
8992
9093 printf ("\nThe following are all implemented sub-commands:\n" );
94+ if (str )
95+ printf ("Note: Only sub-commands including %s\n" , str );
9196
9297 /*
9398 * iterate through all commands to get maximum length
@@ -100,12 +105,16 @@ void general_help(struct plugin *plugin)
100105 }
101106
102107 i = 0 ;
103- for (; plugin -> commands [i ]; i ++ )
104- printf (" %-*s %s\n" , padding , plugin -> commands [i ]-> name ,
105- plugin -> commands [i ]-> help );
108+ for (; plugin -> commands [i ]; i ++ ) {
109+ if (!str || strstr (plugin -> commands [i ]-> name , str ))
110+ printf (" %-*s %s\n" , padding , plugin -> commands [i ]-> name ,
111+ plugin -> commands [i ]-> help );
112+ }
106113
107- printf (" %-*s %s\n" , padding , "version" , "Shows the program version" );
108- printf (" %-*s %s\n" , padding , "help" , "Display this help" );
114+ if (!str || strstr ("version" , str ))
115+ printf (" %-*s %s\n" , padding , "version" , "Shows the program version" );
116+ if (!str || strstr ("help" , str ))
117+ printf (" %-*s %s\n" , padding , "help" , "Display this help" );
109118 printf ("\n" );
110119
111120 if (plugin -> name )
@@ -127,8 +136,12 @@ void general_help(struct plugin *plugin)
127136 return ;
128137
129138 printf ("\nThe following are all installed plugin extensions:\n" );
139+ if (str )
140+ printf ("Note: Only extensions including %s\n" , str );
141+
130142 while (extension ) {
131- printf (" %-*s %s\n" , 15 , extension -> name , extension -> desc );
143+ if (!str || strstr (extension -> name , str ))
144+ printf (" %-*s %s\n" , 15 , extension -> name , extension -> desc );
132145 extension = extension -> next ;
133146 }
134147 printf ("\nSee '%s <plugin> help' for more information on a plugin\n" ,
@@ -147,7 +160,7 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin)
147160 int dash_count = 0 ;
148161
149162 if (!argc ) {
150- general_help (plugin );
163+ general_help (plugin , NULL );
151164 return 0 ;
152165 }
153166
0 commit comments