1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#![no_std]

extern crate alloc;
extern crate std;

use std::{io::Write, process::exit};

use alloc::boxed::Box;

pub mod args;
pub mod run;
pub mod workflow_getter;

/// Creates a new workflows.toml file from a template
fn create_workflows_file() -> Result<(), std::io::Error> {
    let mut file = std::fs::File::create("workflows.toml")?;

    file.write_all(include_str!("../text/workflows.toml").as_bytes())?;

    Ok(())
}

/// Runs this program
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args = args::Args::parse();

    match args.subcmd {
        args::SubCommandEnum::Run(workflow) => run::run(&workflow.workflow, workflow.debug)?,
        args::SubCommandEnum::Init(_) => create_workflows_file()?,
    }

    exit(0)
}