pub struct WorkonConfig<'repo> { /* private fields */ }Expand description
Configuration reader for workon settings stored in git config.
This struct provides access to workon-specific configuration keys, handling precedence between CLI arguments, local config, and global config.
Implementations§
Source§impl<'repo> WorkonConfig<'repo>
impl<'repo> WorkonConfig<'repo>
Sourcepub fn new(repo: &'repo Repository) -> Result<Self>
pub fn new(repo: &'repo Repository) -> Result<Self>
Create a new config reader for the given repository.
This opens the repository’s git config, which automatically handles precedence: local config (.git/config) > global config (~/.gitconfig) > system config.
Sourcepub fn default_branch(
&self,
cli_override: Option<&str>,
) -> Result<Option<String>>
pub fn default_branch( &self, cli_override: Option<&str>, ) -> Result<Option<String>>
Get the default branch to use when creating new worktrees.
Precedence: CLI override > workon.defaultBranch config > None
Returns None if not configured. Callers can fall back to init.defaultBranch or “main”.
Sourcepub fn pr_format(&self, cli_override: Option<&str>) -> Result<String>
pub fn pr_format(&self, cli_override: Option<&str>) -> Result<String>
Get the format string for PR-based worktree names.
Precedence: CLI override > workon.prFormat config > “pr-{number}”
The format string must contain {number} placeholder for the PR number.
Returns an error if the format is invalid.
Sourcepub fn post_create_hooks(&self) -> Result<Vec<String>>
pub fn post_create_hooks(&self) -> Result<Vec<String>>
Get the list of post-create hook commands to run after worktree creation.
Reads from multi-value workon.postCreateHook config. Returns empty Vec if not configured.
Sourcepub fn copy_patterns(&self) -> Result<Vec<String>>
pub fn copy_patterns(&self) -> Result<Vec<String>>
Get the list of glob patterns for files to copy between worktrees.
Reads from multi-value workon.copyPattern config. Returns empty Vec if not configured.
Sourcepub fn copy_excludes(&self) -> Result<Vec<String>>
pub fn copy_excludes(&self) -> Result<Vec<String>>
Get the list of glob patterns for files to exclude from copying.
Reads from multi-value workon.copyExclude config. Returns empty Vec if not configured.
Sourcepub fn copy_include_ignored(&self, cli_override: Option<bool>) -> Result<bool>
pub fn copy_include_ignored(&self, cli_override: Option<bool>) -> Result<bool>
Get whether to include git-ignored files when copying untracked files.
Precedence: CLI override > workon.copyIncludeIgnored config > false
When enabled, files matching .gitignore (e.g., .env.local, node_modules/)
will also be included as copy candidates.
Sourcepub fn auto_copy_untracked(&self, cli_override: Option<bool>) -> Result<bool>
pub fn auto_copy_untracked(&self, cli_override: Option<bool>) -> Result<bool>
Get whether to automatically copy untracked files when creating new worktrees.
Precedence: CLI override > workon.autoCopyUntracked config > false
When enabled, files matching workon.copyPattern (excluding workon.copyExclude) will be automatically copied from the base worktree to the new worktree.
Sourcepub fn prune_protected_branches(&self) -> Result<Vec<String>>
pub fn prune_protected_branches(&self) -> Result<Vec<String>>
Get the list of branch patterns to protect from pruning.
Reads from multi-value workon.pruneProtectedBranches config. Patterns support simple glob matching (* and ?). Returns empty Vec if not configured.
Sourcepub fn is_protected(&self, branch_name: &str) -> bool
pub fn is_protected(&self, branch_name: &str) -> bool
Check if a given branch name is protected from pruning.
Returns true if the branch name matches any of the protected patterns.
Sourcepub fn hook_timeout(&self) -> Result<Duration>
pub fn hook_timeout(&self) -> Result<Duration>
Get the timeout duration for hook execution.
Reads from workon.hookTimeout config (integer seconds). Default: 300 seconds (5 minutes). A value of 0 disables the timeout.
Auto Trait Implementations§
impl<'repo> Freeze for WorkonConfig<'repo>
impl<'repo> RefUnwindSafe for WorkonConfig<'repo>
impl<'repo> !Send for WorkonConfig<'repo>
impl<'repo> !Sync for WorkonConfig<'repo>
impl<'repo> Unpin for WorkonConfig<'repo>
impl<'repo> UnsafeUnpin for WorkonConfig<'repo>
impl<'repo> UnwindSafe for WorkonConfig<'repo>
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
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more