Compare commits
5 Commits
v1.0.2
...
1dcd456cb2
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dcd456cb2 | |||
| 2f7cc9c150 | |||
| c13d6e54ee | |||
| 7000ecb3bf | |||
| 1d3b12bf2f |
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -74,6 +74,15 @@ dependencies = [
|
|||||||
"strsim",
|
"strsim",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete"
|
||||||
|
version = "4.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "19c9f1dde76b736e3681f28cec9d5a61299cbaae0fce80a68e43724ad56031eb"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.6.0"
|
version = "4.6.0"
|
||||||
@@ -155,9 +164,10 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet"
|
name = "pallet"
|
||||||
version = "1.0.2"
|
version = "1.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
"colored",
|
"colored",
|
||||||
"glob",
|
"glob",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pallet"
|
name = "pallet"
|
||||||
version = "1.0.2"
|
version = "1.0.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
description = "A project manager and build system for C inspired by Rust's Cargo"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.6.0", features = ["derive"] }
|
clap = { version = "4.6.0", features = ["derive"] }
|
||||||
|
clap_complete = "4.6.0"
|
||||||
colored = "3.1.1"
|
colored = "3.1.1"
|
||||||
glob = "0.3.3"
|
glob = "0.3.3"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
|
|||||||
19
PKGBUILD
Normal file
19
PKGBUILD
Normal 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"
|
||||||
|
}
|
||||||
@@ -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.
|
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
|
## Usage
|
||||||
|
|
||||||
- `pallet new <project>`: initializes a new project at `project`
|
- `pallet new <project>`: initializes a new project at `project`
|
||||||
|
|||||||
79
src/app.rs
79
src/app.rs
@@ -4,6 +4,7 @@ use std::{
|
|||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use clap::CommandFactory;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ const MAIN_C: &str = include_str!("templates/main.c");
|
|||||||
const GITIGNORE: &str = "target/";
|
const GITIGNORE: &str = "target/";
|
||||||
|
|
||||||
#[derive(clap::Parser)]
|
#[derive(clap::Parser)]
|
||||||
#[clap(version)]
|
#[clap(version, about)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Subcommand,
|
command: Subcommand,
|
||||||
@@ -41,6 +42,31 @@ enum Subcommand {
|
|||||||
},
|
},
|
||||||
/// Clean all in progress files
|
/// Clean all in progress files
|
||||||
Clean,
|
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 {
|
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<()> {
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user