Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Add `--draft` to `patch list` command
Alexis Sellier committed 3 years ago
commit 0ecd8fb0741cbb93e8e451d9404a6630372967ad
parent 12a91bd0ae5f5de3a096ab4aaac735fe61e8a6e9
2 files changed +14 -5
modified radicle-cli/src/commands/patch.rs
@@ -40,7 +40,7 @@ pub const HELP: Help = Help {
Usage

    rad patch [<option>...]
-
    rad patch list [--all|--merged|--open|--archived] [<option>...]
+
    rad patch list [--all|--merged|--open|--archived|--draft] [<option>...]
    rad patch show <patch-id> [<option>...]
    rad patch open [--draft] [<option>...]
    rad patch archive <patch-id> [<option>...]
@@ -68,6 +68,7 @@ List options
        --archived             Show only archived patches
        --merged               Show only merged patches
        --open                 Show only open patches (default)
+
        --draft                Show only draft patches

Ready options

@@ -209,6 +210,9 @@ impl Args for Options {
                Long("all") => {
                    filter = None;
                }
+
                Long("draft") => {
+
                    filter = Some(patch::State::Draft);
+
                }
                Long("archived") => {
                    filter = Some(patch::State::Archived);
                }
modified radicle/src/cob/patch.rs
@@ -276,12 +276,17 @@ impl Patch {

    /// Check if the patch is open.
    pub fn is_open(&self) -> bool {
-
        matches!(self.state.get().get(), State::Open)
+
        matches!(self.state(), State::Open)
    }

    /// Check if the patch is archived.
    pub fn is_archived(&self) -> bool {
-
        matches!(self.state.get().get(), &State::Archived)
+
        matches!(self.state(), State::Archived)
+
    }
+

+
    /// Check if the patch is a draft.
+
    pub fn is_draft(&self) -> bool {
+
        matches!(self.state(), State::Draft)
    }
}

@@ -982,7 +987,7 @@ impl<'a, 'g> PatchMut<'a, 'g> {

    /// Mark a patch as ready to be reviewed. Returns `false` if the patch was not a draft.
    pub fn ready<G: Signer>(&mut self, signer: &G) -> Result<bool, Error> {
-
        if self.state() != State::Draft {
+
        if !self.is_draft() {
            return Ok(false);
        }
        self.lifecycle(State::Open, signer)?;
@@ -992,7 +997,7 @@ impl<'a, 'g> PatchMut<'a, 'g> {

    /// Mark an open patch as a draft. Returns `false` if the patch was not open.
    pub fn unready<G: Signer>(&mut self, signer: &G) -> Result<bool, Error> {
-
        if self.state() != State::Open {
+
        if !self.is_open() {
            return Ok(false);
        }
        self.lifecycle(State::Draft, signer)?;