Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Disable issue and patch commands
Erik Kundt committed 2 years ago
commit b0fc9fab28b9d98063b18f037c924a21700f8833
parent ea0621321b181ce917d54cb6b847d139e981a653
6 files changed +24 -48
modified README.md
@@ -14,7 +14,7 @@

> Requires the Rust toolchain.

-
You can install the binaries from source, by running the following
+
You can install the binary from source, by running the following
commands from inside this repository:

    cargo install --path . --force --locked
@@ -23,10 +23,11 @@ Or directly from our seed node:

    cargo install --force --locked --git https://seed.radicle.xyz/z39mP9rQAaGmERfUMPULfPUi473tY.git

-
This will install the following binaries:
+
This will install `rad-tui`. You can execute it by running `rad tui`.

-
- `rad-issue-tui`
-
- `rad-patch-tui`
+
## Commands
+

+
All available commands can be shown by running `rad tui --help`.

## License

modified bin/commands/help.rs
@@ -14,7 +14,7 @@ pub const HELP: Help = Help {
    usage: "Usage: rad-tui help [--help]",
};

-
const COMMANDS: &[Help] = &[tui_help::HELP, tui_patch::HELP];
+
const COMMANDS: &[Help] = &[tui_help::HELP];

#[derive(Default)]
pub struct Options {}
modified bin/commands/issue.rs
@@ -8,14 +8,15 @@ use anyhow::anyhow;
use crate::terminal;
use crate::terminal::args::{Args, Error, Help};

+
#[allow(dead_code)]
pub const HELP: Help = Help {
    name: "issue",
-
    description: "Terminal interfaces for patches",
+
    description: "Terminal interfaces for issues",
    version: env!("CARGO_PKG_VERSION"),
    usage: r#"
Usage

-
    rad-tui patch
+
    rad-tui issue

General options

@@ -62,6 +63,7 @@ impl Args for Options {
    }
}

+
#[allow(dead_code)]
pub fn run(_options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> {
    Ok(())
}
modified bin/commands/patch.rs
@@ -8,6 +8,7 @@ use anyhow::anyhow;
use crate::terminal;
use crate::terminal::args::{Args, Error, Help};

+
#[allow(dead_code)]
pub const HELP: Help = Help {
    name: "patch",
    description: "Terminal interfaces for patches",
@@ -62,6 +63,7 @@ impl Args for Options {
    }
}

+
#[allow(dead_code)]
pub fn run(_options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> {
    Ok(())
}
modified bin/main.rs
@@ -51,15 +51,11 @@ fn parse_args() -> anyhow::Result<Command> {
                command = Some(Command::Version);
            }
            Value(val) if command.is_none() => {
-
                if val == *"." {
-
                    command = Some(Command::Other(vec![OsString::from("inspect")]));
-
                } else {
-
                    let args = iter::once(val)
-
                        .chain(iter::from_fn(|| parser.value().ok()))
-
                        .collect();
-

-
                    command = Some(Command::Other(args))
-
                }
+
                let args = iter::once(val)
+
                    .chain(iter::from_fn(|| parser.value().ok()))
+
                    .collect();
+

+
                command = Some(Command::Other(args))
            }
            _ => return Err(anyhow::anyhow!(arg.unexpected())),
        }
@@ -99,24 +95,8 @@ fn run(command: Command) -> Result<(), Option<anyhow::Error>> {
    Ok(())
}

-
fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
-
    match exe {
-
        "issue" => {
-
            terminal::run_command_args::<tui_issue::Options, _>(
-
                tui_issue::HELP,
-
                tui_issue::run,
-
                args.to_vec(),
-
            );
-
        }
-
        "patch" => {
-
            terminal::run_command_args::<tui_patch::Options, _>(
-
                tui_patch::HELP,
-
                tui_patch::run,
-
                args.to_vec(),
-
            );
-
        }
-
        other => Err(Some(anyhow!(
-
            "`{other}` is not a command. See `rad-tui --help` for a list of commands.",
-
        ))),
-
    }
+
fn run_other(exe: &str, _args: &[OsString]) -> Result<(), Option<anyhow::Error>> {
+
    Err(Some(anyhow!(
+
        "`{exe}` is not a command. See `rad-tui --help` for a list of commands.",
+
    )))
}
modified bin/terminal.rs
@@ -46,16 +46,7 @@ where
    }
}

-
// pub fn run_command<A, C>(help: Help, cmd: C) -> !
-
// where
-
//     A: Args,
-
//     C: Command<A, fn() -> anyhow::Result<Profile>>,
-
// {
-
//     let args = std::env::args_os().skip(1).collect();
-

-
//     run_command_args(help, cmd, args)
-
// }
-

+
#[allow(dead_code)]
pub fn run_command_args<A, C>(help: Help, cmd: C, args: Vec<OsString>) -> !
where
    A: Args,
@@ -77,7 +68,7 @@ where
                }
                Some(Error::HelpManual { name }) => {
                    let Ok(status) = term::manual(name) else {
-
                        term::error(format!("rad {}: failed to load manual page", help.name));
+
                        term::error(format!("rad-tui {}: failed to load manual page", help.name));
                        process::exit(1);
                    };
                    process::exit(status.code().unwrap_or(0));
@@ -89,7 +80,7 @@ where
                Some(Error::WithHint { hint, .. }) => Some(hint),
                None => None,
            };
-
            term::error(format!("rad {}: {err}", help.name));
+
            term::error(format!("rad-tui {}: {err}", help.name));

            if let Some(hint) = hint {
                term::hint(hint);