From 4a337cd33b1e1f1fced4a630f3541226af8dd7e9 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 11 Apr 2016 17:06:50 +0200 Subject: [PATCH] fish: improve formatting of help text of generated commands In the generated description of the guestfish commands, wrap and indent the help text, so it is a multiline string instead of a very long single one. This has no behaviour changes, only makes cmds.c more readable (and easier to diff when the description of actions change). --- generator/fish.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generator/fish.ml b/generator/fish.ml index 864f65d21..646674df7 100644 --- a/generator/fish.ml +++ b/generator/fish.ml @@ -71,6 +71,11 @@ let all_functions_commands_and_aliases_sorted = ) (fish_functions_sorted @ fish_commands) [] in List.sort func_compare all +let c_quoted_indented ~indent str = + let str = c_quote str in + let str = replace_str str "\\n" ("\\n\"\n" ^ indent ^ "\"") in + str + (* Generate a lot of different functions for guestfish. *) let generate_fish_cmds () = generate_header CStyle GPLv2plus; @@ -138,7 +143,7 @@ let generate_fish_cmds () = pr "struct command_entry %s_cmd_entry = {\n" name; pr " .name = \"%s\",\n" name2; - pr " .help = \"%s\",\n" (c_quote text); + pr " .help = \"%s\",\n" (c_quoted_indented ~indent:" " text); pr " .synopsis = NULL,\n"; pr " .run = run_%s\n" name; pr "};\n"; @@ -200,7 +205,7 @@ Guestfish will prompt for these separately." pr "struct command_entry %s_cmd_entry = {\n" name; pr " .name = \"%s\",\n" name2; - pr " .help = \"%s\",\n" (c_quote text); + pr " .help = \"%s\",\n" (c_quoted_indented ~indent:" " text); pr " .synopsis = \"%s\",\n" (c_quote synopsis); pr " .run = run_%s\n" name; pr "};\n";