summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-06-10 19:27:43 +0200
committerCyborus <cyborus@cyborus.xyz>2024-06-10 19:27:43 +0200
commit56f0e8babff2c67c3aa961f2affb8ef2164ef77e (patch)
treeb91809fffd7ac289962fbe09711f38e1074c9f9c
parentMerge pull request 'print markdown text nicely' (#75) from pretty-text into main (diff)
downloadforgejo-cli-56f0e8babff2c67c3aa961f2affb8ef2164ef77e.tar.xz
forgejo-cli-56f0e8babff2c67c3aa961f2affb8ef2164ef77e.zip
add more success messages
-rw-r--r--src/issues.rs10
-rw-r--r--src/prs.rs11
-rw-r--r--src/release.rs25
3 files changed, 38 insertions, 8 deletions
diff --git a/src/issues.rs b/src/issues.rs
index 233d603..4c1f08c 100644
--- a/src/issues.rs
+++ b/src/issues.rs
@@ -574,8 +574,16 @@ pub async fn close_issue(
unset_due_date: None,
updated_at: None,
};
- api.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
+ let issue_data = api
+ .issue_edit_issue(repo.owner(), repo.name(), issue, edit)
.await?;
+ let issue_title = issue_data
+ .title
+ .as_deref()
+ .ok_or_eyre("issue does not have title")?;
+
+ println!("Closed issue {issue}: \"{issue_title}\"");
+
Ok(())
}
diff --git a/src/prs.rs b/src/prs.rs
index b4e6e30..a923924 100644
--- a/src/prs.rs
+++ b/src/prs.rs
@@ -781,6 +781,17 @@ async fn merge_pr(
let pr_number = pr_info.number.ok_or_eyre("pr does not have number")?;
api.repo_merge_pull_request(repo.owner(), repo.name(), pr_number, request)
.await?;
+
+ let pr_title = pr_info
+ .title
+ .as_deref()
+ .ok_or_eyre("pr does not have title")?;
+ let pr_base = pr_info.base.as_ref().ok_or_eyre("pr does not have base")?;
+ let base_label = pr_base
+ .label
+ .as_ref()
+ .ok_or_eyre("base does not have label")?;
+ println!("Merged PR #{pr_number} \"{pr_title}\" into `{base_label}`");
Ok(())
}
diff --git a/src/release.rs b/src/release.rs
index 1745a5e..4fd85ed 100644
--- a/src/release.rs
+++ b/src/release.rs
@@ -221,7 +221,7 @@ async fn create_release(
let release_opt = forgejo_api::structs::CreateReleaseOption {
body,
draft: Some(draft),
- name: Some(name),
+ name: Some(name.clone()),
prerelease: Some(prerelease),
tag_name,
target_commitish: None,
@@ -259,6 +259,8 @@ async fn create_release(
.await?;
}
+ println!("Created release {name}");
+
Ok(())
}
@@ -461,23 +463,25 @@ async fn create_asset(
)
.await?;
+ println!("Added attachment `{}` to {}", asset, release);
+
Ok(())
}
async fn delete_asset(
repo: &RepoName,
api: &Forgejo,
- release: String,
- asset: String,
+ release_name: String,
+ asset_name: String,
) -> eyre::Result<()> {
- let release = find_release(repo, api, &release).await?;
+ let release = find_release(repo, api, &release_name).await?;
let assets = release
.assets
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
let asset = assets
.iter()
- .find(|a| a.name.as_ref() == Some(&asset))
+ .find(|a| a.name.as_ref() == Some(&asset_name))
.ok_or_else(|| eyre!("asset not found"))?;
let release_id = release
.id
@@ -487,6 +491,7 @@ async fn delete_asset(
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
api.repo_delete_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
.await?;
+ println!("Removed attachment `{}` from {}", asset_name, release_name);
Ok(())
}
@@ -535,17 +540,23 @@ async fn download_asset(
.to_vec()
}
};
- let output = output
+ let real_output = output
.as_deref()
.unwrap_or_else(|| std::path::Path::new(&asset));
tokio::fs::OpenOptions::new()
.create_new(true)
.write(true)
- .open(output)
+ .open(real_output)
.await?
.write_all(file.as_ref())
.await?;
+ if output.is_some() {
+ println!("Downloaded {asset} into {}", real_output.display());
+ } else {
+ println!("Downloaded {asset}");
+ }
+
Ok(())
}