X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_fish.ml;h=3d52421b9e255690c23789959e128c2eca847225;hb=54e91da925323642e67b8ce4b95899fe4b7a51c4;hp=dc2dc3eae0ae29d53009bf320bf04677f8bb3ee8;hpb=3064277680ad11f887691646d0fa17bb35f38c19;p=libguestfs.git diff --git a/generator/generator_fish.ml b/generator/generator_fish.ml index dc2dc3e..3d52421 100644 --- a/generator/generator_fish.ml +++ b/generator/generator_fish.ml @@ -30,6 +30,13 @@ open Generator_structs open Generator_prepopts open Generator_c +let doc_opttype_of = function + | Bool n -> "true|false" + | Int n + | Int64 n -> "N" + | String n -> ".." + | _ -> assert false + (* Generate a lot of different functions for guestfish. *) let generate_fish_cmds () = generate_header CStyle GPLv2plus; @@ -122,7 +129,9 @@ let generate_fish_cmds () = (String.concat "" (List.map (fun arg -> " " ^ name_of_argt arg) args)) (String.concat "" - (List.map (fun arg -> sprintf " [%s:..]" (name_of_argt arg)) optargs)) in + (List.map (fun arg -> + sprintf " [%s:%s]" (name_of_argt arg) (doc_opttype_of arg) + ) optargs)) in let warnings = if List.exists (function Key _ -> true | _ -> false) args then @@ -136,16 +145,6 @@ Guestfish will prompt for these separately." ("\n\n" ^ protocol_limit_warning) else "" in - (* For DangerWillRobinson commands, we should probably have - * guestfish prompt before allowing you to use them (especially - * in interactive mode). XXX - *) - let warnings = - warnings ^ - if List.mem DangerWillRobinson flags then - ("\n\n" ^ danger_will_robinson) - else "" in - let warnings = warnings ^ match deprecation_notice flags with @@ -174,7 +173,8 @@ Guestfish will prompt for these separately." ) all_functions; (* list_commands function, which implements guestfish -h *) - pr "void list_commands (void)\n"; + pr "void\n"; + pr "list_commands (void)\n"; pr "{\n"; pr " printf (\" %%-16s %%s\\n\", _(\"Command\"), _(\"Description\"));\n"; pr " list_builtin_commands ();\n"; @@ -190,7 +190,8 @@ Guestfish will prompt for these separately." pr "\n"; (* display_command function, which implements guestfish -h cmd *) - pr "int display_command (const char *cmd)\n"; + pr "int\n"; + pr "display_command (const char *cmd)\n"; pr "{\n"; pr " const struct command_table *ct;\n"; pr "\n"; @@ -205,7 +206,8 @@ Guestfish will prompt for these separately." pr "\n"; let emit_print_list_function typ = - pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n" + pr "static void\n"; + pr "print_%s_list (struct guestfs_%s_list *%ss)\n" typ typ typ; pr "{\n"; pr " unsigned int i;\n"; @@ -225,7 +227,8 @@ Guestfish will prompt for these separately." let needs_i = List.exists (function (_, (FUUID|FBuffer)) -> true | _ -> false) cols in - pr "static void print_%s_indent (struct guestfs_%s *%s, const char *indent)\n" typ typ typ; + pr "static void\n"; + pr "print_%s_indent (struct guestfs_%s *%s, const char *indent)\n" typ typ typ; pr "{\n"; if needs_i then ( pr " unsigned int i;\n"; @@ -264,9 +267,11 @@ Guestfish will prompt for these separately." pr " printf (\"%%s%s: %%c\\n\", indent, %s->%s);\n" name typ name | name, FOptPercent -> - pr " if (%s->%s >= 0) printf (\"%%s%s: %%g %%%%\\n\", indent, %s->%s);\n" - typ name name typ name; - pr " else printf (\"%%s%s: \\n\", indent);\n" name + pr " if (%s->%s >= 0)\n" typ name; + pr " printf (\"%%s%s: %%g %%%%\\n\", indent, (double) %s->%s);\n" + name typ name; + pr " else\n"; + pr " printf (\"%%s%s: \\n\", indent);\n" name ) cols; pr "}\n"; pr "\n"; @@ -285,7 +290,8 @@ Guestfish will prompt for these separately." List.iter ( function | typ, (RStructOnly | RStructAndList) -> - pr "static void print_%s (struct guestfs_%s *%s)\n" typ typ typ; + pr "static void\n"; + pr "print_%s (struct guestfs_%s *%s)\n" typ typ typ; pr "{\n"; pr " print_%s_indent (%s, \"\");\n" typ typ; pr "}\n"; @@ -844,7 +850,8 @@ and generate_fish_actions_pod () = ) args; List.iter ( function - | Bool n | Int n | Int64 n | String n -> pr " [%s:..]" n + | (Bool n | Int n | Int64 n | String n) as arg -> + pr " [%s:%s]" n (doc_opttype_of arg) | _ -> assert false ) optargs; pr "\n"; @@ -865,9 +872,6 @@ Guestfish will prompt for these separately.\n\n"; if List.mem ProtocolLimitWarning flags then pr "%s\n\n" protocol_limit_warning; - if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson; - match deprecation_notice flags with | None -> () | Some txt -> pr "%s\n\n" txt