From: <ny...@us...> - 2007-02-07 12:33:43
|
Revision: 305 http://svn.sourceforge.net/pmplib/?rev=305&view=rev Author: nyaochi Date: 2007-02-07 04:33:41 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Updated cmmand-line options Modified Paths: -------------- trunk/pmplib/frontend/easypmp/common/easypmp.h trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/frontend/easypmp/cui/option.h Modified: trunk/pmplib/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-02-06 18:12:00 UTC (rev 304) +++ trunk/pmplib/frontend/easypmp/common/easypmp.h 2007-02-07 12:33:41 UTC (rev 305) @@ -69,18 +69,19 @@ #define MAKE_PMP_ERROR(code) (((code) << 16) | EASYPMPE_PMPERROR) enum { - MODE_NONE = 0, - MODE_DATABASE = 0x00000001, + MODE_NONE = 0, + MODE_DATABASE = 0x00000001, MODE_DATABASE_UPDATE = 0x00000002, MODE_DATABASE_REPR = 0x00000004, - MODE_PLAYLIST = 0x00000010, + MODE_PLAYLIST = 0x00000010, MODE_PLAYLIST_RECONVERT = 0x00000100, MODE_PLAYLIST_FIND = 0x00000200, MODE_PLAYLIST_SKIP = 0x00000400, MODE_PLAYLIST_JSPL = 0x00000800, - MODE_LIST_DEVICES = 0x00001000, - MODE_HELP = 0x00010000, - MODE_VERSION = 0x00020000, + MODE_LIST_DEVICES = 0x00001000, + MODE_HELP = 0x00010000, + MODE_HELP_VARIABLE = 0x00020000, + MODE_VERSION = 0x00040000, }; typedef struct { Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-06 18:12:00 UTC (rev 304) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-07 12:33:41 UTC (rev 305) @@ -251,6 +251,13 @@ goto exit_main; } + // Show help message for variables and exit. + if (opt.verb & MODE_HELP_VARIABLE) { + option_usage_variable(fpo); + ret = 0; + goto exit_main; + } + // Initialize PMPlib library. if (res = pmplib_init(&pmplib)) { fprintf(fpe, "ERROR: Failed to initialize PMPlib library (%d)\n", res); Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-06 18:12:00 UTC (rev 304) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-07 12:33:41 UTC (rev 305) @@ -50,18 +50,13 @@ #include <easypmp.h> #include "option.h" -/** - * \addtogroup cui - * @{ - */ - void option_usage(FILE *fp, const char *argv0) { fprintf(fp, "USAGE: %s [OPTIONS] [LOCATION]\n", argv0); #ifdef _WIN32 fprintf(fp, " LOCATION Absolute path to the root directory of a player (e.g., D:\\).\n"); #else - fprintf(fp, " LOCATION Absolute path to the root directory of a player (e.g., /mnt/usbdisk/).\n"); + fprintf(fp, " LOCATION Mount location of a player (e.g., /mnt/usbdisk/).\n"); #endif fprintf(fp, " If LOCATION is omitted, assume the current directory.\n"); #ifdef _WIN32 @@ -74,11 +69,11 @@ fprintf(fp, " -u, --update Update the existing media database incrementally\n"); /*fprintf(fp, " -z, --source=SOURCE Specify a source for obtaining media information\n");*/ fprintf(fp, " -R, --repr Output a database structure in plain text\n"); - fprintf(fp, " -L, --repr-level=VAL Specify representation level\n"); + fprintf(fp, " -L, --repr-level=VAL Specify representation level for -R option\n"); fprintf(fp, " -t, --strip-words=VAL Specify a list (CSV) of words to strip from artist names\n"); fprintf(fp, "\n"); fprintf(fp, "Playlist options:\n"); - fprintf(fp, " -p, --playlist Convert playlist files in PLAYLIST directory\n"); + fprintf(fp, " -p, --playlist Convert playlist files\n"); fprintf(fp, " -r, --reconvert Discard the existing playlist files and reconvert\n"); fprintf(fp, " -f, --find-missing Correct playlists with corrupt references to media files\n"); fprintf(fp, " -i, --ignore-missing Continue a conversion even if a media file is missing\n"); @@ -89,7 +84,7 @@ fprintf(fp, "Player options:\n"); fprintf(fp, " -l, --list-device Show the list of supported devices and exit\n"); fprintf(fp, " -d, --device Specify a device identifier for the player\n"); - fprintf(fp, " -s, --set=NAME=VALUE Set a variable NAME to VALUE\n"); + fprintf(fp, " -s, --set=NAME:VALUE Set a variable NAME to VALUE\n"); fprintf(fp, "\n"); #ifndef _WIN32 fprintf(fp, "Language-specific options:\n"); @@ -100,8 +95,21 @@ fprintf(fp, "Miscellaneous options:\n"); fprintf(fp, " -v, --version Show version number and exit\n"); fprintf(fp, " -h, --help Show this help message and exit\n"); + fprintf(fp, " -x, --help-variable Show the list of variables and exit\n"); } +void option_usage_variable(FILE* fp) +{ + fprintf(fp, "VARIABLE USAGE:\n"); + fprintf(fp, " Specify the VALUE of a variable NAME with -s option, i.e., -s NAME:VALUE\n"); + fprintf(fp, " Note that a pathname ending with \"%c%c\" implies inclusion of its subdirs\n", PATHCHAR, PATHCHAR); + fprintf(fp, "\n"); + fprintf(fp, "Pathname variables:\n"); + fprintf(fp, " music Relative path to music directory\n"); + fprintf(fp, " playlistsrc Absolute path to the sources for playlist conversion\n"); + fprintf(fp, " playlistdst Relative path to the destinations for playlist conversion\n"); +} + void option_init(option_t* opt) { memset(opt, 0, sizeof(*opt)); @@ -138,32 +146,32 @@ int this_option_optind = optind ? optind : 1; int option_index = 0; static const struct option long_options[] = { - {"create", no_argument, 0, 'c'}, - {"update", no_argument, 0, 'u'}, - {"source", required_argument, 0, 'z'}, - {"repr", no_argument, 0, 'R'}, + {"create", no_argument, 0, 'c'}, + {"update", no_argument, 0, 'u'}, + {"source", required_argument, 0, 'z'}, + {"repr", no_argument, 0, 'R'}, {"repr-level", required_argument, 0, 'L'}, {"strip-words", required_argument, 0, 't'}, {"playlist", no_argument, 0, 'p'}, {"reconvert", no_argument, 0, 'r'}, {"find-missing", no_argument, 0, 'f'}, - {"ignore-missing", no_argument, 0, 's'}, - {"jspl", no_argument, 0, 'j'}, + {"ignore-missing", no_argument, 0, 'i'}, {"list-device", no_argument, 0, 'l'}, - {"device", required_argument, 0, 'd'}, - {"set", required_argument, 0, 's'}, + {"device", required_argument, 0, 'd'}, + {"set", required_argument, 0, 's'}, #ifndef _WIN32 {"encoding", required_argument, 0, 'e'}, {"tagencoding", required_argument, 0, 'w'}, #endif/*_WIN32*/ - {"version", no_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + {"help-variable", no_argument, 0, 'x'}, {NULL, 0, 0, 0} }; #ifndef _WIN32 - int c = getopt_long(argc, argv, "cuz:RL:t:pmrfsjld:e:w:vh", long_options, &option_index); + int c = getopt_long(argc, argv, "cuz:RL:t:prfild:xs:e:w:vh", long_options, &option_index); #else - int c = getopt_long(argc, argv, "cuz:RL:t:pmrfsjld:vh", long_options, &option_index); + int c = getopt_long(argc, argv, "cuz:RL:t:prfild:xs:vh", long_options, &option_index); #endif/*_WIN32*/ if (c == -1) { break; @@ -203,6 +211,7 @@ free(opt->mbs_strip_words); opt->mbs_strip_words = strdup(optarg); break; + case 'p': opt->verb |= MODE_PLAYLIST; break; @@ -215,9 +224,7 @@ case 'i': opt->verb |= MODE_PLAYLIST_SKIP; break; - case 'j': - opt->verb |= MODE_PLAYLIST_JSPL; - break; + case 'l': opt->verb |= MODE_LIST_DEVICES; break; @@ -242,6 +249,9 @@ case 'h': opt->verb |= MODE_HELP; break; + case 'x': + opt->verb |= MODE_HELP_VARIABLE; + break; case '?': return -1; break; @@ -250,4 +260,3 @@ return optind; } -/** @} */ Modified: trunk/pmplib/frontend/easypmp/cui/option.h =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.h 2007-02-06 18:12:00 UTC (rev 304) +++ trunk/pmplib/frontend/easypmp/cui/option.h 2007-02-07 12:33:41 UTC (rev 305) @@ -29,5 +29,6 @@ void option_finish(option_t* opt); int option_parse(option_t* opt, int argc, char *argv[], FILE *fpe); void option_usage(FILE *fp, const char *argv0); +void option_usage_variable(FILE *fp); #endif/*__OPTION_H__*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |