ADD the common convention to display the active version of the bees/beesd program

This commit is contained in:
2025-11-15 22:47:43 +01:00
parent cddce84542
commit dd96fe3b9c
4 changed files with 24 additions and 6 deletions

View File

@@ -39,6 +39,10 @@ help(){
exec "$bees_bin" --help
}
version(){
exec "$bees_bin" --version
}
for i in $("$bees_bin" --help 2>&1 | grep -E " --" | sed -e "s/^[^-]*-/-/" -e "s/,[^-]*--/ --/" -e "s/ [^-]*$//")
do
TMP_ARGS="$TMP_ARGS $i"
@@ -66,6 +70,8 @@ for arg in "${ARGUMENTS[@]}"; do
case $arg in
-h) help;;
--help) help;;
-V) version;;
--version) version;;
esac
done

View File

@@ -2,7 +2,9 @@
// tracing ----------------------------------------
int bees_log_level = 8;
/* default log level is LOG_INFO i.e.*/
/* LOG_WARNING (4); LOG_NOTICE (5); LOG_INFO (6); LOG_DEBUG (7) */
int bees_log_level = LOG_INFO + 1;
thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr;
thread_local bool BeesTracer::tl_first = true;

View File

@@ -6,6 +6,7 @@ Other directories will be rejected.
Options:
-h, --help Show this help
-V, --version Output version information and exit
Load management options:
-c, --thread-count Worker thread count (default CPU count * factor)
@@ -26,7 +27,7 @@ Logging options:
-T, --no-timestamps Omit timestamps in log output
-p, --absolute-paths Show absolute paths (default)
-P, --strip-paths Strip $CWD from beginning of all paths in the log
-v, --verbose Set maximum log level (0..8, default 8)
-v, --verbose Set maximum log level (0..8, default %d)
Optional environment variables:
BEESHOME Path to hash table and configuration files

View File

@@ -34,10 +34,17 @@
using namespace crucible;
using namespace std;
void
print_version(FILE *stream=stdout)
{
fprintf(stream, "bees version %s\n", BEES_VERSION);
}
void
do_cmd_help(char *argv[])
{
fprintf(stderr, BEES_USAGE, argv[0]);
print_version(stderr);
fprintf(stderr, BEES_USAGE, argv[0], bees_log_level);
}
// static inline helpers ----------------------------------------
@@ -803,6 +810,7 @@ bees_main(int argc, char *argv[])
{ .name = "absolute-paths", .has_arg = no_argument, .val = 'p' },
{ .name = "timestamps", .has_arg = no_argument, .val = 't' },
{ .name = "verbose", .has_arg = required_argument, .val = 'v' },
{ .name = "version", .has_arg = no_argument, .val = 'V' },
{ 0 },
};
@@ -879,7 +887,10 @@ bees_main(int argc, char *argv[])
BEESLOGNOTICE("log level set to " << bees_log_level);
}
break;
case 'V':
print_version();
bees_log_level = LOG_WARNING + 1; //Suppress the log message at the end
return EXIT_SUCCESS;
case 'h':
default:
do_cmd_help(argv);
@@ -965,8 +976,6 @@ bees_main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
cerr << "bees version " << BEES_VERSION << endl;
if (argc < 2) {
do_cmd_help(argv);
return EXIT_FAILURE;