package bap-std
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9c126781385d2fa9b8edab22e62b25c70bf2f99f6ec78abb7e5e36d63cfa4174
md5=5abd9b3628b43f797326034f31ca574f
doc/bap/Bap/Std/Self/Config/index.html
Module Self.Config
This module allows plugins to access BAP configuration variables.
When reading the values for the configuration variables, the decreasing order of precedence for the values is:
- Command line arguments
- Environment variables
- Configuration file
- Default fallback value
Example usage:
let path = Config.(param string ~doc:"a path to file"
~default:"input.txt" "path")
let debug = Config.(flag (* ... *) )
(* ... *)
let main () =
Config.when_ready
(fun {Config.get=(!)} ->
do_stuff !path !debug (* ... *)
)A directory for bap specific object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts
val converter :
'a parser ->
(Format.formatter -> 'a -> unit) ->
'a ->
'a converterval param :
'a converter ->
?deprecated:string ->
?default:'a ->
?as_flag:'a ->
?docv:string ->
?doc:string ->
?synonyms:string list ->
string ->
'a paramparam conv ~default ~docv ~doc name creates a parameter which is referred to on the command line, environment variable, and config file using the value of name, with the type defined by conv, using the default value if unspecified by user.
The default is optional, and falls back to the default defined by conv.
doc is the man page information of the argument. The variable "$(docv)" can be used to refer to the value of docv. docv is a variable name used in the man page to stand for their value.
A user can optionally add deprecated to a parameter that is to be deprecated soon. This will cause the parameter to be usable as normal, but will emit a warning to the user if they try to use it. Example usage: Config.(param ~deprecated int "--old").
Additionally, synonyms can be added to allow multiple arguments referring to the same parameters. However, this is usually discouraged, and considered proper usage only in rare scenarios.
Also, a developer can use the ~as_flag to specify a default value that the argument takes if it is used like a flag. This behaviour can be understood better through the following example.
Consider Config.(param (some int) ~as_flag:(Some 10) "x").
This results in 3 possible command line invocations:
1. No --x - Results in default value (specifically here, None).
2. Only --x - This causes it to have the value as_flag (specifically here,Some 10).
3. --x=20 - This causes it to have the value from the command line (specifically here, Some 20).
val param_all :
'a converter ->
?deprecated:string ->
?default:'a list ->
?as_flag:'a ->
?docv:string ->
?doc:string ->
?synonyms:string list ->
string ->
'a list paramCreate a parameter which accepts a list at command line by repetition of argument. Similar to param (list 'a) ... in all other respects. Defaults to an empty list if unspecified.
val flag :
?deprecated:string ->
?docv:string ->
?doc:string ->
?synonyms:string list ->
string ->
bool paramCreate a boolean parameter that is set to true if user mentions it in the command line arguments
val determined : 'a param -> 'a Bap_future.Std.futureProvides a future determined on when the config can be read
A witness that can read configured params
val when_ready : (reader -> unit) -> unitwhen_ready f requests the system to call function f once configuration parameters are established and stabilized. An access function will be passed to the function f, that can be used to safely dereference parameters.
The type for a block of man page text.
`S sintroduces a new sections.`P tis a new paragraph with textt.`Pre tis a new preformatted paragraph with textt.`I (l,t)is an indented paragraph with labelland textt.`Noblanksuppresses the blank line introduced between two blocks.
Except in `Pre, whitespace and newlines are not significant and are all collapsed to a single space. In labels l and text strings t, the syntax "$(i,italic text)" and "$(b,bold text)" can be used to respectively produce italic and bold text.
val manpage : manpage_block list -> unitCreate a manpage for the plugin
val bool : bool converterbool converts values with bool_of_string.
val char : char converterchar converts values by ensuring the argument has a single char.
val int : int converterint converts values with int_of_string.
val nativeint : nativeint converternativeint converts values with Nativeint.of_string.
val int32 : int32 converterint32 converts values with Int32.of_string.
val int64 : int64 converterint64 converts values with Int64.of_string.
val float : float converterfloat converts values with float_of_string.
val string : string converterstring converts values with the identity function.
val enum : (string * 'a) list -> 'a converterenum l converts values such that unambiguous prefixes of string names in l map to the corresponding value of type 'a.
Warning. The type 'a must be comparable with Pervasives.compare.
doc_enum l documents the possible string names in the l map according to the number of alternatives. If quoted is true (default), the tokens are quoted. The resulting string can be used in sentences of the form "$(docv) must be %s".
val file : string converterfile converts a value with the identity function and checks with Sys.file_exists that a file with that name exists.
val dir : string converterdir converts a value with the identity function and checks with Sys.file_exists and Sys.is_directory that a directory with that name exists.
val non_dir_file : string converternon_dir_file converts a value with the identity function and checks with Sys.file_exists and Sys.is_directory that a non directory file with that name exists.
list sep c splits the argument at each sep (defaults to ',') character and converts each substrings with c.
array sep c splits the argument at each sep (defaults to ',') character and converts each substring with c.
pair sep c0 c1 splits the argument at the first sep character (defaults to ',') and respectively converts the substrings with c0 and c1.
t3 sep c0 c1 c2 splits the argument at the first two sep characters (defaults to ',') and respectively converts the substrings with c0, c1 and c2.