package argsh

  1. Overview
  2. Docs

Source file fish.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(******************************************************************************)
(*  Copyright 2023 Gurvan Debaussart                                          *)
(*  This file is distributed under the MIT license.                           *)
(*  https://codeberg.org/gurvan/argsh                                         *)
(******************************************************************************)

open Common
open Format

let create out executable_name args =

  let args_to_cmd (key, _, doc) =
    let doc = treat_doc doc
            |> escape_char '\''
    in
    sprintf "complete -c %s -a \"%s\" -d '%s'" executable_name key doc
  in

  let args =  add_help args
           |> List.map args_to_cmd
           |> String.concat "\n"
  in

  fprintf out
{|# %s

%s|}
  msg args
OCaml

Innovation. Community. Security.