Use our own Error enum in fn main
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -17,7 +17,7 @@ const API_RELEASE_FRONT: &'static str = "/api/v1/repos/";
|
|||||||
const API_RELEASE_BACK: &'static str = "/releases";
|
const API_RELEASE_BACK: &'static str = "/releases";
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Error> {
|
async fn main() -> Result<(), gt_tools::Error> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
match args.command {
|
match args.command {
|
||||||
@@ -26,7 +26,7 @@ async fn main() -> Result<(), Error> {
|
|||||||
&client,
|
&client,
|
||||||
&args.gitea_url,
|
&args.gitea_url,
|
||||||
&args.repo
|
&args.repo
|
||||||
).await.unwrap();
|
).await?;
|
||||||
for release in releases {
|
for release in releases {
|
||||||
println!("{:?}", release);
|
println!("{:?}", release);
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,9 @@ async fn main() -> Result<(), Error> {
|
|||||||
tag_name,
|
tag_name,
|
||||||
target_commitish,
|
target_commitish,
|
||||||
};
|
};
|
||||||
do_create_release(&client, &args.gitea_url, &args.repo, submission).await?;
|
do_create_release(&client, &args.gitea_url, &args.repo, submission)
|
||||||
|
.await
|
||||||
|
.map_err(reqwest_to_gttool)?;
|
||||||
}
|
}
|
||||||
gt_tools::cli::Commands::UploadRelease {
|
gt_tools::cli::Commands::UploadRelease {
|
||||||
tag_name,
|
tag_name,
|
||||||
@@ -69,13 +71,17 @@ async fn main() -> Result<(), Error> {
|
|||||||
&args.repo,
|
&args.repo,
|
||||||
52usize,
|
52usize,
|
||||||
files
|
files
|
||||||
).await?;
|
).await.map_err(reqwest_to_gttool)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reqwest_to_gttool(err: reqwest::Error) -> gt_tools::Error {
|
||||||
|
gt_tools::Error::WrappedReqwestErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
async fn do_create_release(
|
async fn do_create_release(
|
||||||
client: &reqwest::Client,
|
client: &reqwest::Client,
|
||||||
|
|||||||
Reference in New Issue
Block a user