lib: Disable issue and patch commands

This commit is contained in:
Erik Kundt
2023-12-28 16:27:47 +01:00
parent ea0621321b
commit b0fc9fab28
6 changed files with 23 additions and 47 deletions
+5 -4
View File
@@ -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
+1 -1
View File
@@ -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 {}
+4 -2
View File
@@ -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(())
}
+2
View File
@@ -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(())
}
+8 -28
View File
@@ -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();
let args = iter::once(val)
.chain(iter::from_fn(|| parser.value().ok()))
.collect();
command = Some(Command::Other(args))
}
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.",
)))
}
+3 -12
View File
@@ -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);