have_terminfo = 1;
}
-void
-pod2text (const char *name, const char *shortdesc, const char *str)
-{
- FILE *fp;
-
- fp = popen ("pod2text", "w");
- if (fp == NULL) {
- /* pod2text failed, maybe not found, so let's just print the
- * source instead, since that's better than doing nothing.
- */
- printf ("%s - %s\n\n%s\n", name, shortdesc, str);
- return;
- }
- fprintf (fp, "=head1 NAME\n\n%s - %s\n\n", name, shortdesc);
- fputs (str, fp);
- pclose (fp);
-}
-
static void
prepare_drives (struct drv *drv)
{
extern int remote_control_csh;
extern const char *libvirt_uri;
extern int issue_command (const char *cmd, char *argv[], const char *pipe);
-extern void pod2text (const char *name, const char *shortdesc, const char *body);
extern void list_builtin_commands (void);
extern int display_builtin_command (const char *cmd);
extern void free_strings (char **argv);
(* List of command_entry structs. *)
List.iter (
fun (name, _, _, flags, _, shortdesc, longdesc) ->
- pr "struct command_entry %s_cmd_entry = {\n" name;
-
let name2 = replace_char name '_' '-' in
- pr " .name = \"%s\",\n" name2;
-
let aliases =
filter_map (function FishAlias n -> Some n | _ -> None) flags in
let describe_alias =
(String.concat " or " (List.map (fun s -> "'" ^ s ^ "'") aliases))
else "" in
- pr " .shortdesc = \"%s\",\n" shortdesc;
- pr " .podbody = %S,\n"
- ("=head1 DESCRIPTION\n\n" ^ longdesc ^ describe_alias);
+ let pod =
+ sprintf "%s - %s\n\n=head1 DESCRIPTION\n\n%s\n\n%s"
+ name2 shortdesc longdesc describe_alias in
+ let text =
+ String.concat "\n" (pod2text ~trim:false ~discard:false "NAME" pod)
+ ^ "\n" in
+ pr "struct command_entry %s_cmd_entry = {\n" name;
+ pr " .name = \"%s\",\n" name2;
+ pr " .help = \"%s\",\n" (c_quote text);
pr " .run = run_%s\n" name;
pr "};\n";
pr "\n";
List.iter (
fun (name, (_, args, optargs), _, flags, _, shortdesc, longdesc) ->
- pr "struct command_entry %s_cmd_entry = {\n" name;
-
let name2 = replace_char name '_' '-' in
- pr " .name = \"%s\",\n" name2;
-
let aliases =
filter_map (function FishAlias n -> Some n | _ -> None) flags in
(String.concat " or " (List.map (fun s -> "'" ^ s ^ "'") aliases))
else "" in
- pr " .shortdesc = \"%s\",\n" shortdesc;
- pr " .podbody = %S,\n"
- ("=head1 SYNOPSIS\n\n " ^ synopsis ^ "\n\n" ^
- "=head1 DESCRIPTION\n\n" ^
- longdesc ^ warnings ^ describe_alias);
+ let pod =
+ sprintf "%s - %s\n\n=head1 SYNOPSIS\n\n %s\n\n=head1 DESCRIPTION\n\n%s%s%s"
+ name2 shortdesc synopsis longdesc warnings describe_alias in
+ let text =
+ String.concat "\n" (pod2text ~trim:false ~discard:false "NAME" pod)
+ ^ "\n" in
+ pr "struct command_entry %s_cmd_entry = {\n" name;
+ pr " .name = \"%s\",\n" name2;
+ pr " .help = \"%s\",\n" (c_quote text);
pr " .run = run_%s\n" name;
pr "};\n";
pr "\n";
pr "\n";
pr " ct = lookup_fish_command (cmd, strlen (cmd));\n";
pr " if (ct) {\n";
- pr " pod2text (ct->entry->name, ct->entry->shortdesc, ct->entry->podbody);\n";
+ pr " fputs (ct->entry->help, stdout);\n";
pr " return 0;\n";
pr " }\n";
pr " else\n";