pub struct ConfigEditor { /* private fields */ }Expand description
Edit a config file outside an open Repository (global, system, or -f path).
Implementations§
Source§impl ConfigEditor
impl ConfigEditor
Sourcepub fn global(env: &Environment) -> Result<Self>
pub fn global(env: &Environment) -> Result<Self>
Open the per-user global config file for writes (respects GIT_CONFIG_GLOBAL / XDG).
§Errors
Returns ConfigError::NoGlobalConfigPath when no global path can be resolved.
Sourcepub fn system(env: &Environment) -> Self
pub fn system(env: &Environment) -> Self
Open the system config file for writes.
Sourcepub fn open(env: &Environment, path: PathBuf, file_scope: ConfigScope) -> Self
pub fn open(env: &Environment, path: PathBuf, file_scope: ConfigScope) -> Self
Open an explicit config file (for example grit config -f path).
file_scope is the scope stored in parsed entries (typically ConfigScope::Local).
Sourcepub fn set(
&self,
key: &str,
value: &str,
options: &ConfigWriteOptions,
) -> Result<Option<ConfigWritePreview>>
pub fn set( &self, key: &str, value: &str, options: &ConfigWriteOptions, ) -> Result<Option<ConfigWritePreview>>
Set key to value, replacing an existing single-valued key.
Sourcepub fn add_value(
&self,
key: &str,
value: &str,
options: &ConfigWriteOptions,
) -> Result<Option<ConfigWritePreview>>
pub fn add_value( &self, key: &str, value: &str, options: &ConfigWriteOptions, ) -> Result<Option<ConfigWritePreview>>
Append value for a multi-valued key.
Sourcepub fn unset(
&self,
key: &str,
options: &ConfigWriteOptions,
) -> Result<Option<ConfigWritePreview>>
pub fn unset( &self, key: &str, options: &ConfigWriteOptions, ) -> Result<Option<ConfigWritePreview>>
Remove the last value for key.
Sourcepub fn unset_all(
&self,
key: &str,
options: &ConfigWriteOptions,
) -> Result<(usize, Option<ConfigWritePreview>)>
pub fn unset_all( &self, key: &str, options: &ConfigWriteOptions, ) -> Result<(usize, Option<ConfigWritePreview>)>
Remove every value for key, optionally filtered by ConfigWriteOptions::unset_value_pattern.
Sourcepub fn rename_section(
&self,
old_name: &str,
new_name: &str,
options: &ConfigWriteOptions,
) -> Result<Option<ConfigWritePreview>>
pub fn rename_section( &self, old_name: &str, new_name: &str, options: &ConfigWriteOptions, ) -> Result<Option<ConfigWritePreview>>
Rename a section in the file.
Sourcepub fn remove_section(
&self,
section: &str,
options: &ConfigWriteOptions,
) -> Result<Option<ConfigWritePreview>>
pub fn remove_section( &self, section: &str, options: &ConfigWriteOptions, ) -> Result<Option<ConfigWritePreview>>
Remove an entire section from the file.
Trait Implementations§
Source§impl Clone for ConfigEditor
impl Clone for ConfigEditor
Auto Trait Implementations§
impl Forget for ConfigEditor
impl Freeze for ConfigEditor
impl RefUnwindSafe for ConfigEditor
impl Send for ConfigEditor
impl Sync for ConfigEditor
impl Unpin for ConfigEditor
impl UnsafeUnpin for ConfigEditor
impl UnwindSafe for ConfigEditor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more