···401401 parameter overrides the two previous ways. See
402402 {{!args_detect_absent}this} example. }}
403403404404+{2:args_completion How can I customize positional and option value completion?}
405405+406406+Positional argument values and option values are completed according
407407+to the {{!Cmdliner.Arg.argconv}argument converter} you use for defining
408408+the optional or positional argument.
409409+410410+A couple of predefined argument converter like {!Cmdliner.Arg.path},
411411+{!Cmdliner.Arg.filepath} and {!Cmdliner.Arg.dirpath} or
412412+{!Cmdliner.Arg.enum} automatically handle this for you.
413413+414414+If you would like to perform custom or more elaborate context
415415+sensitive completions you can define your own argument converter with
416416+with a completion defined with {!Cmdliner.Arg.Completion.make}.
417417+418418+Here is an example where the first positional argument is completed
419419+with the filenames found in a directory specified via the [--dir]
420420+option (which defaults to the current working directory if unspecified).
421421+{[
422422+let dir = Arg.(value & opt dirpath "." & info ["d"; "dir"])
423423+let dir_filenames_conv =
424424+ let complete dir ~token = match dir with
425425+ | None -> Error "Could not determine directory to lookup"
426426+ | Some dir ->
427427+ match Array.to_list (Sys.readdir dir) with
428428+ | exception Sys_error e -> Error (String.concat ": " [dir; e])
429429+ | fnames ->
430430+ let fnames = List.filter (String.starts_with ~prefix:token) fnames in
431431+ Ok (List.map Arg.Completion.string fnames)
432432+ in
433433+ let completion = Arg.Completion.make ~context:dir complete in
434434+ Arg.Conv.of_conv ~completion Arg.string
435435+436436+let pos0 = Arg.(required & pos 0 (some dir_filenames_conv) None & info [])
437437+]}
438438+439439+Note that when you use [pos0] in a command line definition you also
440440+need to make sure [dir] is part of the term otherwise the context will
441441+always be [None]:
442442+443443+{[
444444+let+ pos0 and+ dir and+ … in …
445445+]}
446446+404447{1:envs Environment variables}
405448406449{2:env_args How can environment variables define defaults?}