(trunk utils) add support for --version/-V

This commit is contained in:
Charles Kerr
2010-08-08 22:53:24 +00:00
parent cbf51842c8
commit ac9dd13ee0
3 changed files with 34 additions and 5 deletions

View File

@@ -51,6 +51,7 @@
static tr_option options[] =
{
{ 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL },
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
{ 0, NULL, NULL, NULL, 0, NULL }
};
@@ -61,6 +62,7 @@ getUsage( void )
}
static tr_bool scrapeFlag = FALSE;
static tr_bool showVersion = FALSE;
const char * filename = NULL;
static int
@@ -74,6 +76,7 @@ parseCommandLine( int argc, const char ** argv )
switch( c )
{
case 's': scrapeFlag = TRUE; break;
case 'V': showVersion = TRUE; break;
case TR_OPT_UNK: filename = optarg; break;
default: return 1;
}
@@ -258,6 +261,12 @@ main( int argc, char * argv[] )
if( parseCommandLine( argc, (const char**)argv ) )
return EXIT_FAILURE;
if( showVersion )
{
fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" );
return 0;
}
/* make sure the user specified a filename */
if( !filename )
{