pub enum ResourceTarget {
GlobalShared,
GlobalWorkflow(String),
Cwd,
}Expand description
Where an add or remove command should place / look for a resource.
Constructed with ResourceTarget::from_flags, which enforces the
mutually-exclusive flag rules (a target must be unambiguous).
Variants§
~/.zig/resources/_shared/
GlobalWorkflow(String)
~/.zig/resources/<workflow>/
Cwd
<git-root>/.zig/resources/ — falls back to ./.zig/resources/ when
not inside a git repo.
Implementations§
Source§impl ResourceTarget
impl ResourceTarget
Sourcepub fn from_flags(
workflow: Option<&str>,
global: bool,
cwd: bool,
) -> Result<Self, ZigError>
pub fn from_flags( workflow: Option<&str>, global: bool, cwd: bool, ) -> Result<Self, ZigError>
Resolve a target from the CLI flag combination passed by the user.
Rules:
--workflow <name>always means the global per-workflow tier.--cwdmeans the project tier.--global(without--workflow) means the global shared tier.- No flags at all is treated as
--cwd(the most local tier).
Sourcepub fn ensure_dir(&self) -> Result<PathBuf, ZigError>
pub fn ensure_dir(&self) -> Result<PathBuf, ZigError>
Resolve to an absolute directory path, creating it if it doesn’t exist.
Sourcepub fn existing_dir(&self) -> Option<PathBuf>
pub fn existing_dir(&self) -> Option<PathBuf>
Resolve to an absolute directory path without creating it. Returns
None when the directory cannot be derived (e.g. $HOME unset).
Trait Implementations§
Source§impl Clone for ResourceTarget
impl Clone for ResourceTarget
Source§fn clone(&self) -> ResourceTarget
fn clone(&self) -> ResourceTarget
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ResourceTarget
impl RefUnwindSafe for ResourceTarget
impl Send for ResourceTarget
impl Sync for ResourceTarget
impl Unpin for ResourceTarget
impl UnsafeUnpin for ResourceTarget
impl UnwindSafe for ResourceTarget
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