update config, add config docs
This commit is contained in:
parent
4ed06a7f53
commit
f77783c66f
8 changed files with 615 additions and 72 deletions
|
@ -1,9 +1,17 @@
|
|||
# Gregory
|
||||
|
||||
This is Gregory. Gregory controls repos. He keeps track of building packages for repos, and can also have steps added to update those repos, or whatever you want him to do.
|
||||
This is Gregory. Gregory controls repos. Gregory keeps track of updating repos, trying to be simple and elegant, but enough.
|
||||
|
||||
<small>Okay that's enough of talking about Gregory as a person.</small>
|
||||
## TODO
|
||||
|
||||
## Why the name?
|
||||
- Add sources (similar to `sources` in a PKGBUILD)?
|
||||
- Add support for loading scripts rather than listing commands
|
||||
- Add multithreading
|
||||
- Add better/custom grouping for when to run jobs (dependency system?)
|
||||
|
||||
I was thinking to go with something dark and foreboding, since this is a program to control *everything* about a repo - it's the high command. But I couldn't think of anything and thought just naming it some lame random name instead would be way funnier. Hence, Gregory.
|
||||
## Other stuff
|
||||
|
||||
- The formatting for the config file (`gregory.yml`) was heavily inspired by Drone's config.
|
||||
- Why the name?
|
||||
|
||||
I was thinking to go with something dark and foreboding, since this is a program to control *everything* about a repo - it's the high command. But I couldn't think of anything and thought just naming it some lame random name instead would be way funnier. Hence, Gregory.
|
||||
|
|
23
src/cli.rs
Normal file
23
src/cli.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Commands {
|
||||
///Generate bash completions
|
||||
GenerateBashCompletions,
|
||||
///Generate zsh completions
|
||||
GenerateZshCompletions,
|
||||
///Generate fish completions
|
||||
GenerateFishCompletions,
|
||||
///Runs it
|
||||
Run {
|
||||
#[arg(short, long)]
|
||||
config: String,
|
||||
},
|
||||
}
|
104
src/main.rs
104
src/main.rs
|
@ -1,68 +1,48 @@
|
|||
use crate::cli::Commands;
|
||||
use crate::cli::*;
|
||||
use alphanumeric_sort::sort_str_slice;
|
||||
use clap::{CommandFactory, Parser};
|
||||
use clap_complete::aot::{generate, Bash, Fish, Zsh};
|
||||
use std::fs;
|
||||
use std::io::stdout;
|
||||
use yaml_rust2::YamlLoader;
|
||||
mod cli;
|
||||
mod tests;
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
#[test]
|
||||
/// This isn't to test the program, more to test the crate works how I want, especially if I switch crates
|
||||
fn test_semver_sorting() {
|
||||
// copied from https://pkgs.org/download/xorg-x11-xauth
|
||||
let mut versions = [
|
||||
"xorg-x11-xauth-1.1.3",
|
||||
"xorg-x11-xauth-1.1.2",
|
||||
"xorg-x11-xauth-1.0.9",
|
||||
"xorg-x11-xauth-1.0.10",
|
||||
"xorg-x11-xauth-1.1",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"xorg-x11-xauth-1.0.9",
|
||||
"xorg-x11-xauth-1.0.10",
|
||||
"xorg-x11-xauth-1.1",
|
||||
"xorg-x11-xauth-1.1.2",
|
||||
"xorg-x11-xauth-1.1.3"
|
||||
]
|
||||
);
|
||||
match cli.command {
|
||||
Commands::GenerateBashCompletions => {
|
||||
generate(
|
||||
Bash,
|
||||
&mut Cli::command(),
|
||||
"gregory",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
Commands::GenerateZshCompletions => {
|
||||
generate(
|
||||
Zsh,
|
||||
&mut Cli::command(),
|
||||
"gregory",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
Commands::GenerateFishCompletions => {
|
||||
generate(
|
||||
Fish,
|
||||
&mut Cli::command(),
|
||||
"gregory",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
Commands::Run => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_versioning() {
|
||||
// copied from https://pkgs.org/download/vpnc-script
|
||||
let mut versions = [
|
||||
"vpnc-script-20230907",
|
||||
"vpnc-script-20230103",
|
||||
"vpnc-script-20220404",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"vpnc-script-20220404",
|
||||
"vpnc-script-20230103",
|
||||
"vpnc-script-20230907"
|
||||
]
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_git_versioning() {
|
||||
// copied from aurpublish versions - https://gitlab.archlinux.org/archlinux/packaging/packages/avahi/-/commits/main
|
||||
let mut versions = [
|
||||
"1:0.8+r194+g3f79789-3",
|
||||
"1:0.8+r194+g3f79789-2",
|
||||
"0.7+4+gd8d8c67-1",
|
||||
"0.8+r189+g35bb1ba-1",
|
||||
"0.8+r127+g55d783d-1",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"0.7+4+gd8d8c67-1",
|
||||
"0.8+r127+g55d783d-1",
|
||||
"0.8+r189+g35bb1ba-1",
|
||||
"1:0.8+r194+g3f79789-2",
|
||||
"1:0.8+r194+g3f79789-3"
|
||||
]
|
||||
);
|
||||
fn run(config_path: String) {
|
||||
let tmp = fs::read_to_string(config_path.as_str()).unwrap();
|
||||
let config = YamlLoader::load_from_str(tmp.as_str()).unwrap()[0].clone();
|
||||
println!("{:?}", config)
|
||||
}
|
||||
|
|
66
src/tests.rs
Normal file
66
src/tests.rs
Normal file
|
@ -0,0 +1,66 @@
|
|||
use alphanumeric_sort::sort_str_slice;
|
||||
|
||||
#[test]
|
||||
/// This isn't to test the program, more to test the crate works how I want, especially if I switch crates
|
||||
fn test_semver_sorting() {
|
||||
// copied from https://pkgs.org/download/xorg-x11-xauth
|
||||
let mut versions = [
|
||||
"xorg-x11-xauth-1.1.3",
|
||||
"xorg-x11-xauth-1.1.2",
|
||||
"xorg-x11-xauth-1.0.9",
|
||||
"xorg-x11-xauth-1.0.10",
|
||||
"xorg-x11-xauth-1.1",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"xorg-x11-xauth-1.0.9",
|
||||
"xorg-x11-xauth-1.0.10",
|
||||
"xorg-x11-xauth-1.1",
|
||||
"xorg-x11-xauth-1.1.2",
|
||||
"xorg-x11-xauth-1.1.3"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_versioning() {
|
||||
// copied from https://pkgs.org/download/vpnc-script
|
||||
let mut versions = [
|
||||
"vpnc-script-20230907",
|
||||
"vpnc-script-20230103",
|
||||
"vpnc-script-20220404",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"vpnc-script-20220404",
|
||||
"vpnc-script-20230103",
|
||||
"vpnc-script-20230907"
|
||||
]
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_git_versioning() {
|
||||
// copied from aurpublish versions - https://gitlab.archlinux.org/archlinux/packaging/packages/avahi/-/commits/main
|
||||
let mut versions = [
|
||||
"1:0.8+r194+g3f79789-3",
|
||||
"1:0.8+r194+g3f79789-2",
|
||||
"0.7+4+gd8d8c67-1",
|
||||
"0.8+r189+g35bb1ba-1",
|
||||
"0.8+r127+g55d783d-1",
|
||||
];
|
||||
sort_str_slice(&mut versions);
|
||||
assert_eq!(
|
||||
versions,
|
||||
[
|
||||
"0.7+4+gd8d8c67-1",
|
||||
"0.8+r127+g55d783d-1",
|
||||
"0.8+r189+g35bb1ba-1",
|
||||
"1:0.8+r194+g3f79789-2",
|
||||
"1:0.8+r194+g3f79789-3"
|
||||
]
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue