cli: Simplify fatal error output
It didn't make sense to get eg. `Patch failed` when listing patches failed. We change all fatal errors to simply "Error:", giving more control over the individual commands.
This commit is contained in:
parent
27e2f47280
commit
4fb5f6c172
|
|
@ -3,5 +3,5 @@ Trying to clone a repository that is not in our routing table returns an error:
|
||||||
``` (fail)
|
``` (fail)
|
||||||
$ rad clone rad:zVNuptPuk5XauitpCWSNVCXGGfXW --scope trusted
|
$ rad clone rad:zVNuptPuk5XauitpCWSNVCXGGfXW --scope trusted
|
||||||
✓ Tracking relationship established for rad:zVNuptPuk5XauitpCWSNVCXGGfXW with scope 'trusted'
|
✓ Tracking relationship established for rad:zVNuptPuk5XauitpCWSNVCXGGfXW with scope 'trusted'
|
||||||
✗ Clone failed: no seeds found for rad:zVNuptPuk5XauitpCWSNVCXGGfXW
|
✗ Error: no seeds found for rad:zVNuptPuk5XauitpCWSNVCXGGfXW
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ $ rad id commit 2bf3a85e209d10b11a65e7ed8a8085f6f18ac6bf --no-confirm
|
||||||
! Warning: Revision is out of date
|
! Warning: Revision is out of date
|
||||||
! Warning: d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f
|
! 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 not match for revision 2bf3a85e209d10b11a65e7ed8a8085f6f18ac6bf (d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f)
|
✗ Error: the identity hashes do not match for revision 2bf3a85e209d10b11a65e7ed8a8085f6f18ac6bf (d96f425412c9f8ad5d9a9a05c9831d0728e2338d =/= 475cdfbc8662853dd132ec564e4f5eb0f152dd7f)
|
||||||
```
|
```
|
||||||
|
|
||||||
So, let's fix this by running a rebase on the proposal's revision:
|
So, let's fix this by running a rebase on the proposal's revision:
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ it will fail:
|
||||||
|
|
||||||
``` (fail)
|
``` (fail)
|
||||||
$ rad init
|
$ rad init
|
||||||
✗ Initialization failed: a Git repository was not found at the current path
|
✗ Error: a Git repository was not found at the current path
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ $ rad ls
|
||||||
``` ~bob (fail)
|
``` ~bob (fail)
|
||||||
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch --seed z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi --timeout 1
|
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch --seed z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi --timeout 1
|
||||||
✗ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi.. error: connection reset
|
✗ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi.. error: connection reset
|
||||||
✗ Sync failed: repository fetch from 1 seed(s) failed
|
✗ Error: repository fetch from 1 seed(s) failed
|
||||||
```
|
```
|
||||||
|
|
||||||
She allows Bob to view the repository. And when she syncs, one node (Bob) gets
|
She allows Bob to view the repository. And when she syncs, one node (Bob) gets
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@ The `rad inspect` command can be run without being authenticated with radicle:
|
||||||
|
|
||||||
``` (fail)
|
``` (fail)
|
||||||
$ rad self
|
$ rad self
|
||||||
✗ Self failed: Could not load radicle profile: no profile found at path [..]
|
✗ Error: Could not load radicle profile: no profile found at path [..]
|
||||||
✗ Hint: To setup your radicle profile, run `rad auth`.
|
✗ Hint: To setup your radicle profile, run `rad auth`.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,5 @@ Attempting to remove a repository that doesn't exist gives us an error message:
|
||||||
|
|
||||||
``` (fail)
|
``` (fail)
|
||||||
$ rad rm rad:z2Jk1mNqyX7AjT4K83jJW9vQoHn4f
|
$ rad rm rad:z2Jk1mNqyX7AjT4K83jJW9vQoHn4f
|
||||||
✗ Remove failed: repository rad:z2Jk1mNqyX7AjT4K83jJW9vQoHn4f was not found
|
✗ Error: repository rad:z2Jk1mNqyX7AjT4K83jJW9vQoHn4f was not found
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@ When you try to track, clone, or sync without your node running, it gives you an
|
||||||
|
|
||||||
``` ~alice (fail)
|
``` ~alice (fail)
|
||||||
$ rad track rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 --no-fetch
|
$ rad track rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 --no-fetch
|
||||||
✗ Track failed: to track a repository, your node must be running. To start it, run `rad node start`
|
✗ Error: to track a repository, your node must be running. To start it, run `rad node start`
|
||||||
```
|
```
|
||||||
|
|
||||||
``` ~bob (fail)
|
``` ~bob (fail)
|
||||||
$ rad clone rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
|
$ rad clone rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
|
||||||
✗ Clone failed: to clone a repository, your node must be running. To start it, run `rad node start`
|
✗ Error: to clone a repository, your node must be running. To start it, run `rad node start`
|
||||||
```
|
```
|
||||||
|
|
||||||
``` ~eve (fail)
|
``` ~eve (fail)
|
||||||
$ rad sync --fetch rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 --seed z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz
|
$ rad sync --fetch rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 --seed z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz
|
||||||
✗ Sync failed: to sync a repository, your node must be running. To start it, run `rad node start`
|
✗ Error: to sync a repository, your node must be running. To start it, run `rad node start`
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ $ rad sync --announce --timeout 1
|
||||||
✗ Syncing with 2 node(s)..
|
✗ Syncing with 2 node(s)..
|
||||||
! Seed z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk timed out..
|
! Seed z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk timed out..
|
||||||
! Seed z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z timed out..
|
! Seed z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z timed out..
|
||||||
✗ Sync failed: all seeds timed out
|
✗ Error: all seeds timed out
|
||||||
```
|
```
|
||||||
|
|
||||||
We can also use the `--fetch` option to only fetch objects:
|
We can also use the `--fetch` option to only fetch objects:
|
||||||
|
|
@ -45,7 +45,7 @@ $ rad sync --fetch --announce --timeout 1
|
||||||
✗ Syncing with 2 node(s)..
|
✗ Syncing with 2 node(s)..
|
||||||
! Seed z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk timed out..
|
! Seed z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk timed out..
|
||||||
! Seed z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z timed out..
|
! Seed z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z timed out..
|
||||||
✗ Sync failed: all seeds timed out
|
✗ Error: all seeds timed out
|
||||||
```
|
```
|
||||||
|
|
||||||
It's also possible to use the `--seed` flag to only sync with a specific node:
|
It's also possible to use the `--seed` flag to only sync with a specific node:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"assign" => {
|
"assign" => {
|
||||||
term::run_command_args::<rad_assign::Options, _>(
|
term::run_command_args::<rad_assign::Options, _>(
|
||||||
rad_assign::HELP,
|
rad_assign::HELP,
|
||||||
"Assign",
|
|
||||||
rad_assign::run,
|
rad_assign::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -108,7 +107,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"auth" => {
|
"auth" => {
|
||||||
term::run_command_args::<rad_auth::Options, _>(
|
term::run_command_args::<rad_auth::Options, _>(
|
||||||
rad_auth::HELP,
|
rad_auth::HELP,
|
||||||
"Authentication",
|
|
||||||
rad_auth::run,
|
rad_auth::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -116,7 +114,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"checkout" => {
|
"checkout" => {
|
||||||
term::run_command_args::<rad_checkout::Options, _>(
|
term::run_command_args::<rad_checkout::Options, _>(
|
||||||
rad_checkout::HELP,
|
rad_checkout::HELP,
|
||||||
"Checkout",
|
|
||||||
rad_checkout::run,
|
rad_checkout::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -124,7 +121,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"clone" => {
|
"clone" => {
|
||||||
term::run_command_args::<rad_clone::Options, _>(
|
term::run_command_args::<rad_clone::Options, _>(
|
||||||
rad_clone::HELP,
|
rad_clone::HELP,
|
||||||
"Clone",
|
|
||||||
rad_clone::run,
|
rad_clone::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -132,7 +128,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"cob" => {
|
"cob" => {
|
||||||
term::run_command_args::<rad_cob::Options, _>(
|
term::run_command_args::<rad_cob::Options, _>(
|
||||||
rad_cob::HELP,
|
rad_cob::HELP,
|
||||||
"Cob",
|
|
||||||
rad_cob::run,
|
rad_cob::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -140,7 +135,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"comment" => {
|
"comment" => {
|
||||||
term::run_command_args::<rad_comment::Options, _>(
|
term::run_command_args::<rad_comment::Options, _>(
|
||||||
rad_comment::HELP,
|
rad_comment::HELP,
|
||||||
"Comment",
|
|
||||||
rad_comment::run,
|
rad_comment::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -148,7 +142,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"delegate" => {
|
"delegate" => {
|
||||||
term::run_command_args::<rad_delegate::Options, _>(
|
term::run_command_args::<rad_delegate::Options, _>(
|
||||||
rad_delegate::HELP,
|
rad_delegate::HELP,
|
||||||
"Delegate",
|
|
||||||
rad_delegate::run,
|
rad_delegate::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -156,7 +149,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"edit" => {
|
"edit" => {
|
||||||
term::run_command_args::<rad_edit::Options, _>(
|
term::run_command_args::<rad_edit::Options, _>(
|
||||||
rad_edit::HELP,
|
rad_edit::HELP,
|
||||||
"Edit",
|
|
||||||
rad_edit::run,
|
rad_edit::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -164,7 +156,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"fork" => {
|
"fork" => {
|
||||||
term::run_command_args::<rad_fork::Options, _>(
|
term::run_command_args::<rad_fork::Options, _>(
|
||||||
rad_fork::HELP,
|
rad_fork::HELP,
|
||||||
"Fork",
|
|
||||||
rad_fork::run,
|
rad_fork::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -172,23 +163,16 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"help" => {
|
"help" => {
|
||||||
term::run_command_args::<rad_help::Options, _>(
|
term::run_command_args::<rad_help::Options, _>(
|
||||||
rad_help::HELP,
|
rad_help::HELP,
|
||||||
"Help",
|
|
||||||
rad_help::run,
|
rad_help::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"id" => {
|
"id" => {
|
||||||
term::run_command_args::<rad_id::Options, _>(
|
term::run_command_args::<rad_id::Options, _>(rad_id::HELP, rad_id::run, args.to_vec());
|
||||||
rad_id::HELP,
|
|
||||||
"Id",
|
|
||||||
rad_id::run,
|
|
||||||
args.to_vec(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"init" => {
|
"init" => {
|
||||||
term::run_command_args::<rad_init::Options, _>(
|
term::run_command_args::<rad_init::Options, _>(
|
||||||
rad_init::HELP,
|
rad_init::HELP,
|
||||||
"Initialization",
|
|
||||||
rad_init::run,
|
rad_init::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -196,7 +180,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"inspect" => {
|
"inspect" => {
|
||||||
term::run_command_args::<rad_inspect::Options, _>(
|
term::run_command_args::<rad_inspect::Options, _>(
|
||||||
rad_inspect::HELP,
|
rad_inspect::HELP,
|
||||||
"Inspect",
|
|
||||||
rad_inspect::run,
|
rad_inspect::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -204,23 +187,16 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"issue" => {
|
"issue" => {
|
||||||
term::run_command_args::<rad_issue::Options, _>(
|
term::run_command_args::<rad_issue::Options, _>(
|
||||||
rad_issue::HELP,
|
rad_issue::HELP,
|
||||||
"Issue",
|
|
||||||
rad_issue::run,
|
rad_issue::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"ls" => {
|
"ls" => {
|
||||||
term::run_command_args::<rad_ls::Options, _>(
|
term::run_command_args::<rad_ls::Options, _>(rad_ls::HELP, rad_ls::run, args.to_vec());
|
||||||
rad_ls::HELP,
|
|
||||||
"List",
|
|
||||||
rad_ls::run,
|
|
||||||
args.to_vec(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"node" => {
|
"node" => {
|
||||||
term::run_command_args::<rad_node::Options, _>(
|
term::run_command_args::<rad_node::Options, _>(
|
||||||
rad_node::HELP,
|
rad_node::HELP,
|
||||||
"Node",
|
|
||||||
rad_node::run,
|
rad_node::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -228,7 +204,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"patch" => {
|
"patch" => {
|
||||||
term::run_command_args::<rad_patch::Options, _>(
|
term::run_command_args::<rad_patch::Options, _>(
|
||||||
rad_patch::HELP,
|
rad_patch::HELP,
|
||||||
"Patch",
|
|
||||||
rad_patch::run,
|
rad_patch::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -236,7 +211,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"path" => {
|
"path" => {
|
||||||
term::run_command_args::<rad_path::Options, _>(
|
term::run_command_args::<rad_path::Options, _>(
|
||||||
rad_path::HELP,
|
rad_path::HELP,
|
||||||
"Path",
|
|
||||||
rad_path::run,
|
rad_path::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -244,23 +218,16 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"review" => {
|
"review" => {
|
||||||
term::run_command_args::<rad_review::Options, _>(
|
term::run_command_args::<rad_review::Options, _>(
|
||||||
rad_review::HELP,
|
rad_review::HELP,
|
||||||
"Review",
|
|
||||||
rad_review::run,
|
rad_review::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"rm" => {
|
"rm" => {
|
||||||
term::run_command_args::<rad_rm::Options, _>(
|
term::run_command_args::<rad_rm::Options, _>(rad_rm::HELP, rad_rm::run, args.to_vec());
|
||||||
rad_rm::HELP,
|
|
||||||
"Remove",
|
|
||||||
rad_rm::run,
|
|
||||||
args.to_vec(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
"self" => {
|
"self" => {
|
||||||
term::run_command_args::<rad_self::Options, _>(
|
term::run_command_args::<rad_self::Options, _>(
|
||||||
rad_self::HELP,
|
rad_self::HELP,
|
||||||
"Self",
|
|
||||||
rad_self::run,
|
rad_self::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -268,7 +235,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"sync" => {
|
"sync" => {
|
||||||
term::run_command_args::<rad_sync::Options, _>(
|
term::run_command_args::<rad_sync::Options, _>(
|
||||||
rad_sync::HELP,
|
rad_sync::HELP,
|
||||||
"Sync",
|
|
||||||
rad_sync::run,
|
rad_sync::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -276,7 +242,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"label" => {
|
"label" => {
|
||||||
term::run_command_args::<rad_label::Options, _>(
|
term::run_command_args::<rad_label::Options, _>(
|
||||||
rad_label::HELP,
|
rad_label::HELP,
|
||||||
"Label",
|
|
||||||
rad_label::run,
|
rad_label::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -284,7 +249,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"track" => {
|
"track" => {
|
||||||
term::run_command_args::<rad_track::Options, _>(
|
term::run_command_args::<rad_track::Options, _>(
|
||||||
rad_track::HELP,
|
rad_track::HELP,
|
||||||
"Track",
|
|
||||||
rad_track::run,
|
rad_track::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -292,7 +256,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"unassign" => {
|
"unassign" => {
|
||||||
term::run_command_args::<rad_unassign::Options, _>(
|
term::run_command_args::<rad_unassign::Options, _>(
|
||||||
rad_unassign::HELP,
|
rad_unassign::HELP,
|
||||||
"Unassign",
|
|
||||||
rad_unassign::run,
|
rad_unassign::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -300,7 +263,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"unlabel" => {
|
"unlabel" => {
|
||||||
term::run_command_args::<rad_unlabel::Options, _>(
|
term::run_command_args::<rad_unlabel::Options, _>(
|
||||||
rad_unlabel::HELP,
|
rad_unlabel::HELP,
|
||||||
"Unlabel",
|
|
||||||
rad_unlabel::run,
|
rad_unlabel::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
|
|
@ -308,20 +270,17 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
"untrack" => {
|
"untrack" => {
|
||||||
term::run_command_args::<rad_untrack::Options, _>(
|
term::run_command_args::<rad_untrack::Options, _>(
|
||||||
rad_untrack::HELP,
|
rad_untrack::HELP,
|
||||||
"Untrack",
|
|
||||||
rad_untrack::run,
|
rad_untrack::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"web" => term::run_command_args::<rad_web::Options, _>(
|
"web" => term::run_command_args::<rad_web::Options, _>(
|
||||||
rad_web::HELP,
|
rad_web::HELP,
|
||||||
"Web",
|
|
||||||
rad_web::run,
|
rad_web::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
),
|
),
|
||||||
"remote" => term::run_command_args::<rad_remote::Options, _>(
|
"remote" => term::run_command_args::<rad_remote::Options, _>(
|
||||||
rad_remote::HELP,
|
rad_remote::HELP,
|
||||||
"Remote",
|
|
||||||
rad_remote::run,
|
rad_remote::run,
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -50,17 +50,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_command<A, C>(help: Help, action: &str, cmd: C) -> !
|
pub fn run_command<A, C>(help: Help, cmd: C) -> !
|
||||||
where
|
where
|
||||||
A: Args,
|
A: Args,
|
||||||
C: Command<A, fn() -> anyhow::Result<Profile>>,
|
C: Command<A, fn() -> anyhow::Result<Profile>>,
|
||||||
{
|
{
|
||||||
let args = std::env::args_os().skip(1).collect();
|
let args = std::env::args_os().skip(1).collect();
|
||||||
|
|
||||||
run_command_args(help, action, cmd, args)
|
run_command_args(help, cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_command_args<A, C>(help: Help, action: &str, cmd: C, args: Vec<OsString>) -> !
|
pub fn run_command_args<A, C>(help: Help, cmd: C, args: Vec<OsString>) -> !
|
||||||
where
|
where
|
||||||
A: Args,
|
A: Args,
|
||||||
C: Command<A, fn() -> anyhow::Result<Profile>>,
|
C: Command<A, fn() -> anyhow::Result<Profile>>,
|
||||||
|
|
@ -107,7 +107,7 @@ where
|
||||||
match cmd.run(options, self::profile) {
|
match cmd.run(options, self::profile) {
|
||||||
Ok(()) => process::exit(0),
|
Ok(()) => process::exit(0),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
terminal::fail(&format!("{action} failed"), &err);
|
terminal::fail(help.name, &err);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,26 +127,21 @@ pub fn profile() -> Result<Profile, anyhow::Error> {
|
||||||
|
|
||||||
pub fn perror(name: &str, err: impl std::fmt::Display) {
|
pub fn perror(name: &str, err: impl std::fmt::Display) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{} {} rad {}: {err}",
|
"{ERROR_PREFIX} {} rad {}: {err}",
|
||||||
Paint::red(ERROR_PREFIX),
|
|
||||||
Paint::red("Error:"),
|
Paint::red("Error:"),
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fail(header: &str, error: &anyhow::Error) {
|
pub fn fail(_name: &str, error: &anyhow::Error) {
|
||||||
let err = error.to_string();
|
let err = error.to_string();
|
||||||
let err = err.trim_end();
|
let err = err.trim_end();
|
||||||
let separator = if err.contains('\n') { ":\n" } else { ": " };
|
|
||||||
|
|
||||||
println!(
|
for line in err.lines() {
|
||||||
"{ERROR_PREFIX} {}{}{error}",
|
println!("{ERROR_PREFIX} {} {line}", Paint::red("Error:"));
|
||||||
Paint::red(header).bold(),
|
}
|
||||||
Paint::red(separator),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(Error::WithHint { hint, .. }) = error.downcast_ref::<Error>() {
|
if let Some(Error::WithHint { hint, .. }) = error.downcast_ref::<Error>() {
|
||||||
println!("{} {}", ERROR_HINT_PREFIX, Paint::yellow(hint));
|
println!("{ERROR_HINT_PREFIX} {}", Paint::yellow(hint));
|
||||||
blank();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue