fix: add ctrl-c handling

This commit is contained in:
Guilhem Lavaux 2025-06-29 13:13:40 +02:00
parent 6544e3ecb7
commit 53de4cd18e
3 changed files with 100 additions and 0 deletions

View file

@ -5,6 +5,9 @@ use forgejo_api::Forgejo;
use forgejo_api::structs::CreateReleaseOption;
use std::io;
use url::Url;
use ctrlc;
use std::sync::mpsc::channel;
pub mod config;
@ -155,6 +158,11 @@ async fn handle_list_releases(config: &config::Config, alias: &str) -> Result<()
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (tx_ctrlc, rx_ctrlc) = channel();
ctrlc::set_handler(move || tx_ctrlc.send(()).expect("Could not send signal on channel."))
.expect("Error setting Ctrl-C handler");
let args = Cli::parse();
let config = config::load_config("config.ini").expect("Failed to load config");