Add List function

This commit is contained in:
2026-03-22 21:40:48 -05:00
parent 2f7cc9c150
commit 1dcd456cb2
4 changed files with 24 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -164,7 +164,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]] [[package]]
name = "pallet" name = "pallet"
version = "1.0.3" version = "1.0.4"
dependencies = [ dependencies = [
"clap", "clap",
"clap_complete", "clap_complete",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "pallet" name = "pallet"
version = "1.0.3" version = "1.0.4"
edition = "2024" edition = "2024"
description = "A project manager and build system for C inspired by Rust's Cargo" description = "A project manager and build system for C inspired by Rust's Cargo"

View File

@@ -1,6 +1,6 @@
# Maintainer: Shea Frembling <sfrembling@gmail.com> # Maintainer: Shea Frembling <sfrembling@gmail.com>
pkgname=pallet pkgname=pallet
pkgver=1.0.3 pkgver=1.0.4
pkgrel=1 pkgrel=1
pkgdesc="A simple C project manager inspired by Cargo" pkgdesc="A simple C project manager inspired by Cargo"
arch=('x86_64') arch=('x86_64')

View File

@@ -47,6 +47,8 @@ enum Subcommand {
#[clap(subcommand)] #[clap(subcommand)]
command: UtilSubcommand, command: UtilSubcommand,
}, },
/// List available build modes
List,
} }
#[derive(clap::Subcommand)] #[derive(clap::Subcommand)]
@@ -143,10 +145,29 @@ impl App {
} }
} }
}, },
Subcommand::List => match list() {
Err(e) => {
eprintln!("Error listing build profiles: {e}");
std::process::exit(1);
}
_ => {}
},
} }
} }
} }
fn list() -> std::io::Result<()> {
let conf = get_config().ok_or(std::io::Error::new(
std::io::ErrorKind::NotFound,
"no Pallet.toml found in local directory",
))?;
for build in conf.build {
println!(" - {}: {:?}", build.name.green().bold(), build.args);
}
Ok(())
}
fn create_project<P: AsRef<Path>>(directory: P) -> std::io::Result<()> { fn create_project<P: AsRef<Path>>(directory: P) -> std::io::Result<()> {
let name = if directory.as_ref().to_string_lossy() == "." { let name = if directory.as_ref().to_string_lossy() == "." {
String::new() String::new()