cli: Don't show patch diff by default

It can be re-enabled with `-p`, which is what git uses usually.
This commit is contained in:
Alexis Sellier 2023-04-19 16:34:29 +02:00
parent 04e95b45fc
commit 6f17a4db67
No known key found for this signature in database
4 changed files with 21 additions and 18 deletions

View File

@ -48,7 +48,7 @@ $ rad patch
╰─────────────────────────────────────────────────────────────────────────────────────────╯
```
```
$ rad patch show 191a14e520f2eeff7c0e3ee0a5523c5217eecb89
$ rad patch show 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 -p
╭─────────────────────────────────────────────────────────────────────────────────────────╮
│ Title Define power requirements │
│ Patch 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 │

View File

@ -57,17 +57,6 @@ $ rad patch show a07ef7743a32a2e902672ea3526d1db6ee08108a
├─────────────────────────────────────────────────────────────────────────────────────────┤
│ ● opened by did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (you) [.. ]│
╰─────────────────────────────────────────────────────────────────────────────────────────╯
commit 3e674d1a1df90807e934f9ae5da2591dd6848a33
Author: radicle <radicle@localhost>
Date: Thu Dec 15 17:28:04 2022 +0000
Define power requirements
diff --git a/REQUIREMENTS b/REQUIREMENTS
new file mode 100644
index 0000000..e69de29
```
Wait, let's add a README too! Just for fun.

View File

@ -45,6 +45,10 @@ Usage
rad patch checkout <patch-id> [<option>...]
rad patch delete <patch-id> [<option>...]
Show options
-p, --patch Show the actual patch diff
Create/Update options
--[no-]announce Announce patch to network (default: false)
@ -84,6 +88,7 @@ pub enum Operation {
},
Show {
patch_id: Rev,
diff: bool,
},
Update {
patch_id: Option<Rev>,
@ -125,6 +130,7 @@ impl Args for Options {
let mut message = Message::default();
let mut push = true;
let mut filter = Some(patch::State::Open);
let mut diff = false;
while let Some(arg) = parser.next()? {
match arg {
@ -158,6 +164,11 @@ impl Args for Options {
push = false;
}
// Show options.
Long("patch") | Short('p') if op == Some(OperationName::Show) => {
diff = true;
}
// List options.
Long("all") => {
filter = None;
@ -205,6 +216,7 @@ impl Args for Options {
OperationName::List => Operation::List { filter },
OperationName::Show => Operation::Show {
patch_id: patch_id.ok_or_else(|| anyhow!("a patch must be provided"))?,
diff,
},
OperationName::Delete => Operation::Delete {
patch_id: patch_id.ok_or_else(|| anyhow!("a patch must be provided"))?,
@ -249,9 +261,9 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
Operation::List { filter } => {
list::run(&repository, &profile, Some(workdir), filter)?;
}
Operation::Show { patch_id } => {
Operation::Show { patch_id, diff } => {
let patch_id = patch_id.resolve(&repository.backend)?;
show::run(&profile, &repository, &workdir, &patch_id)?;
show::run(&profile, &repository, &workdir, &patch_id, diff)?;
}
Operation::Update {
ref patch_id,

View File

@ -40,6 +40,7 @@ pub fn run(
// TODO: Should be optional.
workdir: &git::raw::Repository,
patch_id: &PatchId,
diff: bool,
) -> anyhow::Result<()> {
let patches = patch::Patches::open(stored)?;
let Some(patch) = patches.get(patch_id)? else {
@ -91,10 +92,11 @@ pub fn run(
widget.push(line);
}
widget.print();
term::blank();
show_patch_diff(&patch, stored, workdir)?;
term::blank();
if diff {
term::blank();
show_patch_diff(&patch, stored, workdir)?;
term::blank();
}
Ok(())
}