Added initial git and storage engine

This commit is contained in:
2022-10-25 22:00:46 +02:00
parent 1be156d911
commit dce155979e
16 changed files with 931 additions and 12 deletions

View File

@@ -6,3 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
octopush_infra = { path = "../octopush_infra" }
octopush_core = { path = "../octopush_core" }
clap = { version = "4.0.18" }
eyre = { workspace = true }

View File

@@ -0,0 +1,33 @@
use clap::{Arg, ArgAction, ArgMatches, Command};
use octopush_infra::service_register::ServiceRegister;
pub fn execute_cmd() -> Command {
Command::new("execute")
.about("execute a certain action")
.arg(
Arg::new("action")
.long("action")
.short('a')
.action(ArgAction::Set)
.help("action path to your local octopush.yaml file")
.long_help("action path to your local octopush.yaml file")
.required(true),
)
}
pub async fn execute_subcommand(args: &ArgMatches) -> eyre::Result<()> {
let action = args
.get_one::<String>("action")
.ok_or(eyre::anyhow!("--action is required"))?;
let service_register = ServiceRegister::new();
service_register
.git_provider
.clone_from_url("https://git.front.kjuulh.io/kjuulh/cuddle".to_string())
.await?;
service_register.cleanup().await?;
Ok(())
}

View File

@@ -0,0 +1 @@
pub mod execute;

View File

@@ -1,14 +1,38 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
mod commands;
use clap::Command;
const VERSION: &str = "1.0.0";
#[derive(Debug)]
pub struct OctopushCli {
cmd: clap::Command,
}
#[cfg(test)]
mod tests {
use super::*;
impl OctopushCli {
pub fn new() -> Self {
let cmd = Command::new("octopush")
.version(VERSION)
.author("Kasper J. Hermansen <contact@kjuulh.io>")
.about("Your cute action executor")
.propagate_version(true)
.subcommand_required(true)
.subcommand(commands::execute::execute_cmd());
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
Self { cmd }
}
pub async fn execute(self) -> eyre::Result<()> {
let matches = self.cmd.get_matches();
match matches.subcommand() {
Some(("execute", execute_sub)) => {
commands::execute::execute_subcommand(execute_sub).await?;
}
Some(_) => return Err(eyre::anyhow!("unknown subcommand, please see --help")),
None => return Err(eyre::anyhow!("no subcommand specified")),
}
Ok(())
}
}