Make help show when no fractal not specified
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 26 Apr 2024 06:52:49 +0000 (08:52 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 26 Apr 2024 06:52:49 +0000 (08:52 +0200)
As per the subject fractol should should behave as follows:
"If no parameter is provided, or if the parameter is invalid, the
program displays a list of available parameters and exits properly."

src/main.c

index d083ea5a82adfaf42c2f887360279e6ea4f34e44..8825b3f354c02c435050b74026a1d49ab4febb7b 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2023/10/27 14:29:26 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/04/25 15:45:14 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/04/26 08:52:24 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -216,7 +216,7 @@ void        set_default(t_session *s)
        s->img.height = 1011;
        s->img.undersample_max = 5;
        s->set.detail = 1000;
-       s->view.fractal = mandelbrot;
+       s->view.fractal = NULL;
        s->view.palette = tri_color;
        s->view.color_shift_speed = -0.001;
        s->set.color_stability = 100;
@@ -314,6 +314,8 @@ int parse_args(int argc, char **argv, t_session *s)
                        return (1);
                ++i;
        }
+       if (!s->view.fractal)
+               return (1);
        init_view(s);
        return (0);
 }
@@ -321,27 +323,27 @@ int       parse_args(int argc, char **argv, t_session *s)
 static const char      *help_str =
        "This is the help for fractol by Lukáš Jiřiště\n"
        "You can call the program as follows:\n\n"
-       "fractol [option value]\n"
+       "fractol -f <fractal name> [<option> <value>]\n"
        "\nOptions:\n"
-       "\t-w\n\t\tWidth of window in pixels\n"
-       "\t-h\n\t\tHeight of window in pixels\n"
-       "\t-u\n\t\tMaximum undersample in pixels\n"
-       "\t-d\n\t\tDetail in maximum iterations\n"
-       "\t-f\n\t\tOne of these fractals:\n"
+       "\t-f\tOne of these fractals:\n"
        "\t\t\tman[delbrot]\n"
        "\t\t\ttri[corn]\n"
        "\t\t\tju[lia]\n"
-       "\t-i\n\t\tInput for selected fractal. Has to be after -f option.\n"
+       "\t-w\tWidth of window in pixels\n"
+       "\t-h\tHeight of window in pixels\n"
+       "\t-u\tMaximum undersample in pixels\n"
+       "\t-d\tDetail in maximum iterations\n"
+       "\t-i\tInput for selected fractal.\n"
        "\t\t\tmandelbrot\t- no input\n"
        "\t\t\ttricorn\t\t- no input\n"
        "\t\t\tjulia\t\t- a complex number in the form real,complex\n"
        "\t\t\t\t\t- the complex number will be divided by 1000 after input\n"
-       "\t-s\n\t\tSpeed of color change (negative values reverse the direction)\n"
-       "\t-c\n\t\tColorfulness\n"
+       "\t-s\tSpeed of color change (negative values reverse the direction)\n"
+       "\t-c\tColorfulness\n"
        "\nControls:\n"
        "\tArrow keys and wasd can be used for movement.\n"
-       "\tOne can zoom in with + and zoom out with - keypad."
-       "Zoom can also be controlled with scrollwheel on the mouse.\n"
+       "\tOne can zoom in with + and zoom out with - keypad.\n"
+       "\tZoom can also be controlled with scrollwheel on the mouse.\n"
        "\tThe detail is controlled by * (increase) and / (decrease) keys.\n"
        "\tThe color change can be sped up and down with 8 and 2 keys.\n";