Skip to content

Commit

Permalink
deleted 'serde' package, updated code and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxydev committed Nov 30, 2022
1 parent 6a04aa4 commit dfb51cd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 136 deletions.
112 changes: 0 additions & 112 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ repository = "https://github.com/nkr413/rustix-vcs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"

[profile.release]
opt-level = "z"
panic = "abort"
Expand Down
4 changes: 2 additions & 2 deletions src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod init_fn

let info = format!("name: {folder}\nos_name: {os_name}\ncreated_date: {created_date}\ncreated_time: {created_time}");

fs::write("rustix/init.yml", info).expect("Unable to write file");
fs::write("rustix/init.txt", info).expect("Unable to write file");

println!("Initialized !");
}
Expand All @@ -32,7 +32,7 @@ pub mod init_fn
}
Ok(_) => {
fs::File::create("rustix/log.txt");
fs::File::create("rustix/init.yml");
fs::File::create("rustix/init.txt");
fs::File::create("rustix/storage.txt");
fs::create_dir("rustix/saves");
create_yaml();
Expand Down
1 change: 1 addition & 0 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod logger
use std::fs::OpenOptions;
use std::io::prelude::*;


pub fn start(action: String)
{
let time_date: [String; 2] = crate::time::time_fn::start();
Expand Down
50 changes: 32 additions & 18 deletions src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@ pub mod print_fn
{
// PACKAGES
use std::fs;
use std::fs::File;
use std::io::{prelude::*, BufReader};

use serde::{Deserialize, Serialize};
use serde_yaml::{self};
// PACKAGES


#[derive(Debug, Serialize, Deserialize)]
struct Config {
name: String,
os_name: String,
created_date: String,
created_time: String,
}


pub fn print_commands() {
println!("Commands:\n");
Expand All @@ -41,11 +29,37 @@ pub mod print_fn


pub fn read_yaml() {
let f = fs::File::open("rustix/init.yml").expect("Could not open file.");
let data: Config = serde_yaml::from_reader(f).expect("Couldn't read");

println!("INFO\n os: {}\n created date: {} - {}\n current path: {}\n\n",
data.os_name, data.created_date, data.created_time, data.name);
fn cut_data(x: String) -> String
{
let mut elem_start_point : i64 = 0;
let mut s = String::new();

for i in x.chars() {
if i == ':' { elem_start_point += 1; }
if elem_start_point >= 1 { s.push(i); }
}

s.remove(0);
s.remove(0);

return s;
}

fn get_data() -> std::io::Result<Vec<String>>
{
let file = File::open("rustix/init.txt")?;
let reader = BufReader::new(file);
let mut info_base = Vec::new();

for line in reader.lines() { info_base.push(cut_data(line.unwrap())); }

Ok(info_base)
}

let info : Vec<String> = get_data().unwrap();

println!("\nINFO\n os: {}\n created date: {} - {}\n current path: {}\n\n",
info[1], info[3], info[2], info[0]);
}


Expand Down

0 comments on commit dfb51cd

Please sign in to comment.