Initial commit

- pkh created
- basic 'get' command to obtain a source package
This commit is contained in:
2025-11-26 00:22:09 +01:00
commit c466ad1846
6 changed files with 564 additions and 0 deletions

68
src/main.rs Normal file
View File

@@ -0,0 +1,68 @@
use std::env;
use std::error::Error;
use std::collections::HashMap;
extern crate serde;
use serde::Deserialize;
extern crate clap;
use clap::{arg, command, value_parser, ArgAction, Command};
extern crate flate2;
extern crate cmd_lib;
use cmd_lib::{run_cmd};
mod get;
use get::get;
fn main() {
let rt = tokio::runtime::Runtime::new().unwrap();
let matches = command!()
.subcommand_required(true)
.disable_version_flag(true)
.subcommand(
Command::new("get")
.about("Get a source package from the archive or git")
.arg(
arg!(-s --series <series> "Target package distribution series")
.required(false)
)
.arg(
arg!(-v --version <version> "Target package version")
.required(false)
)
.arg(
arg!(--ppa <ppa> "Download the package from a specific PPA")
.required(false)
)
.arg(arg!(<package> "Target package"))
)
.subcommand(
Command::new("changelog")
.about("Auto-generate changelog entry, editing it, committing it afterwards")
.arg(arg!(-s --series <series> "Target distribution series").required(false))
.arg(arg!(--backport "This changelog is for a backport entry").required(false))
.arg(arg!(-v --version <version> "Target version").required(false))
)
.get_matches();
match matches.subcommand() {
Some(("get", sub_matches)) => {
let package = sub_matches.get_one::<String>("package").expect("required");
let series = sub_matches.get_one::<String>("series").map(|s| s.as_str()).unwrap_or("");
let version = sub_matches.get_one::<String>("version").map(|s| s.as_str()).unwrap_or("");
let ppa = sub_matches.get_one::<String>("ppa").map(|s| s.as_str()).unwrap_or("");
// Since get is async, we need to block on it
if let Err(e) = rt.block_on(get(package, version, series, "", ppa, None)) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
},
Some(("changelog", _sub_matches)) => {
},
_ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"),
}
}