Rewritten in python

pull/855/head
Haider Ali 3 years ago
parent f98ecc1002
commit d642b9bc8a

262
cli/Cargo.lock generated

@ -1,262 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "clap"
version = "3.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
dependencies = [
"atty",
"bitflags",
"clap_lex",
"indexmap",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "execute"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "313431b1c5e3a6ec9b864333defee57d2ddb50de77abab419e4baedb6cdff292"
dependencies = [
"execute-command-macro",
"execute-command-tokens",
"generic-array",
]
[[package]]
name = "execute-command-macro"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5fbc65a0cf735106743f4c38c9a3671c1e734b5c2c20d21a3c93c696daa3157"
dependencies = [
"execute-command-macro-impl",
]
[[package]]
name = "execute-command-macro-impl"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5109f6bc9cd57feda665da326f3f6c57e0498c8fe9f7d12d7b8abc96719ca91b"
dependencies = [
"execute-command-tokens",
"quote",
"syn",
]
[[package]]
name = "execute-command-tokens"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ba569491c70ec8471e34aa7e9c0b9e82bb5d2464c0398442d17d3c4af814e5a"
[[package]]
name = "generic-array"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "hashbrown"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "libc"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "os_str_bytes"
version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
[[package]]
name = "proc-macro2"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "reddit_video_maker"
version = "0.1.0"
dependencies = [
"clap",
"execute",
"thiserror",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thiserror"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "typenum"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

@ -1,15 +0,0 @@
[package]
name = "reddit_video_maker"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "reddit_bot_cli"
path = "src/cli-lib/mod.rs"
[dependencies]
clap = "3.2.8"
execute = "0.2.11"
thiserror = "1.0.31"

@ -0,0 +1,40 @@
#!/usr/bin/env python
import click
from ...RedditVideoMakerBot.main import process, VERSION
# MAIN Group:
# A group is created here called "main", which will have subcommands.
@click.group()
def main():
# Since this command will execute nothing, we'll just pass.
pass
# Command 1:
# We are using a decorator here, which is a "command" decorator, which turns your function into a command.
# Note that the decorator has an argument called "help", this will describe the command when we use "--help" flag
@click.command(help="Create your reddit video.")
def create():
# By making taking the help of "main.py", we import a function called "process" which does the same if we do "python main.py"
process()
# Command 2:
# We are using a decorator here, which is a "command" decorator, which turns your function into a command.
@click.command(help="Bot's version")
def version():
print(VERSION)
# Helper 1:
# This function takes the group, command and the name. After that it adds a command into that group
def command_adder(group: click.Group, cmd: click.Command, name: str):
# Adding command
group.add_command(cmd, name)
# MAIN
if __name__ == "__main__":
# Helper Called 1
command_adder(main, create, "create")
# Helper Called 2
command_adder(main, version, "version")
# Group Called
main()

@ -1,16 +0,0 @@
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(())
}

@ -1,16 +0,0 @@
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)
}

@ -1,31 +0,0 @@
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(())
}
}

@ -1,5 +0,0 @@
use reddit_bot_cli::Cli;
fn main() -> Result<(), reddit_bot_cli::error::Error> {
Cli::start()
}

@ -50,7 +50,7 @@ def run_many(times):
Popen("cls" if name == "nt" else "clear", shell=True).wait() Popen("cls" if name == "nt" else "clear", shell=True).wait()
if __name__ == "__main__": def process():
if check_env() is not True: if check_env() is not True:
exit() exit()
load_dotenv() load_dotenv()
@ -72,3 +72,7 @@ if __name__ == "__main__":
print_markdown("## Clearing temp files") print_markdown("## Clearing temp files")
cleanup() cleanup()
exit() exit()
if __name__ == "__main__":
process()

Loading…
Cancel
Save