better --help output for vips driver prog

now lists possible actions
This commit is contained in:
John Cupitt 2012-11-13 12:51:58 +00:00
parent f561785274
commit fdaad16407
3 changed files with 53 additions and 8 deletions

View File

@ -17,7 +17,8 @@
- dzsave --layout google has a @background option
- dzsave has a --depth option
- update for new glib threading API
- remove no threads option
- remove no threads option, glib no longer support it
- better --help output for vips driver prog
2/10/12 started 7.30.4
- remove options from format string in .dzi (thanks Martin)

16
TODO
View File

@ -1,3 +1,19 @@
- have a web page with a list of the python member names
$ vips cpph all | grep join
VImage bandjoin( VImage bandjoin_in2 ) throw( VError );
static VImage
gbandjoin( std::vector<VImage> gbandjoin_in ) throw( VError );
VImage lrjoin( VImage lrjoin_in2 ) throw( VError );
VImage tbjoin( VImage tbjoin_in2 ) throw( VError );
could generate some docs too?
perhaps it should be part of vips.c
- quadratic doesn't work for order 3
start to get jaggies on lines --- the 3rd differential isn't being

View File

@ -905,6 +905,20 @@ print_cppdefs( int argc, char **argv )
return( 0 );
}
static void action_list( VipsBuf *buf );
static int
print_help( int argc, char **argv )
{
char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt );
action_list( &buf );
printf( "%s", vips_buf_all( &buf ) );
return( 0 );
}
/* All our built-in actions.
*/
@ -930,11 +944,28 @@ static ActionEntry actions[] = {
&empty_options[0], print_cppdefs },
{ "links", N_( "generate links for vips/bin" ),
&empty_options[0], print_links },
{ "help", N_( "list possible actions" ),
&empty_options[0], print_help },
};
static void
action_list( VipsBuf *buf )
{
int i;
vips_buf_appends( buf, _( "possible actions:\n" ) );
for( i = 0; i < VIPS_NUMBER( actions ); i++ )
vips_buf_appendf( buf, "%7s - %s\n",
actions[i].name, _( actions[i].description ) );
vips_buf_appendf( buf, "%7s - %s\n",
"OP", _( "execute vips operation OP" ) );
}
static void
parse_options( GOptionContext *context, int *argc, char **argv )
{
char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt );
GError *error = NULL;
int i, j;
@ -944,6 +975,9 @@ parse_options( GOptionContext *context, int *argc, char **argv )
printf( "%d) %s\n", i, argv[i] );
#endif /*DEBUG*/
action_list( &buf );
g_option_context_set_summary( context, vips_buf_all( &buf ) );
if( !g_option_context_parse( context, argc, &argv, &error ) ) {
if( error ) {
fprintf( stderr, "%s\n", error->message );
@ -1128,13 +1162,7 @@ main( int argc, char **argv )
if( action &&
!handled ) {
printf( "%s", _( "possible actions:\n" ) );
for( i = 0; i < VIPS_NUMBER( actions ); i++ )
printf( "%10s - %s\n",
actions[i].name, _( actions[i].description ) );
printf( "%10s - %s\n",
"<operation>", _( "execute named vips operation" ) );
print_help( argc, argv );
error_exit( _( "unknown action \"%s\"" ), action );
}