Skip to content

Commit 4b01097

Browse files
Merge pull request #42 from shaswatcodes28/main
added menu to display all options
2 parents 2ee64f4 + 00744a3 commit 4b01097

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

filter.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,43 @@
77
int main(int argc, char *argv[])
88
{
99
// Define allowable filters
10-
char *filters = "bgrsivtdGoB:";
10+
char *filters = "bgrsivtmdGoB:";
1111

1212

1313
char filterArr[argc-3];
1414
int filterCount = 0;
1515

1616
// gets all filter flags and checks validity
1717
int opt;
18-
while ((opt = getopt(argc, argv, filters)) != -1) {
19-
if (opt == '?') {
20-
printf("Invalid filter option\n");
21-
return 1;
22-
}
23-
filterArr[filterCount++] = opt;
18+
while ((opt = getopt(argc, argv, filters)) != -1)
19+
{
20+
if (opt == '?')
21+
{
22+
printf("Invalid filter option\n");
23+
return 1;
2424
}
25-
2625

27-
// Ensure proper usage
26+
if (opt == 'm')
27+
{
28+
printf("\nAvailable filters:\n");
29+
printf(" -b Blur\n");
30+
printf(" -g Grayscale\n");
31+
printf(" -r Reflect\n");
32+
printf(" -s Sepia\n");
33+
printf(" -i Invert\n");
34+
printf(" -v Vignette\n");
35+
printf(" -t Threshold\n");
36+
printf(" -d Detect edges\n");
37+
printf(" -B <value> Adjust brightness\n");
38+
printf(" -G Glow\n");
39+
printf(" -o Oil paint\n");
40+
printf(" -m Show this menu\n\n");
41+
return 0;
42+
}
43+
44+
filterArr[filterCount++] = opt;
45+
}
46+
2847
if (argc < optind + 2)
2948
{
3049
printf("Usage: ./filter [flag] infile outfile\n");

filter.exe

-55.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)