mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-15 16:14:12 +00:00
Add --version switch to main program.
This commit is contained in:
parent
417459b806
commit
ed30de44cf
3 changed files with 35 additions and 16 deletions
|
@ -15,24 +15,12 @@
|
||||||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "builtin_feats.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "dindexerConfig.h"
|
#include "dindexerConfig.h"
|
||||||
|
|
||||||
void print_builtin_feats() {
|
void print_builtin_feats() {
|
||||||
#if VERSION_BETA
|
print_version();
|
||||||
char beta_str[2] = "b";
|
|
||||||
#else
|
|
||||||
char beta_str[1] = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("%s v %d.%d.%d%s\nRev %s\n",
|
|
||||||
PROGRAM_NAME,
|
|
||||||
VERSION_MAJOR,
|
|
||||||
VERSION_MINOR,
|
|
||||||
VERSION_PATCH,
|
|
||||||
beta_str,
|
|
||||||
VERSION_GIT
|
|
||||||
);
|
|
||||||
|
|
||||||
printf("CONFIG_FILE_PATH = \"%s\"\n", CONFIG_FILE_PATH);
|
printf("CONFIG_FILE_PATH = \"%s\"\n", CONFIG_FILE_PATH);
|
||||||
printf("ACTIONS_SEARCH_PATH = \"%s\"\n", ACTIONS_SEARCH_PATH);
|
printf("ACTIONS_SEARCH_PATH = \"%s\"\n", ACTIONS_SEARCH_PATH);
|
||||||
|
@ -49,3 +37,20 @@ void print_builtin_feats() {
|
||||||
#endif
|
#endif
|
||||||
printf("DB_OWNER_NAME = \"%s\"\n", DB_OWNER_NAME);
|
printf("DB_OWNER_NAME = \"%s\"\n", DB_OWNER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_version() {
|
||||||
|
#if VERSION_BETA
|
||||||
|
char beta_str[2] = "b";
|
||||||
|
#else
|
||||||
|
char beta_str[1] = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("%s v%d.%d.%d%s\nRev %s\n",
|
||||||
|
PROGRAM_NAME,
|
||||||
|
VERSION_MAJOR,
|
||||||
|
VERSION_MINOR,
|
||||||
|
VERSION_PATCH,
|
||||||
|
beta_str,
|
||||||
|
VERSION_GIT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -19,5 +19,6 @@
|
||||||
#define id17B851C76AD54C8B9A2098323FC83038
|
#define id17B851C76AD54C8B9A2098323FC83038
|
||||||
|
|
||||||
void print_builtin_feats ( void );
|
void print_builtin_feats ( void );
|
||||||
|
void print_version ( void );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -181,12 +181,14 @@ static void print_usage() {
|
||||||
printf("--help, -h - show this help\n");
|
printf("--help, -h - show this help\n");
|
||||||
printf("--builtin, -b - show build info\n");
|
printf("--builtin, -b - show build info\n");
|
||||||
printf("--printactions=[prefix] - print a complete-friendly list of available commands, filtered by an optional prefix\n");
|
printf("--printactions=[prefix] - print a complete-friendly list of available commands, filtered by an optional prefix\n");
|
||||||
|
printf("--version, -v - show %s's version and quit", PROGRAM_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int manage_commandline (int parArgc, char* parArgv[], char** parActions, size_t parActionCount, int* parShouldQuit) {
|
static int manage_commandline (int parArgc, char* parArgv[], char** parActions, size_t parActionCount, int* parShouldQuit) {
|
||||||
int showbuiltin;
|
int showbuiltin;
|
||||||
int showhelp;
|
int showhelp;
|
||||||
int showactions_for_completion;
|
int showactions_for_completion;
|
||||||
|
int showversion;
|
||||||
int option_index;
|
int option_index;
|
||||||
int getopt_retval;
|
int getopt_retval;
|
||||||
FILE* streamout;
|
FILE* streamout;
|
||||||
|
@ -204,15 +206,16 @@ static int manage_commandline (int parArgc, char* parArgv[], char** parActions,
|
||||||
{ "printactions", optional_argument, NULL, 'a' },
|
{ "printactions", optional_argument, NULL, 'a' },
|
||||||
{ "builtin", no_argument, &showbuiltin, 1 },
|
{ "builtin", no_argument, &showbuiltin, 1 },
|
||||||
{ "help", no_argument, &showhelp, 1 },
|
{ "help", no_argument, &showhelp, 1 },
|
||||||
|
{ "version", no_argument, &showversion, 1 },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
memset(&actions_print_context, 0, sizeof(actions_print_context));
|
memset(&actions_print_context, 0, sizeof(actions_print_context));
|
||||||
option_index = 0;
|
option_index = 0;
|
||||||
showbuiltin = showhelp = showactions_for_completion = 0;
|
showversion = showbuiltin = showhelp = showactions_for_completion = 0;
|
||||||
*parShouldQuit = 0;
|
*parShouldQuit = 0;
|
||||||
|
|
||||||
while (0 <= (getopt_retval = getopt_long(parArgc, parArgv, "bh", opts, &option_index))) {
|
while (0 <= (getopt_retval = getopt_long(parArgc, parArgv, "bhv", opts, &option_index))) {
|
||||||
switch (getopt_retval) {
|
switch (getopt_retval) {
|
||||||
case 'h':
|
case 'h':
|
||||||
showhelp = 1;
|
showhelp = 1;
|
||||||
|
@ -226,6 +229,10 @@ static int manage_commandline (int parArgc, char* parArgv[], char** parActions,
|
||||||
case 'a':
|
case 'a':
|
||||||
showactions_for_completion = 1;
|
showactions_for_completion = 1;
|
||||||
actions_print_context.prefix_filter = (optarg ? optarg : "");
|
actions_print_context.prefix_filter = (optarg ? optarg : "");
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
showversion = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
option_index = 0;
|
option_index = 0;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +256,7 @@ static int manage_commandline (int parArgc, char* parArgv[], char** parActions,
|
||||||
streamout = stdout;
|
streamout = stdout;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
}
|
}
|
||||||
|
fprintf(streamout, "\n");
|
||||||
fprintf(streamout, "Available actions are:\n");
|
fprintf(streamout, "Available actions are:\n");
|
||||||
foreach_avail_action(&printf_stream, parActions, parActionCount, streamout);
|
foreach_avail_action(&printf_stream, parActions, parActionCount, streamout);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -258,6 +266,11 @@ static int manage_commandline (int parArgc, char* parArgv[], char** parActions,
|
||||||
print_builtin_feats();
|
print_builtin_feats();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if (showversion) {
|
||||||
|
*parShouldQuit = 1;
|
||||||
|
print_version();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if (showactions_for_completion) {
|
else if (showactions_for_completion) {
|
||||||
*parShouldQuit = 1;
|
*parShouldQuit = 1;
|
||||||
actions_print_context.stream = stdout;
|
actions_print_context.stream = stdout;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue