Skip to content

Commit

Permalink
[chump] add --query:[version_language|version_chugin_api] command-l…
Browse files Browse the repository at this point in the history
…ine args (#440)

* add --query command (for chump)

* add print usage for --query

---------

Co-authored-by: Ge Wang <[email protected]>
  • Loading branch information
nshaheed and gewang authored May 9, 2024
1 parent aeaddb5 commit b9b41d6
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/host/chuck_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -247,7 +248,7 @@ static void version()

//-----------------------------------------------------------------------------
// name: usage()
// desc: ...
// desc: print command line options
//-----------------------------------------------------------------------------
void usage()
{
Expand All @@ -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:<path>|chugin:<name>\n" );
CK_FPRINTF_STDERR( " color:{on|off}|pid-file:<path>|cmd-listener:{on|off}\n" );
CK_FPRINTF_STDERR( " query|query:<name>\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" );
Expand All @@ -272,6 +274,21 @@ void usage()



//-----------------------------------------------------------------------------
// name: usage_query() | added 1.5.2.5 (nshaheed, ge)
// desc: print command line options for --query:<name>
//-----------------------------------------------------------------------------
void usage_query()
{
CK_FPRINTF_STDERR( "possible names for --query:<name>: \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
Expand Down Expand Up @@ -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 <name>
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:<name>'", 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:<name> usage
usage_query();
// clean up and exit
EXIT_with_global_cleanup( 0 );
}
else
{
// boost log level
Expand Down

0 comments on commit b9b41d6

Please sign in to comment.