Xgit v0.8.0 Xgit.ConfigFile View Source
This GenServer monitors and potentially updates the contents of an on-disk git config file.
See https://git-scm.com/docs/git-config for details on the config file format.
Link to this section Summary
Types
Error codes that can be returned by remove_entries/2
.
Process ID for an Xgit.ConfigFile
process.
Functions
Returns a specification to start this module under a supervisor.
Return any configuration entries that match the requested search.
Removes all configuration entries that match the requested search.
Start a ConfigFile
for a config file at the given path.
Create or update a config value.
Link to this section Types
Error codes that can be returned by remove_entries/2
.
Process ID for an Xgit.ConfigFile
process.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
get_entries(config_file, opts \\ [])
View Sourceget_entries(config_file :: t(), section: String.t(), subsection: String.t(), name: String.t() ) :: [Xgit.ConfigEntry.t()]
Return any configuration entries that match the requested search.
Entries will be returned in the order in which they appeared in the underlying file.
Options
section:
(String
) if provided, only returns entries in the named sectionsubsection:
(String
) if provided, only returns entries in the named subsection (only meaningful ifsection
is also provided)name:
(String
) if provided, only returns entries with the given variable name (only meaningful ifsection
is also provided)
If section
is provided but subsection
is not, then only items within the top-level
section (i.e. with no subsection) will be matched.
If no options are provided, returns all entries.
A list of Xgit.ConfigEntry
structs that match the search parameters.
remove_entries(config_file, opts \\ [])
View Sourceremove_entries(config_file :: t(), section: String.t(), subsection: String.t(), name: String.t() ) :: :ok | {:error, reason :: remove_entries_reason()}
Removes all configuration entries that match the requested search.
Options
section:
(String
) if provided, only removes entries in the named sectionsubsection:
(String
) if provided, only removes entries in the named subsection (only meaningful ifsection
is also provided)name:
(String
) if provided, only removes entries with the given variable name (only meaningful ifsection
is also provided)
If section
is provided but subsection
is not, then only items within the top-level
section (i.e. with no subsection) will be removed.
If no options are provided, removes all entries.
Returns :ok
regardless of whether any matching entries were found and removed.
start_link(path)
View Sourcestart_link(path :: Path.t()) :: GenServer.on_start()
Start a ConfigFile
for a config file at the given path.
The path (including parent directory) needs to exist, but there need not be a file at this path.
Create or update a config value.
Parameters
value
(nil
or String
) value to be added to this variable
Options
section
: required section to add the value tosubsection
: (optional) subsection to add the value toname
: required name of variable to update or replaceadd?
: iftrue
, adds this value to any that may already existreplace_all?
: iftrue
, removes all existing entries that match any keys provided
Return Values
:ok
if successful.
{:error, :replacing_multivar}
if the existing variable has multiple variables.
Replacing such a variable requires either add?: true
or replace_all?: true
.