mirror of
https://github.com/transmission/transmission
synced 2025-03-10 14:13:23 +00:00
(trunk utils) add support for --version/-V
This commit is contained in:
parent
cbf51842c8
commit
ac9dd13ee0
3 changed files with 34 additions and 5 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <libtransmission/makemeta.h>
|
#include <libtransmission/makemeta.h>
|
||||||
#include <libtransmission/tr-getopt.h>
|
#include <libtransmission/tr-getopt.h>
|
||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
|
#include <libtransmission/version.h>
|
||||||
|
|
||||||
#define MY_NAME "transmission-create"
|
#define MY_NAME "transmission-create"
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
static tr_tracker_info trackers[MAX_TRACKERS];
|
static tr_tracker_info trackers[MAX_TRACKERS];
|
||||||
static int trackerCount = 0;
|
static int trackerCount = 0;
|
||||||
static tr_bool isPrivate = FALSE;
|
static tr_bool isPrivate = FALSE;
|
||||||
|
static tr_bool showVersion = FALSE;
|
||||||
const char * comment = NULL;
|
const char * comment = NULL;
|
||||||
const char * outfile = NULL;
|
const char * outfile = NULL;
|
||||||
const char * infile = NULL;
|
const char * infile = NULL;
|
||||||
|
@ -34,6 +36,7 @@ static tr_option options[] =
|
||||||
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "<file>" },
|
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "<file>" },
|
||||||
{ 'c', "comment", "Add a comment", "c", 1, "<comment>" },
|
{ 'c', "comment", "Add a comment", "c", 1, "<comment>" },
|
||||||
{ 't', "tracker", "Add a tracker's announce URL", "t", 1, "<url>" },
|
{ 't', "tracker", "Add a tracker's announce URL", "t", 1, "<url>" },
|
||||||
|
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ parseCommandLine( int argc, const char ** argv )
|
||||||
{
|
{
|
||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
|
case 'V': showVersion = TRUE; break;
|
||||||
case 'p': isPrivate = TRUE; break;
|
case 'p': isPrivate = TRUE; break;
|
||||||
case 'o': outfile = optarg; break;
|
case 'o': outfile = optarg; break;
|
||||||
case 'c': comment = optarg; break;
|
case 'c': comment = optarg; break;
|
||||||
|
@ -94,6 +98,11 @@ main( int argc, char * argv[] )
|
||||||
if( parseCommandLine( argc, (const char**)argv ) )
|
if( parseCommandLine( argc, (const char**)argv ) )
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if( showVersion ) {
|
||||||
|
fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( !infile )
|
if( !infile )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: No input file or directory specified.\n" );
|
fprintf( stderr, "ERROR: No input file or directory specified.\n" );
|
||||||
|
|
21
utils/edit.c
21
utils/edit.c
|
@ -18,20 +18,23 @@
|
||||||
#include <libtransmission/bencode.h>
|
#include <libtransmission/bencode.h>
|
||||||
#include <libtransmission/tr-getopt.h>
|
#include <libtransmission/tr-getopt.h>
|
||||||
#include <libtransmission/utils.h>
|
#include <libtransmission/utils.h>
|
||||||
|
#include <libtransmission/version.h>
|
||||||
|
|
||||||
#define MY_NAME "transmission-edit"
|
#define MY_NAME "transmission-edit"
|
||||||
|
|
||||||
int fileCount = 0;
|
static int fileCount = 0;
|
||||||
const char ** files = NULL;
|
static tr_bool showVersion = FALSE;
|
||||||
const char * add = NULL;
|
static const char ** files = NULL;
|
||||||
const char * deleteme = NULL;
|
static const char * add = NULL;
|
||||||
const char * replace[2] = { NULL, NULL };
|
static const char * deleteme = NULL;
|
||||||
|
static const char * replace[2] = { NULL, NULL };
|
||||||
|
|
||||||
static tr_option options[] =
|
static tr_option options[] =
|
||||||
{
|
{
|
||||||
{ 'a', "add", "Add a tracker's announce URL", "a", 1, "<url>" },
|
{ 'a', "add", "Add a tracker's announce URL", "a", 1, "<url>" },
|
||||||
{ 'd', "delete", "Delete a tracker's announce URL", "d", 1, "<url>" },
|
{ 'd', "delete", "Delete a tracker's announce URL", "d", 1, "<url>" },
|
||||||
{ 'r', "replace", "Search and replace a substring in the announce URLs", "r", 1, "<old> <new>" },
|
{ 'r', "replace", "Search and replace a substring in the announce URLs", "r", 1, "<old> <new>" },
|
||||||
|
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,6 +63,8 @@ parseCommandLine( int argc, const char ** argv )
|
||||||
if( c != TR_OPT_UNK ) return 1;
|
if( c != TR_OPT_UNK ) return 1;
|
||||||
replace[1] = optarg;
|
replace[1] = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'V': showVersion = TRUE;
|
||||||
|
break;
|
||||||
case TR_OPT_UNK: files[fileCount++] = optarg; break;
|
case TR_OPT_UNK: files[fileCount++] = optarg; break;
|
||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +263,12 @@ main( int argc, char * argv[] )
|
||||||
if( parseCommandLine( argc, (const char**)argv ) )
|
if( parseCommandLine( argc, (const char**)argv ) )
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if( showVersion )
|
||||||
|
{
|
||||||
|
fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( fileCount < 1 )
|
if( fileCount < 1 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: No torrent files specified.\n" );
|
fprintf( stderr, "ERROR: No torrent files specified.\n" );
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
static tr_option options[] =
|
static tr_option options[] =
|
||||||
{
|
{
|
||||||
{ 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL },
|
{ '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 }
|
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ getUsage( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
static tr_bool scrapeFlag = FALSE;
|
static tr_bool scrapeFlag = FALSE;
|
||||||
|
static tr_bool showVersion = FALSE;
|
||||||
const char * filename = NULL;
|
const char * filename = NULL;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -74,6 +76,7 @@ parseCommandLine( int argc, const char ** argv )
|
||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case 's': scrapeFlag = TRUE; break;
|
case 's': scrapeFlag = TRUE; break;
|
||||||
|
case 'V': showVersion = TRUE; break;
|
||||||
case TR_OPT_UNK: filename = optarg; break;
|
case TR_OPT_UNK: filename = optarg; break;
|
||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +261,12 @@ main( int argc, char * argv[] )
|
||||||
if( parseCommandLine( argc, (const char**)argv ) )
|
if( parseCommandLine( argc, (const char**)argv ) )
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if( showVersion )
|
||||||
|
{
|
||||||
|
fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure the user specified a filename */
|
/* make sure the user specified a filename */
|
||||||
if( !filename )
|
if( !filename )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue