summaryrefslogtreecommitdiff
path: root/cli/hitomezashi_cli.c
diff options
context:
space:
mode:
authoruntir_l <87096069+untir-l@users.noreply.github.com>2022-02-19 05:40:09 +0000
committeruntir-l <87096069+untir-l@users.noreply.github.com>2022-02-25 09:56:49 +0000
commit8a7dde79de6edee01571d2eb4a333d8256f4c342 (patch)
tree786b305ed2b1b0896c6b651d6585feeae7fc447a /cli/hitomezashi_cli.c
parent581bc2dd768ca0af390b9abb41a5c89f1bca19e3 (diff)
downloadhitomezashi-8a7dde79de6edee01571d2eb4a333d8256f4c342.tar
hitomezashi-8a7dde79de6edee01571d2eb4a333d8256f4c342.tar.gz
hitomezashi-8a7dde79de6edee01571d2eb4a333d8256f4c342.zip
Improve docs, don't initialise SDL until arguments are already handled
Diffstat (limited to 'cli/hitomezashi_cli.c')
-rw-r--r--cli/hitomezashi_cli.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/cli/hitomezashi_cli.c b/cli/hitomezashi_cli.c
index 762c9e3..70a2812 100644
--- a/cli/hitomezashi_cli.c
+++ b/cli/hitomezashi_cli.c
@@ -15,12 +15,6 @@
/** Initialise SDL, pass the information from hitomezashi_cli_handle_args() to
* libhitomezashi, and save the resulting image. */
int main(int argc, char **argv) {
- if (SDL_Init(SDL_INIT_VIDEO) != 0) {
- SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Failed to initialise SDL: %s",
- SDL_GetError());
- return Hitomezashi_Cli_Exit_Code_Err_Sdl_Init;
- }
-
char *out_file_path;
int x_pattern_len;
int y_pattern_len;
@@ -32,6 +26,12 @@ int main(int argc, char **argv) {
&x_pattern, &y_pattern, &gap, &thickness, argc,
argv);
+ if (SDL_Init(SDL_INIT_VIDEO) != 0) {
+ SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Failed to initialise SDL: %s",
+ SDL_GetError());
+ return Hitomezashi_Cli_Exit_Code_Err_Sdl_Init;
+ }
+
struct Hitomezashi_State state;
if (hitomezashi_state_init(&state, x_pattern_len, y_pattern_len, x_pattern,
y_pattern, gap, thickness) != 0) {
@@ -52,7 +52,6 @@ int main(int argc, char **argv) {
SDL_Quit();
}
-// Attempts to prints help. Exits 0 on success, 2 on failure.
void hitomezashi_cli_help(void) {
if (puts("hitomezashi_cli - generate hitomezashi patterns\n"
"Options:\n"
@@ -86,8 +85,6 @@ char *hitomezashi_cli_ascii_binary_str_to_ints(char *ascii_str, size_t n) {
return res;
}
-// Parses arguments with xgetopt, ensures they are valid, initialises various
-// variables based on them. Prints and exits if it encounters an error.
void hitomezashi_cli_handle_args(char **out_file_path, int *x_pattern_len,
int *y_pattern_len, char **x_pattern,
char **y_pattern, int *gap, int *thickness,