-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b40f69
commit 355b064
Showing
7 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use cling::prelude::*; | ||
|
||
#[derive(Run, Parser, Debug, Clone)] | ||
#[cling(run = "run")] | ||
pub struct App {} | ||
|
||
// handlers can be sync or async, cling will handle this transparently. | ||
async fn run() -> anyhow::Result<()> { | ||
let err1 = std::io::Error::new( | ||
std::io::ErrorKind::BrokenPipe, | ||
"Fatal disk IO Error!", | ||
); | ||
let err2 = anyhow::Error::new(err1).context("Trying to read a file"); | ||
let err3 = err2.context("Can't load application"); | ||
let err4 = err3.context("App level error"); | ||
Err(err4) | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> ClingFinished<App> { | ||
env_logger::builder().init(); | ||
// Cling::parse().run().await | ||
// Or, return ClingFinished<T> to let cling handle error printing and exit | ||
// code in a more convenient way. | ||
Cling::parse_and_run().await | ||
} |