From 627f2c1d001b49cccf07baacbcf4f1a220e76bbe Mon Sep 17 00:00:00 2001 From: John Haugabook Date: Thu, 31 Jul 2025 12:49:15 -0400 Subject: [PATCH] edit data, two structs, remove unneeded Apply suggestions, editing data by capitalizing first letter and sort by heading, use two struct members for cheat_table, and remove unneeded condition. --- src/tool_help.c | 70 ++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/tool_help.c b/src/tool_help.c index f11d867fe6..5bc1511743 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -408,32 +408,33 @@ void tool_list_engines(void) curl_easy_cleanup(curl); } -/* Functions for outputting cheat-sheet argument. */ -/* Cheat sheet data structure organized by heading and value. */ +/* Functions for outputting cheat-sheet argument. + Cheat sheet data structure organized by heading and option. */ static const struct cheat_table { - const char *heading[2]; + const char *head; + const char *opt; } cheat_items[] = { - {{"Verbose", "-v, --trace-ascii file"}}, - {{"Hide progress", "-s"}}, - {{"extra info", "-w format"}}, - {{"Write output", "-O, -o file"}}, - {{"Timeout", "-m secs"}}, - {{"POST", "-d string, -d @file"}}, - {{"multipart", "-F name=value, -F name=@file"}}, - {{"PUT", "-T file"}}, - {{"HEAD", "-I"}}, - {{"custom", "-X METHOD"}}, - {{"Basic auth", "-u user:password"}}, - {{"read cookies", "-b "}}, - {{"write cookies", "-c "}}, - {{"send cookies", "-b \"c=1; d=2\""}}, - {{"user-agent", "-A string"}}, - {{"Use proxy", "-x host:port"}}, - {{"Headers add/remove", "-H \"name: value\", -H name:"}}, - {{"follow redirs", "-L"}}, - {{"gzip", "--compressed"}}, - {{"insecure", "-k"}}, - {{NULL, NULL}} + {"Basic auth", "-u user:password"}, + {"Custom", "-X METHOD"}, + {"Extra info", "-w format"}, + {"Follow redirs", "-L"}, + {"Gzip", "--compressed"}, + {"Head", "-I"}, + {"Headers add/remove", "-H \"name: value\", -H name:"}, + {"Hide progress", "-s"}, + {"Insecure", "-k"}, + {"Multipart", "-F name=value, -F name=@file"}, + {"Post", "-d string, -d @file"}, + {"Put", "-T file"}, + {"Read cookies", "-b "}, + {"Send cookies", "-b \"c=1; d=2\""}, + {"Timeout", "-m secs"}, + {"Use proxy", "-x host:port"}, + {"User-agent", "-A string"}, + {"Verbose", "-v, --trace-ascii file"}, + {"Write cookies", "-c "}, + {"Write output", "-O, -o file"}, + {NULL, NULL} }; /* Support to print number of columns per screen width. */ @@ -443,23 +444,22 @@ static void print_cheatsheet(size_t i, size_t col_num) size_t c; for(c = 0; c < col_num; c++) { - /* The headers */ - if(cheat_items[c + i].heading[0]) - printf("%-30s ", cheat_items[c + i].heading[0]); + /* The headings. */ + if(cheat_items[c + i].head) + printf("%-30s ", cheat_items[c + i].head); else { - col_num = c; /* redefine for uneven rows */ + col_num = c; /* Redefine for uneven rows. */ break; } } puts(""); for(c = 0; c < col_num; c++) - printf("------------------------------ "); /* The separators */ + printf("------------------------------ "); /* The separators. */ puts(""); - for(c = 0; c < col_num; c++) { - /* The options */ - if(cheat_items[c + i].heading[1]) - printf("%-30s ", cheat_items[c + i].heading[1]); - } + + /* The options. */ + for(c = 0; c < col_num; c++) + printf("%-30s ", cheat_items[c + i].opt); puts("\n"); } @@ -476,7 +476,7 @@ void tool_cheat_sheet(void) else if(j == 0) j = 1; - /* Loop through cheat sheet sections */ + /* Loop through cheat sheet sections. */ for(i = 0; i < CURL_ARRAYSIZE(cheat_items); i += j) print_cheatsheet(i, j); }