parent
1352725860
commit
f98ecc1002
@ -0,0 +1,16 @@
|
|||||||
|
use crate::error::Error;
|
||||||
|
use std::process::Command;
|
||||||
|
use execute::Execute;
|
||||||
|
pub fn create_video() -> Result<(), Error> {
|
||||||
|
let mut command = Command::new("python");
|
||||||
|
command.arg("main.py");
|
||||||
|
match command.execute_output() {
|
||||||
|
Ok(o) => {
|
||||||
|
println!("{}", String::from_utf8(o.stdout).unwrap())
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
return Err(Error::ScriptError(e.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
use clap::Error as ClapError;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
#[error("There is an error with the cli: {0}")]
|
||||||
|
CliError(#[from] ClapError),
|
||||||
|
#[error("Error while running the script: {0}")]
|
||||||
|
ScriptError(String),
|
||||||
|
#[error("Standard Input/Ouput error: {0}")]
|
||||||
|
IoError(#[from] std::io::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
use clap::Command;
|
||||||
|
use commands::create_video;
|
||||||
|
use error::Error;
|
||||||
|
|
||||||
|
pub mod commands;
|
||||||
|
pub mod error;
|
||||||
|
|
||||||
|
pub struct Cli;
|
||||||
|
|
||||||
|
impl Cli {
|
||||||
|
pub fn start() -> Result<(), Error> {
|
||||||
|
let app = Command::new("reddit-video-maker")
|
||||||
|
.about("Create Reddit Videos with \u{2728} one command \u{2728}")
|
||||||
|
.subcommand(
|
||||||
|
Command::new("create").about("Start the process of creating the video")
|
||||||
|
);
|
||||||
|
let matches = app.clone().get_matches();
|
||||||
|
match matches.subcommand() {
|
||||||
|
Some(("create", _)) => {
|
||||||
|
create_video()?;
|
||||||
|
},
|
||||||
|
Some(_) => {
|
||||||
|
app.clone().print_help()?;
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
app.clone().print_help()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue