From e7cc32a2788b8284557de0a698e68ab0fbf0d72d Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Fri, 12 May 2023 13:09:42 +0200 Subject: [PATCH] cli: Update some of the output formatting --- radicle-cli/examples/rad-auth.md | 2 +- radicle-cli/examples/rad-id-rebase.md | 10 +++++----- radicle-cli/examples/rad-init-sync.md | 3 +-- radicle-cli/examples/rad-init.md | 6 ++---- radicle-cli/src/commands/auth.rs | 4 ++-- radicle-cli/src/commands/init.rs | 12 ++++++++---- radicle-cli/src/terminal/format.rs | 5 +++++ radicle-term/src/io.rs | 6 +++++- 8 files changed, 29 insertions(+), 19 deletions(-) diff --git a/radicle-cli/examples/rad-auth.md b/radicle-cli/examples/rad-auth.md index c2c3329e..cd3e9fbc 100644 --- a/radicle-cli/examples/rad-auth.md +++ b/radicle-cli/examples/rad-auth.md @@ -9,7 +9,7 @@ Initializing your radicle 👾 identity ✓ Creating your Ed25519 keypair... ✓ Your Radicle ID is did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi. This identifies your device. -👉 To create a radicle project, run `rad init` from a git repository. +To create a radicle project, run `rad init` from a git repository. ``` You can get the above information at all times using the `self` command: diff --git a/radicle-cli/examples/rad-id-rebase.md b/radicle-cli/examples/rad-id-rebase.md index 80530a37..f70de436 100644 --- a/radicle-cli/examples/rad-id-rebase.md +++ b/radicle-cli/examples/rad-id-rebase.md @@ -186,7 +186,7 @@ Now, when we go to accept the second proposal: $ rad id accept 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --no-confirm ! Warning: Revision is out of date ! Warning: d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f -👉 Consider using 'rad id rebase' to update the proposal to the latest identity +* Consider using 'rad id rebase' to update the proposal to the latest identity ✓ Accepted proposal ✓ title: Add Bob description: Add Bob as a delegate @@ -231,9 +231,9 @@ Quorum Reached Note that a warning was emitted: - ** Warning: Revision is out of date - ** Warning: d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f - => Consider using 'rad id rebase' to update the proposal to the latest identity + ! Warning: Revision is out of date + ! Warning: d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f + * Consider using 'rad id rebase' to update the proposal to the latest identity If we attempt to commit this revision, the command will fail: @@ -241,7 +241,7 @@ If we attempt to commit this revision, the command will fail: $ rad id commit 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --no-confirm ! Warning: Revision is out of date ! Warning: d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f -👉 Consider using 'rad id rebase' to update the proposal to the latest identity +* Consider using 'rad id rebase' to update the proposal to the latest identity ✗ Id failed: the identity hashes do match 'd96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f' for the revision '3f6ae4f8645c8b0cbcd35ea924df7b13aca52774' ``` diff --git a/radicle-cli/examples/rad-init-sync.md b/radicle-cli/examples/rad-init-sync.md index 6a9cde81..88dd1c41 100644 --- a/radicle-cli/examples/rad-init-sync.md +++ b/radicle-cli/examples/rad-init-sync.md @@ -12,6 +12,5 @@ Initializing radicle 👾 project in . ✓ Announcing inventory.. Your project's Repository ID (RID) is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. -You can show it any time by running: - rad . +You can show it any time by running `rad .` ``` diff --git a/radicle-cli/examples/rad-init.md b/radicle-cli/examples/rad-init.md index 2a107afc..37c10752 100644 --- a/radicle-cli/examples/rad-init.md +++ b/radicle-cli/examples/rad-init.md @@ -15,11 +15,9 @@ Initializing radicle 👾 project in . } Your project's Repository ID (RID) is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. -You can show it any time by running: - rad . +You can show it any time by running `rad .` -To publish your project to the network, run: - git push +To publish your project to the network, run `git push` ``` Projects can be listed with the `ls` command: diff --git a/radicle-cli/src/commands/auth.rs b/radicle-cli/src/commands/auth.rs index ac523c6b..57441bb7 100644 --- a/radicle-cli/src/commands/auth.rs +++ b/radicle-cli/src/commands/auth.rs @@ -111,9 +111,9 @@ pub fn init(options: Options) -> anyhow::Result<()> { ); term::blank(); - term::tip!( + term::info!( "To create a radicle project, run {} from a git repository.", - term::format::secondary("`rad init`") + term::format::command("rad init") ); Ok(()) diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index fe5a0327..51b38b40 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -276,13 +276,17 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> term::format::dim("(RID)"), term::format::highlight(id.urn()) ); - term::info!("You can show it any time by running:"); - term::indented(term::format::secondary("rad .")); + term::info!( + "You can show it any time by running {}", + term::format::command("rad .") + ); if !options.announce { term::blank(); - term::info!("To publish your project to the network, run:"); - term::indented(term::format::secondary(push_cmd)); + term::info!( + "To publish your project to the network, run {}", + term::format::command(push_cmd) + ); } } Err(err) => { diff --git a/radicle-cli/src/terminal/format.rs b/radicle-cli/src/terminal/format.rs index 9f2e2131..afebaf69 100644 --- a/radicle-cli/src/terminal/format.rs +++ b/radicle-cli/src/terminal/format.rs @@ -29,6 +29,11 @@ pub fn parens(input: Paint) -> Paint { Paint::new(format!("({})", input.item)).with_style(input.style) } +/// Format a command suggestion, eg. `rad init`. +pub fn command(cmd: D) -> Paint { + primary(format!("`{cmd}`")) +} + /// Format a COB id. pub fn cob(id: &ObjectId) -> String { format!("{:.7}", id.to_string()) diff --git a/radicle-term/src/io.rs b/radicle-term/src/io.rs index 15aaee87..538a39e4 100644 --- a/radicle-term/src/io.rs +++ b/radicle-term/src/io.rs @@ -73,7 +73,11 @@ pub fn success_args(args: fmt::Arguments) { } pub fn tip_args(args: fmt::Arguments) { - println!("👉 {}", style(format!("{args}")).italic()); + println!( + "{} {}", + format::yellow("*"), + style(format!("{args}")).italic() + ); } pub fn notice_args(args: fmt::Arguments) {