Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin/patch: Remove selection mode (id-only / operation)
Erik Kundt committed 4 months ago
commit 38fa4297ff6dc5ae642f3be56b0ba12313899e98
parent edc2bd4
3 files changed +9 -50
modified bin/commands/patch.rs
@@ -19,7 +19,6 @@ use radicle_cli::terminal;
use radicle_cli::terminal::args::{string, Args, Error, Help};

use crate::cob::patch;
-
use crate::cob::patch::Filter;
use crate::commands::tui_patch::common::PatchOperation;

pub const HELP: Help = Help {
@@ -33,9 +32,6 @@ Usage

List options

-
    --mode <MODE>           Set selection mode; see MODE below (default: operation)
-
    --json                  Return JSON on stderr instead of calling `rad`
-

    --all                   Show all patches, including merged and archived patches
    --archived              Show only archived patches
    --merged                Show only merged patches
@@ -45,9 +41,7 @@ List options
    --author <did>          Show only patched where the given user is an author
                            (may be specified multiple times)

-
    The MODE argument can be 'operation' or 'id'. 'operation' selects a patch id and
-
    an operation, whereas 'id' selects a patch id only.
-

+
    --json                  Return JSON on stderr instead of calling `rad`

Other options

@@ -80,7 +74,6 @@ pub enum OperationName {

#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct ListOptions {
-
    mode: common::Mode,
    filter: patch::Filter,
    json: bool,
}
@@ -149,17 +142,6 @@ impl Args for Options {
                    };
                }

-
                // select options.
-
                Long("mode") | Short('m') if op == OperationName::List => {
-
                    let val = parser.value()?;
-
                    let val = val.to_str().unwrap_or_default();
-

-
                    list_opts.mode = match val {
-
                        "operation" => common::Mode::Operation,
-
                        "id" => common::Mode::Id,
-
                        unknown => anyhow::bail!("unknown mode '{}'", unknown),
-
                    };
-
                }
                Long("all") if op == OperationName::List => {
                    list_opts.filter = list_opts.filter.with_status(None);
                }
@@ -232,9 +214,6 @@ impl Args for Options {
        }

        // Configure list options
-
        if list_opts.mode == common::Mode::Id {
-
            list_opts.filter = Filter::default().with_status(None)
-
        }
        list_opts.json = json;

        // Map local commands. Forward help and ignore `no-forward`.
@@ -377,7 +356,6 @@ mod interface {
        let context = list::Context {
            profile,
            repository,
-
            mode: opts.mode,
            filter: opts.filter.clone(),
        };

modified bin/commands/patch/common.rs
@@ -1,17 +1,6 @@
use radicle::patch::PatchId;
use serde::Serialize;

-
/// The application's mode. It tells the application
-
/// which widgets to render and which output to produce.
-
///
-
/// Depends on CLI arguments given by the user.
-
#[derive(Clone, Default, Debug, Eq, PartialEq)]
-
pub enum Mode {
-
    #[default]
-
    Operation,
-
    Id,
-
}
-

/// The selected patch operation returned by the operation
/// selection widget.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
modified bin/commands/patch/list.rs
@@ -23,7 +23,7 @@ use tui::ui::im::Show;
use tui::ui::{BufferedValue, Column, Spacing};
use tui::{Channel, Exit};

-
use super::common::{Mode, PatchOperation};
+
use super::common::PatchOperation;

use crate::cob::patch;
use crate::ui::items::filter::Filter;
@@ -42,7 +42,6 @@ const HELP: &str = r#"# Generic keybindings

# Specific keybindings

-
`enter`:    Select patch (if --mode id)
`enter`:    Show patch
`c`:        Checkout patch
`d`:        Show patch diff
@@ -59,7 +58,6 @@ type Selection = tui::Selection<PatchOperation>;
pub struct Context {
    pub profile: Profile,
    pub repository: Repository,
-
    pub mode: Mode,
    pub filter: patch::Filter,
}

@@ -117,7 +115,6 @@ pub enum Page {

#[derive(Clone, Debug)]
pub struct AppState {
-
    mode: Mode,
    page: Page,
    main_group: ContainerState,
    patches: TableState,
@@ -156,7 +153,6 @@ impl TryFrom<&Context> for App {
        Ok(App {
            patches: Arc::new(Mutex::new(items.clone())),
            state: AppState {
-
                mode: context.mode.clone(),
                page: Page::Main,
                main_group: ContainerState::new(3, Some(0)),
                patches: TableState::new(Some(0)),
@@ -559,17 +555,13 @@ impl App {
    pub fn show_browser_shortcuts(&self, frame: &mut Frame, ui: &mut im::Ui<Message>) {
        ui.shortcuts(
            frame,
-
            &match self.state.mode {
-
                Mode::Id => [("enter", "select"), ("/", "search")].to_vec(),
-
                Mode::Operation => [
-
                    ("enter", "show"),
-
                    ("c", "checkout"),
-
                    ("d", "diff"),
-
                    ("/", "search"),
-
                    ("?", "help"),
-
                ]
-
                .to_vec(),
-
            },
+
            &[
+
                ("enter", "show"),
+
                ("c", "checkout"),
+
                ("d", "diff"),
+
                ("/", "search"),
+
                ("?", "help"),
+
            ],
            '∙',
        );
    }