mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2024-11-15 17:40:56 +00:00
add USAGE, OPTSTR macros
rename help() to usage() log_warn() an unknown option condense set_kind()
This commit is contained in:
parent
88fe1f5782
commit
b2bdd21da5
74
src/vmrcli.c
74
src/vmrcli.c
@ -21,6 +21,17 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#define USAGE "Usage: .\\vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n" \
|
||||||
|
"Where: \n" \
|
||||||
|
"\th: Prints the help message\n" \
|
||||||
|
"\ti: Enable interactive mode\n" \
|
||||||
|
"\tk: The kind of Voicemeeter (basic, banana, potato)\n" \
|
||||||
|
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL\n" \
|
||||||
|
"\tv: Enable extra console output (toggle, set messages)\n" \
|
||||||
|
"\tc: Load a user configuration (give the full file path)\n" \
|
||||||
|
"\tm: Launch the MacroButtons application\n" \
|
||||||
|
"\ts: Launch the StreamerView application"
|
||||||
|
#define OPTSTR ":hk:msc:iD:v"
|
||||||
#define MAX_LINE 512
|
#define MAX_LINE 512
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +58,7 @@ struct result
|
|||||||
|
|
||||||
static bool vflag = false;
|
static bool vflag = false;
|
||||||
|
|
||||||
void help(void);
|
static void usage(void);
|
||||||
enum kind set_kind(char *kval);
|
enum kind set_kind(char *kval);
|
||||||
void interactive(PT_VMR vmr);
|
void interactive(PT_VMR vmr);
|
||||||
void parse_input(PT_VMR vmr, char *input);
|
void parse_input(PT_VMR vmr, char *input);
|
||||||
@ -67,19 +78,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
help();
|
usage();
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_set_level(LOG_WARN);
|
log_set_level(LOG_WARN);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hk:msc:iD:v")) != -1)
|
opterr = 0;
|
||||||
|
while ((opt = getopt(argc, argv, OPTSTR)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case 'h':
|
|
||||||
help();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
case 'k':
|
case 'k':
|
||||||
kind = set_kind(optarg);
|
kind = set_kind(optarg);
|
||||||
if (kind == UNKNOWN)
|
if (kind == UNKNOWN)
|
||||||
@ -117,8 +125,20 @@ int main(int argc, char *argv[])
|
|||||||
case 'v':
|
case 'v':
|
||||||
vflag = true;
|
vflag = true;
|
||||||
break;
|
break;
|
||||||
|
case '?':
|
||||||
|
log_warn("unknown option -- '%c'\n"
|
||||||
|
"Try .\\vmrcli.exe -h for more information.",
|
||||||
|
optopt);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
case ':':
|
||||||
|
log_warn("missing argument for option -- '%c'\n"
|
||||||
|
"Try .\\vmrcli.exe -h for more information.",
|
||||||
|
optopt);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
case 'h':
|
||||||
|
/* FALLTHROUGH */
|
||||||
default:
|
default:
|
||||||
abort();
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,19 +199,10 @@ int main(int argc, char *argv[])
|
|||||||
/**
|
/**
|
||||||
* @brief prints the help message
|
* @brief prints the help message
|
||||||
*/
|
*/
|
||||||
void help()
|
static void usage()
|
||||||
{
|
{
|
||||||
puts(
|
puts(USAGE);
|
||||||
"Usage: .\\vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n"
|
exit(EXIT_SUCCESS);
|
||||||
"Where: \n"
|
|
||||||
"\th: Prints the help message\n"
|
|
||||||
"\ti: Enable interactive mode\n"
|
|
||||||
"\tk: The kind of Voicemeeter (basic, banana, potato)\n"
|
|
||||||
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL\n"
|
|
||||||
"\tv: Enable extra console output (toggle, set messages)\n"
|
|
||||||
"\tc: Load a user configuration (give the full file path)\n"
|
|
||||||
"\tm: Launch the MacroButtons application\n"
|
|
||||||
"\ts: Launch the StreamerView application");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,30 +215,13 @@ void help()
|
|||||||
enum kind set_kind(char *kval)
|
enum kind set_kind(char *kval)
|
||||||
{
|
{
|
||||||
if (strcmp(kval, "basic") == 0)
|
if (strcmp(kval, "basic") == 0)
|
||||||
{
|
return sizeof(void *) == 8 ? BASICX64 : BASIC;
|
||||||
if (sizeof(void *) == 8)
|
|
||||||
return BASICX64;
|
|
||||||
else
|
|
||||||
return BASIC;
|
|
||||||
}
|
|
||||||
else if (strcmp(kval, "banana") == 0)
|
else if (strcmp(kval, "banana") == 0)
|
||||||
{
|
return sizeof(void *) == 8 ? BANANAX64 : BANANA;
|
||||||
if (sizeof(void *) == 8)
|
|
||||||
return BANANAX64;
|
|
||||||
else
|
|
||||||
return BANANA;
|
|
||||||
}
|
|
||||||
else if (strcmp(kval, "potato") == 0)
|
else if (strcmp(kval, "potato") == 0)
|
||||||
{
|
return sizeof(void *) == 8 ? POTATOX64 : POTATO;
|
||||||
if (sizeof(void *) == 8)
|
|
||||||
return POTATOX64;
|
|
||||||
else
|
else
|
||||||
return POTATO;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user