refactor: clean and sort args
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ make -f Makefile.dev release-arch
|
|||||||
- [x] `forge_project.cfg`
|
- [x] `forge_project.cfg`
|
||||||
- [x] Define frag prefix in config
|
- [x] Define frag prefix in config
|
||||||
- [ ] Use custom `#include xxx.glsl` preprocessor
|
- [ ] Use custom `#include xxx.glsl` preprocessor
|
||||||
- [ ] Clean and sort args
|
- [x] Clean and sort args
|
||||||
- [x] `--auto-random` / `--no-auto-random`
|
- [x] `--auto-random` / `--no-auto-random`
|
||||||
- [ ] Update readme with usage documentation
|
- [ ] Update readme with usage documentation
|
||||||
- [x] Documentation in default config file
|
- [x] Documentation in default config file
|
||||||
|
|||||||
@@ -102,32 +102,32 @@ When running, the following keybindings are available:
|
|||||||
### CLI arguments
|
### CLI arguments
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
usage: forge [-h] [-v] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-p=PROJECT_PATH] [-c=CFG_FILE] [-sf=STATE_PATH] [-ls / -nls] [-ss / -nss] [-is=SIZE] [-v=FILE] [-vs=SIZE] [-t=TEMPO] [-d] [-ar / -nar] [-w] [-tm] [-tf]
|
usage: forge [-h] [-v] [-p=PROJECT_PATH] [-c=CFG_FILE] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-w] [-t=TEMPO] [-d] [-ar / -nar] [-v=FILE] [-vs=SIZE] [-is=SIZE] [-sf=STATE_PATH] [-ls / -nls] [-ss / -nss] [-tm] [-tf]
|
||||||
|
|
||||||
Fusion Of Real-time Generative Effects.
|
Fusion Of Real-time Generative Effects.
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-v, --version print version
|
-v, --version print version
|
||||||
|
-p, --project forge project directory (default: /usr/share/forge/default)
|
||||||
|
-c, --config config file name (default: forge_project.cfg)
|
||||||
-hr, --hot-reload hot reload of shaders scripts
|
-hr, --hot-reload hot reload of shaders scripts
|
||||||
-s, --screen output screen number (default: primary)
|
-s, --screen output screen number (default: primary)
|
||||||
-m, --monitor monitor screen number (default: none)
|
-m, --monitor monitor screen number (default: none)
|
||||||
-mo, --monitor-only no output screen
|
-mo, --monitor-only no output screen
|
||||||
-p, --project forge project directory (default: /usr/share/forge/default)
|
-w, --windowed not fullscreen
|
||||||
-c, --config config file name (default: forge_project.cfg)
|
-t, --tempo base tempo (default: 60)
|
||||||
|
-d, --demo demonstration mode (assume --no-save-state, --no-load-state, --auto-random)
|
||||||
|
-ar, --auto-random randomize state every 4 beats
|
||||||
|
-nar, --no-auto-random do not randomize state (default)
|
||||||
|
-v, --video-in path to video capture device (multiple allowed)
|
||||||
|
-vs, --video-size video capture desired height (default: internal texture height)
|
||||||
|
-is, --internal-size internal texture height (default: 720)
|
||||||
-sf, --state-file saved state file (default: forge_saved_state.txt)
|
-sf, --state-file saved state file (default: forge_saved_state.txt)
|
||||||
-ls, --load-state load saved state (default)
|
-ls, --load-state load saved state (default)
|
||||||
-nls, --no-load-state do not load saved state
|
-nls, --no-load-state do not load saved state
|
||||||
-ss, --save-state save state (default)
|
-ss, --save-state save state (default)
|
||||||
-nss, --no-save-state do not save state
|
-nss, --no-save-state do not save state
|
||||||
-is, --internal-size internal texture height (default: 720)
|
|
||||||
-v, --video-in path to video capture device (multiple allowed)
|
|
||||||
-vs, --video-size video capture desired height (default: internal texture height)
|
|
||||||
-t, --tempo base tempo (default: 60)
|
|
||||||
-d, --demo demonstration mode (assume --no-save-state , --no-load-state, --auto-random)
|
|
||||||
-ar, --auto-random randomize state every 4 beats
|
|
||||||
-nar, --no-auto-random do not randomize state (default)
|
|
||||||
-w, --windowed not fullscreen
|
|
||||||
-tm, --trace-midi print midi code and values
|
-tm, --trace-midi print midi code and values
|
||||||
-tf, --trace-fps print fps status of subsystems
|
-tf, --trace-fps print fps status of subsystems
|
||||||
```
|
```
|
||||||
|
|||||||
+66
-66
@@ -16,22 +16,22 @@ static void print_help(int status_code) {
|
|||||||
"usage: " PACKAGE " "
|
"usage: " PACKAGE " "
|
||||||
"[-h] "
|
"[-h] "
|
||||||
"[-v] "
|
"[-v] "
|
||||||
|
"[-p=PROJECT_PATH] "
|
||||||
|
"[-c=CFG_FILE] "
|
||||||
"[-hr] "
|
"[-hr] "
|
||||||
"[-s=SCREEN] "
|
"[-s=SCREEN] "
|
||||||
"[-m=SCREEN] "
|
"[-m=SCREEN] "
|
||||||
"[-mo] "
|
"[-mo] "
|
||||||
"[-p=PROJECT_PATH] "
|
"[-w] "
|
||||||
"[-c=CFG_FILE] "
|
|
||||||
"[-sf=STATE_PATH] "
|
|
||||||
"[-ls / -nls] "
|
|
||||||
"[-ss / -nss] "
|
|
||||||
"[-is=SIZE] "
|
|
||||||
"[-v=FILE] "
|
|
||||||
"[-vs=SIZE] "
|
|
||||||
"[-t=TEMPO] "
|
"[-t=TEMPO] "
|
||||||
"[-d] "
|
"[-d] "
|
||||||
"[-ar / -nar] "
|
"[-ar / -nar] "
|
||||||
"[-w] "
|
"[-v=FILE] "
|
||||||
|
"[-vs=SIZE] "
|
||||||
|
"[-is=SIZE] "
|
||||||
|
"[-sf=STATE_PATH] "
|
||||||
|
"[-ls / -nls] "
|
||||||
|
"[-ss / -nss] "
|
||||||
"[-tm] "
|
"[-tm] "
|
||||||
"[-tf] "
|
"[-tf] "
|
||||||
"\n\n"
|
"\n\n"
|
||||||
@@ -39,31 +39,31 @@ static void print_help(int status_code) {
|
|||||||
"options:\n"
|
"options:\n"
|
||||||
" -h, --help show this help message and exit\n"
|
" -h, --help show this help message and exit\n"
|
||||||
" -v, --version print version\n"
|
" -v, --version print version\n"
|
||||||
|
" -p, --project forge project directory (default: " DATADIR
|
||||||
|
"/default)\n"
|
||||||
|
" -c, --config config file name (default: "
|
||||||
|
"forge_project.cfg)\n"
|
||||||
" -hr, --hot-reload hot reload of shaders scripts\n"
|
" -hr, --hot-reload hot reload of shaders scripts\n"
|
||||||
" -s, --screen output screen number (default: primary)\n"
|
" -s, --screen output screen number (default: primary)\n"
|
||||||
" -m, --monitor monitor screen number (default: none)\n"
|
" -m, --monitor monitor screen number (default: none)\n"
|
||||||
" -mo, --monitor-only no output screen\n"
|
" -mo, --monitor-only no output screen\n"
|
||||||
" -p, --project forge project directory "
|
" -w, --windowed not fullscreen\n"
|
||||||
"(default: " DATADIR "/default)\n"
|
" -t, --tempo base tempo (default: 60)\n"
|
||||||
" -c, --config config file name "
|
" -d, --demo demonstration mode (assume "
|
||||||
"(default: forge_project.cfg)\n"
|
"--no-save-state, --no-load-state, --auto-random)\n"
|
||||||
|
" -ar, --auto-random randomize state every 4 beats\n"
|
||||||
|
" -nar, --no-auto-random do not randomize state (default)\n"
|
||||||
|
" -v, --video-in path to video capture device (multiple "
|
||||||
|
"allowed)\n"
|
||||||
|
" -vs, --video-size video capture desired height (default: "
|
||||||
|
"internal texture height)\n"
|
||||||
|
" -is, --internal-size internal texture height (default: 720)\n"
|
||||||
" -sf, --state-file saved state file (default: "
|
" -sf, --state-file saved state file (default: "
|
||||||
"forge_saved_state.txt)\n"
|
"forge_saved_state.txt)\n"
|
||||||
" -ls, --load-state load saved state (default)\n"
|
" -ls, --load-state load saved state (default)\n"
|
||||||
" -nls, --no-load-state do not load saved state\n"
|
" -nls, --no-load-state do not load saved state\n"
|
||||||
" -ss, --save-state save state (default)\n"
|
" -ss, --save-state save state (default)\n"
|
||||||
" -nss, --no-save-state do not save state\n"
|
" -nss, --no-save-state do not save state\n"
|
||||||
" -is, --internal-size internal texture height (default: 720)\n"
|
|
||||||
" -v, --video-in path to video capture device (multiple "
|
|
||||||
"allowed)\n"
|
|
||||||
" -vs, --video-size video capture desired height (default: "
|
|
||||||
"internal texture height)\n"
|
|
||||||
" -t, --tempo base tempo (default: 60)\n"
|
|
||||||
" -d, --demo demonstration mode (assume --no-save-state "
|
|
||||||
", --no-load-state, --auto-random)\n"
|
|
||||||
" -ar, --auto-random randomize state every 4 beats\n"
|
|
||||||
" -nar, --no-auto-random do not randomize state (default)\n"
|
|
||||||
" -w, --windowed not fullscreen\n"
|
|
||||||
" -tm, --trace-midi print midi code and values\n"
|
" -tm, --trace-midi print midi code and values\n"
|
||||||
" -tf, --trace-fps print fps status of subsystems\n");
|
" -tf, --trace-fps print fps status of subsystems\n");
|
||||||
exit(status_code);
|
exit(status_code);
|
||||||
@@ -105,23 +105,23 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
char *arg;
|
char *arg;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
|
strncpy(params.project_path, DATADIR "/default", STR_LEN);
|
||||||
|
strncpy(params.config_file, "forge_project.cfg", STR_LEN);
|
||||||
params.hot_reload = false;
|
params.hot_reload = false;
|
||||||
params.output = true;
|
params.output = true;
|
||||||
params.output_screen = 0;
|
params.output_screen = 0;
|
||||||
params.monitor = false;
|
params.monitor = false;
|
||||||
params.monitor_screen = 0;
|
params.monitor_screen = 0;
|
||||||
strncpy(params.project_path, DATADIR "/default", STR_LEN);
|
params.windowed = false;
|
||||||
strncpy(params.config_file, "forge_project.cfg", STR_LEN);
|
|
||||||
strncpy(params.state_file, "forge_saved_state.txt", STR_LEN);
|
|
||||||
params.load_state = true;
|
|
||||||
params.save_state = true;
|
|
||||||
params.internal_size = 720;
|
|
||||||
params.video_size = 0;
|
|
||||||
params.base_tempo = 60.0f;
|
params.base_tempo = 60.0f;
|
||||||
params.demo = false;
|
params.demo = false;
|
||||||
params.auto_random = false;
|
params.auto_random = false;
|
||||||
params.windowed = false;
|
|
||||||
params.video_in.length = 0;
|
params.video_in.length = 0;
|
||||||
|
params.video_size = 0;
|
||||||
|
params.internal_size = 720;
|
||||||
|
strncpy(params.state_file, "forge_saved_state.txt", STR_LEN);
|
||||||
|
params.load_state = true;
|
||||||
|
params.save_state = true;
|
||||||
params.trace_midi = false;
|
params.trace_midi = false;
|
||||||
params.trace_fps = false;
|
params.trace_fps = false;
|
||||||
|
|
||||||
@@ -133,29 +133,33 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
} else if (is_arg(arg, "-v") || is_arg(arg, "--version")) {
|
} else if (is_arg(arg, "-v") || is_arg(arg, "--version")) {
|
||||||
puts(PACKAGE " " VERSION);
|
puts(PACKAGE " " VERSION);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) {
|
|
||||||
params.hot_reload = true;
|
|
||||||
} else if (is_arg(arg, "-s") || is_arg(arg, "--screen")) {
|
|
||||||
params.output_screen = parse_uint(arg, value);
|
|
||||||
} else if (is_arg(arg, "-p") || is_arg(arg, "--project")) {
|
} else if (is_arg(arg, "-p") || is_arg(arg, "--project")) {
|
||||||
strncpy(params.project_path, value, STR_LEN);
|
strncpy(params.project_path, value, STR_LEN);
|
||||||
} else if (is_arg(arg, "-c") || is_arg(arg, "--config")) {
|
} else if (is_arg(arg, "-c") || is_arg(arg, "--config")) {
|
||||||
strncpy(params.config_file, value, STR_LEN);
|
strncpy(params.config_file, value, STR_LEN);
|
||||||
} else if (is_arg(arg, "-sf") || is_arg(arg, "--state-file")) {
|
} else if (is_arg(arg, "-hr") || is_arg(arg, "--hot-reload")) {
|
||||||
strncpy(params.state_file, value, STR_LEN);
|
params.hot_reload = true;
|
||||||
} else if (is_arg(arg, "-ls") || is_arg(arg, "--load-state")) {
|
} else if (is_arg(arg, "-s") || is_arg(arg, "--screen")) {
|
||||||
params.load_state = true;
|
params.output_screen = parse_uint(arg, value);
|
||||||
} else if (is_arg(arg, "-nls") || is_arg(arg, "--no-load-state")) {
|
} else if (is_arg(arg, "-m") || is_arg(arg, "--monitor")) {
|
||||||
|
params.monitor = true;
|
||||||
|
params.monitor_screen = parse_uint(arg, value);
|
||||||
|
} else if (is_arg(arg, "-mo") || is_arg(arg, "--monitor-only")) {
|
||||||
|
params.output = false;
|
||||||
|
params.monitor = true;
|
||||||
|
} else if (is_arg(arg, "-w") || is_arg(arg, "--windowed")) {
|
||||||
|
params.windowed = true;
|
||||||
|
} else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) {
|
||||||
|
params.base_tempo = (float)parse_uint(arg, value);
|
||||||
|
} else if (is_arg(arg, "-d") || is_arg(arg, "--demo")) {
|
||||||
|
params.demo = true;
|
||||||
params.load_state = false;
|
params.load_state = false;
|
||||||
} else if (is_arg(arg, "-ss") || is_arg(arg, "--save-state")) {
|
|
||||||
params.save_state = true;
|
|
||||||
} else if (is_arg(arg, "-nss") || is_arg(arg, "--no-save-state")) {
|
|
||||||
params.save_state = false;
|
params.save_state = false;
|
||||||
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
|
params.auto_random = true;
|
||||||
params.internal_size = parse_uint(arg, value);
|
} else if (is_arg(arg, "-ar") || is_arg(arg, "--auto-random")) {
|
||||||
if (params.internal_size == 0) {
|
params.auto_random = true;
|
||||||
invalid_value(arg, value);
|
} else if (is_arg(arg, "-nar") || is_arg(arg, "--no-auto-random")) {
|
||||||
}
|
params.auto_random = false;
|
||||||
} else if (is_arg(arg, "-v") || is_arg(arg, "--video-in")) {
|
} else if (is_arg(arg, "-v") || is_arg(arg, "--video-in")) {
|
||||||
if (params.video_in.length == MAX_VIDEO) {
|
if (params.video_in.length == MAX_VIDEO) {
|
||||||
log_error("maximum video input reached");
|
log_error("maximum video input reached");
|
||||||
@@ -167,25 +171,21 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
if (params.video_size == 0) {
|
if (params.video_size == 0) {
|
||||||
invalid_value(arg, value);
|
invalid_value(arg, value);
|
||||||
}
|
}
|
||||||
} else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) {
|
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
|
||||||
params.base_tempo = (float)parse_uint(arg, value);
|
params.internal_size = parse_uint(arg, value);
|
||||||
} else if (is_arg(arg, "-m") || is_arg(arg, "--monitor")) {
|
if (params.internal_size == 0) {
|
||||||
params.monitor = true;
|
invalid_value(arg, value);
|
||||||
params.monitor_screen = parse_uint(arg, value);
|
}
|
||||||
} else if (is_arg(arg, "-mo") || is_arg(arg, "--monitor-only")) {
|
} else if (is_arg(arg, "-sf") || is_arg(arg, "--state-file")) {
|
||||||
params.output = false;
|
strncpy(params.state_file, value, STR_LEN);
|
||||||
params.monitor = true;
|
} else if (is_arg(arg, "-ls") || is_arg(arg, "--load-state")) {
|
||||||
} else if (is_arg(arg, "-d") || is_arg(arg, "--demo")) {
|
params.load_state = true;
|
||||||
params.demo = true;
|
} else if (is_arg(arg, "-nls") || is_arg(arg, "--no-load-state")) {
|
||||||
params.load_state = false;
|
params.load_state = false;
|
||||||
|
} else if (is_arg(arg, "-ss") || is_arg(arg, "--save-state")) {
|
||||||
|
params.save_state = true;
|
||||||
|
} else if (is_arg(arg, "-nss") || is_arg(arg, "--no-save-state")) {
|
||||||
params.save_state = false;
|
params.save_state = false;
|
||||||
params.auto_random = true;
|
|
||||||
} else if (is_arg(arg, "-ar") || is_arg(arg, "--auto-random")) {
|
|
||||||
params.auto_random = true;
|
|
||||||
} else if (is_arg(arg, "-nar") || is_arg(arg, "--no-auto-random")) {
|
|
||||||
params.auto_random = false;
|
|
||||||
} else if (is_arg(arg, "-w") || is_arg(arg, "--windowed")) {
|
|
||||||
params.windowed = true;
|
|
||||||
} else if (is_arg(arg, "-tm") || is_arg(arg, "--trace-midi")) {
|
} else if (is_arg(arg, "-tm") || is_arg(arg, "--trace-midi")) {
|
||||||
params.trace_midi = true;
|
params.trace_midi = true;
|
||||||
} else if (is_arg(arg, "-tf") || is_arg(arg, "--trace-fps")) {
|
} else if (is_arg(arg, "-tf") || is_arg(arg, "--trace-fps")) {
|
||||||
|
|||||||
+8
-8
@@ -30,23 +30,23 @@ typedef struct StringArray {
|
|||||||
} StringArray;
|
} StringArray;
|
||||||
|
|
||||||
typedef struct Parameters {
|
typedef struct Parameters {
|
||||||
|
char project_path[STR_LEN];
|
||||||
|
char config_file[STR_LEN];
|
||||||
bool hot_reload;
|
bool hot_reload;
|
||||||
bool output;
|
bool output;
|
||||||
unsigned int output_screen;
|
unsigned int output_screen;
|
||||||
bool monitor;
|
bool monitor;
|
||||||
unsigned int monitor_screen;
|
unsigned int monitor_screen;
|
||||||
char project_path[STR_LEN];
|
bool windowed;
|
||||||
char config_file[STR_LEN];
|
|
||||||
char state_file[STR_LEN];
|
|
||||||
bool load_state;
|
|
||||||
bool save_state;
|
|
||||||
unsigned int internal_size;
|
|
||||||
unsigned int video_size;
|
|
||||||
float base_tempo;
|
float base_tempo;
|
||||||
bool demo;
|
bool demo;
|
||||||
bool auto_random;
|
bool auto_random;
|
||||||
bool windowed;
|
|
||||||
StringArray video_in;
|
StringArray video_in;
|
||||||
|
unsigned int video_size;
|
||||||
|
unsigned int internal_size;
|
||||||
|
char state_file[STR_LEN];
|
||||||
|
bool load_state;
|
||||||
|
bool save_state;
|
||||||
bool trace_midi;
|
bool trace_midi;
|
||||||
bool trace_fps;
|
bool trace_fps;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|||||||
Reference in New Issue
Block a user