pub enum SpecCommandEffect {
Read,
Write,
Destructive,
}Expand description
What running a command does to the world.
This is a coarse, three-way classification rather than a permission model. It exists so a spec can distinguish “safe to run to find something out” from “changes state” from “may destroy something”, which is the distinction consumers keep reinventing:
- documentation and
--helpcan mark destructive commands - a shell wrapper can require confirmation
- an AI coding agent can be given an allowlist of read-only commands rather than asking about every invocation
It is deliberately not inherited by subcommands. git remote and
git remote remove do different things, and silently inheriting an effect
from a parent would make the strictest reading of a spec the wrong one.
Flags and arguments may carry an effect too, for commands whose danger
depends on how they are invoked — pitchfork logs reads, pitchfork logs --clear deletes. A flag or argument can only ever raise the effect, never
lower it, so a consumer that cannot parse the invocation may fall back to
the maximum over the command and all of its flags and arguments and still be
safe. --dry-run is the tempting counterexample; lowering is the dangerous
direction, because a bug in the dry-run path would then be a spec that
claims a command is safe when it is not.
Ordered least to most dangerous, so Ord gives the combining rule: the
effect of an invocation is the maximum of the command’s effect and the
effect of every flag and argument actually supplied.
Variants§
Read
Only inspects state. Running it twice is the same as running it once, and not running it changes nothing.
Write
Creates or modifies state, but does not remove anything the user cannot recreate by running another command.
Destructive
May delete or irreversibly overwrite something. Deserves a confirmation prompt.
Implementations§
Trait Implementations§
Source§impl Clone for SpecCommandEffect
impl Clone for SpecCommandEffect
Source§fn clone(&self) -> SpecCommandEffect
fn clone(&self) -> SpecCommandEffect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SpecCommandEffect
Source§impl Debug for SpecCommandEffect
impl Debug for SpecCommandEffect
Source§impl Display for SpecCommandEffect
impl Display for SpecCommandEffect
impl Eq for SpecCommandEffect
Source§impl FromStr for SpecCommandEffect
impl FromStr for SpecCommandEffect
Source§impl Ord for SpecCommandEffect
impl Ord for SpecCommandEffect
Source§fn cmp(&self, other: &SpecCommandEffect) -> Ordering
fn cmp(&self, other: &SpecCommandEffect) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SpecCommandEffect
impl PartialEq for SpecCommandEffect
Source§impl PartialOrd for SpecCommandEffect
impl PartialOrd for SpecCommandEffect
Source§impl Serialize for SpecCommandEffect
impl Serialize for SpecCommandEffect
impl StructuralPartialEq for SpecCommandEffect
Auto Trait Implementations§
impl Freeze for SpecCommandEffect
impl RefUnwindSafe for SpecCommandEffect
impl Send for SpecCommandEffect
impl Sync for SpecCommandEffect
impl Unpin for SpecCommandEffect
impl UnsafeUnpin for SpecCommandEffect
impl UnwindSafe for SpecCommandEffect
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more