From b9b41d6aa3fca6f3578dc2c00aa402a48378a9e7 Mon Sep 17 00:00:00 2001 From: nshaheed Date: Thu, 9 May 2024 19:25:03 -0400 Subject: [PATCH] [chump] add `--query:[version_language|version_chugin_api]` command-line args (#440) * add --query command (for chump) * add print usage for --query --------- Co-authored-by: Ge Wang --- src/host/chuck_main.cpp | 51 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/host/chuck_main.cpp b/src/host/chuck_main.cpp index e718b8e86..7ccb265c6 100644 --- a/src/host/chuck_main.cpp +++ b/src/host/chuck_main.cpp @@ -63,6 +63,7 @@ t_CKBOOL global_cleanup(); void all_stop(); void all_detach(); void usage(); +void usage_query(); void uh(); t_CKBOOL get_count( const char * arg, t_CKUINT * out ); static void audio_cb( SAMPLE * in, SAMPLE * out, t_CKUINT numFrames, @@ -247,7 +248,7 @@ static void version() //----------------------------------------------------------------------------- // name: usage() -// desc: ... +// desc: print command line options //----------------------------------------------------------------------------- void usage() { @@ -262,6 +263,7 @@ void usage() CK_FPRINTF_STDERR( " callback|deprecate:{stop|warn|ignore}|chugin-probe\n" ); CK_FPRINTF_STDERR( " chugin-load:{on|off}|chugin-path:|chugin:\n" ); CK_FPRINTF_STDERR( " color:{on|off}|pid-file:|cmd-listener:{on|off}\n" ); + CK_FPRINTF_STDERR( " query|query:\n" ); CK_FPRINTF_STDERR( "%s", TC::set_blue().c_str() ); CK_FPRINTF_STDERR( " [commands] = add|replace|remove|remove.all|status|time|\n" ); CK_FPRINTF_STDERR( " clear.vm|reset.id|abort.shred|exit\n" ); @@ -272,6 +274,21 @@ void usage() +//----------------------------------------------------------------------------- +// name: usage_query() | added 1.5.2.5 (nshaheed, ge) +// desc: print command line options for --query: +//----------------------------------------------------------------------------- +void usage_query() +{ + CK_FPRINTF_STDERR( "possible names for --query:: \n" ); + CK_FPRINTF_STDERR( " VERSION_LANGUAGE : language version (e.g., 1.5.2.0 (chai))\n" ); + CK_FPRINTF_STDERR( " VERSION_CHUGIN_API : chugin API version (e.g., 10.1)\n" ); + CK_FPRINTF_STDERR( " VERSION : (same as VERSION_LANGUAGE)\n" ); +} + + + + // non-NULL when a pid file has been written const char * g_ck_pidfile = NULL; // current process id @@ -979,6 +996,38 @@ t_CKBOOL go( int argc, const char ** argv ) { doVersion = TRUE; } + else if( !strncmp( argv[i], "--query:", 8 ) ) // added 1.5.2.5 (nshaheed) + { + // advance pointer to beginning of argument + string str = ::tolower(argv[i]+8); + + // check + if( str == "version_language" || str == "version" ) + { + CK_FPRINTF_STDOUT( "%s\n", CHUCK_VERSION_STRING ); + } + else if( str == "version_chugin_api" ) + { + CK_FPRINTF_STDOUT( "%d.%d\n", CK_DLL_VERSION_MAJOR, CK_DLL_VERSION_MINOR ); + } + else // no match + { + // print error + EM_error2( 0, "invalid argument '%s' for '--query:'", str.c_str() ); + // print --query usage + usage_query(); + } + + // clean up and exit + EXIT_with_global_cleanup( 0 ); + } + else if( !strncmp( argv[i], "--query", 7 ) ) // added 1.5.2.5 (nshaheed) + { + // print --query: usage + usage_query(); + // clean up and exit + EXIT_with_global_cleanup( 0 ); + } else { // boost log level