5 Commits

Author SHA1 Message Date
1dcd456cb2 Add List function 2026-03-22 21:41:38 -05:00
2f7cc9c150 Fix completions for utils and add description 2026-03-22 21:23:45 -05:00
c13d6e54ee Add ability to generate shell completions 2026-03-22 21:05:34 -05:00
7000ecb3bf create PKGBUILD for Arch 2026-03-22 19:16:22 -05:00
1d3b12bf2f Update README.md 2026-03-22 18:03:12 -06:00
5 changed files with 119 additions and 3 deletions

12
Cargo.lock generated
View File

@@ -74,6 +74,15 @@ dependencies = [
"strsim",
]
[[package]]
name = "clap_complete"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19c9f1dde76b736e3681f28cec9d5a61299cbaae0fce80a68e43724ad56031eb"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
version = "4.6.0"
@@ -155,9 +164,10 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "pallet"
version = "1.0.2"
version = "1.0.4"
dependencies = [
"clap",
"clap_complete",
"colored",
"glob",
"serde",

View File

@@ -1,10 +1,12 @@
[package]
name = "pallet"
version = "1.0.2"
version = "1.0.4"
edition = "2024"
description = "A project manager and build system for C inspired by Rust's Cargo"
[dependencies]
clap = { version = "4.6.0", features = ["derive"] }
clap_complete = "4.6.0"
colored = "3.1.1"
glob = "0.3.3"
serde = { version = "1.0.228", features = ["derive"] }

19
PKGBUILD Normal file
View File

@@ -0,0 +1,19 @@
# Maintainer: Shea Frembling <sfrembling@gmail.com>
pkgname=pallet
pkgver=1.0.4
pkgrel=1
pkgdesc="A simple C project manager inspired by Cargo"
arch=('x86_64')
url=""
license=('MIT')
depends=()
makedepends=('rust' 'cargo')
source=()
build() {
cargo build --release
}
package() {
install -Dm755 "$startdir/target/release/pallet" "$pkgdir/usr/bin/pallet"
}

View File

@@ -4,6 +4,14 @@ Pallet is a project manager and build system for C inspired by Rust's Cargo.
This is a toy project not meant to be taken very seriously.
## Requirements for Use
[GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection) is required as it is currently the back-end tool used to compile the C code.
This tool calls `gcc` internally, so without it, it would fail.
At some point I would like to update `Pallet.toml` to instead allow more configuring of how the build should be performed.
## Usage
- `pallet new <project>`: initializes a new project at `project`

View File

@@ -4,6 +4,7 @@ use std::{
process::Command,
};
use clap::CommandFactory;
use colored::Colorize;
use glob::glob;
@@ -11,7 +12,7 @@ const MAIN_C: &str = include_str!("templates/main.c");
const GITIGNORE: &str = "target/";
#[derive(clap::Parser)]
#[clap(version)]
#[clap(version, about)]
pub struct App {
#[clap(subcommand)]
command: Subcommand,
@@ -41,6 +42,31 @@ enum Subcommand {
},
/// Clean all in progress files
Clean,
/// Utility functions
Utils {
#[clap(subcommand)]
command: UtilSubcommand,
},
/// List available build modes
List,
}
#[derive(clap::Subcommand)]
enum UtilSubcommand {
/// Generate shell completions
Completions {
/// The shell to generate completions for
#[arg(value_enum, long, short)]
shell: ShellCompletions,
},
}
#[derive(Clone, clap::ValueEnum)]
enum ShellCompletions {
Bash,
Fish,
PowerShell,
Zsh,
}
impl App {
@@ -87,10 +113,61 @@ impl App {
}
_ => {}
},
Subcommand::Utils { command } => match command {
UtilSubcommand::Completions { shell } => {
let name = env!("CARGO_PKG_NAME");
let mut command = App::command();
match shell {
ShellCompletions::Bash => clap_complete::generate(
clap_complete::shells::Bash,
&mut command,
name,
&mut std::io::stdout(),
),
ShellCompletions::Fish => clap_complete::generate(
clap_complete::shells::Fish,
&mut command,
name,
&mut std::io::stdout(),
),
ShellCompletions::PowerShell => clap_complete::generate(
clap_complete::shells::PowerShell,
&mut command,
name,
&mut std::io::stdout(),
),
ShellCompletions::Zsh => clap_complete::generate(
clap_complete::shells::Zsh,
&mut command,
name,
&mut std::io::stdout(),
),
}
}
},
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<()> {
let name = if directory.as_ref().to_string_lossy() == "." {
String::new()