Changeset 11160 for trunk/utils/edit.c


Ignore:
Timestamp:
Aug 8, 2010, 10:53:24 PM (12 years ago)
Author:
charles
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/edit.c

    r10808 r11160  
    1919#include <libtransmission/tr-getopt.h>
    2020#include <libtransmission/utils.h>
     21#include <libtransmission/version.h>
    2122
    2223#define MY_NAME "transmission-edit"
    2324
    24 int fileCount = 0;
    25 const char ** files = NULL;
    26 const char * add = NULL;
    27 const char * deleteme = NULL;
    28 const char * replace[2] = { NULL, NULL };
     25static int fileCount = 0;
     26static tr_bool showVersion = FALSE;
     27static const char ** files = NULL;
     28static const char * add = NULL;
     29static const char * deleteme = NULL;
     30static const char * replace[2] = { NULL, NULL };
    2931
    3032static tr_option options[] =
     
    3335  { 'd', "delete", "Delete a tracker's announce URL", "d", 1, "<url>" },
    3436  { 'r', "replace", "Search and replace a substring in the announce URLs", "r", 1, "<old> <new>" },
     37  { 'V', "version", "Show version number and exit", "V", 0, NULL },
    3538  { 0, NULL, NULL, NULL, 0, NULL }
    3639};
     
    6063                      if( c != TR_OPT_UNK ) return 1;
    6164                      replace[1] = optarg;
     65                      break;
     66            case 'V': showVersion = TRUE;
    6267                      break;
    6368            case TR_OPT_UNK: files[fileCount++] = optarg; break;
     
    259264        return EXIT_FAILURE;
    260265
     266    if( showVersion )
     267    {
     268        fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" );
     269        return 0;
     270    }
     271
    261272    if( fileCount < 1 )
    262273    {
Note: See TracChangeset for help on using the changeset viewer.