Skip to content

Commit

Permalink
move all structs to lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnxpl0it committed Jul 7, 2024
1 parent ae96a7a commit e0e8a42
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/cli/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use idkmng::config::Config;
use idkmng::types::Template;
use idkmng::Config;
use idkmng::Template;
mod args;
use args::Cli;
use colored::*;
Expand Down
10 changes: 3 additions & 7 deletions src/core/config.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use crate::keywords::Keywords;
use crate::types::Template;
use crate::Keywords;
use crate::Template;
use crate::Config;
use std::collections::HashMap;
use std::fs;
use toml::Value;

pub const KEYWORDS_FORMAT: &str = "{{$%s:f}}";
pub const KEYWORDS_REGEX: &str = r"\{\{\$[^\s}]+(:[^\s}]+)?\}\}";

pub struct Config {
pub path: String,
pub templates_path: String,
}

impl Config {
pub fn new(path: &str) -> Self {
let config_path = shellexpand::tilde(path).to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/core/file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::File;
use crate::File;

impl File {
pub fn new(path_: String, content_: String) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/core/funcs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::Fns;
use crate::Fns;
use colored::*;
use core::fmt;
use promptly::prompt;
Expand Down
6 changes: 3 additions & 3 deletions src/core/keywords.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::config::{Config, KEYWORDS_FORMAT};
use crate::config::KEYWORDS_FORMAT;
use crate::Keywords;
use crate::Config;
use chrono::Datelike;
use std::{collections::HashMap, env};

pub struct Keywords {}

impl Keywords {
pub fn new(name: String, function: String) -> String {
if !function.is_empty() {
Expand Down
34 changes: 33 additions & 1 deletion src/core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,37 @@ mod file;
pub mod funcs;
pub mod keywords;
mod templates;
pub mod types;
mod utils;
use serde::{Deserialize, Serialize};

pub struct Config {
pub path: String,
pub templates_path: String,
}

pub struct Keywords {}

#[derive(Debug, Deserialize, Serialize)]
pub struct Information {
pub name: Option<String>,
pub author: Option<String>,
pub description: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct File {
pub path: String,
pub content: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Template {
pub info: Option<Information>,
pub files: Vec<File>,
}

#[derive(Clone, Copy)]
pub enum Fns {
Read,
Env,
}
3 changes: 1 addition & 2 deletions src/core/templates.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::config::*;
use crate::keywords::Keywords;
use crate::types::*;
use crate::utils::*;
use crate::*;
use colored::Colorize;
use promptly::prompt;
use regex::Regex;
Expand Down
26 changes: 0 additions & 26 deletions src/core/types.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::Fns;
use crate::Fns;
use colored::*;
use regex::Regex;
use std::{collections::HashMap, fs, path::Path};
Expand Down

0 comments on commit e0e8a42

Please sign in to comment.