Skip to content

Commit dfb51cd

Browse files
committed
deleted 'serde' package, updated code and bug fixes
1 parent 6a04aa4 commit dfb51cd

File tree

5 files changed

+35
-136
lines changed

5 files changed

+35
-136
lines changed

Cargo.lock

Lines changed: 0 additions & 112 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ repository = "https://github.com/nkr413/rustix-vcs"
88

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

11-
[dependencies]
12-
serde = { version = "1.0", features = ["derive"] }
13-
serde_yaml = "0.9"
14-
1511
[profile.release]
1612
opt-level = "z"
1713
panic = "abort"

src/initialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod init_fn
1717

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

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

2222
println!("Initialized !");
2323
}
@@ -32,7 +32,7 @@ pub mod init_fn
3232
}
3333
Ok(_) => {
3434
fs::File::create("rustix/log.txt");
35-
fs::File::create("rustix/init.yml");
35+
fs::File::create("rustix/init.txt");
3636
fs::File::create("rustix/storage.txt");
3737
fs::create_dir("rustix/saves");
3838
create_yaml();

src/log.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub mod logger
33
use std::fs::OpenOptions;
44
use std::io::prelude::*;
55

6+
67
pub fn start(action: String)
78
{
89
let time_date: [String; 2] = crate::time::time_fn::start();

src/print.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,9 @@ pub mod print_fn
22
{
33
// PACKAGES
44
use std::fs;
5+
use std::fs::File;
56
use std::io::{prelude::*, BufReader};
67

7-
use serde::{Deserialize, Serialize};
8-
use serde_yaml::{self};
9-
// PACKAGES
10-
11-
12-
#[derive(Debug, Serialize, Deserialize)]
13-
struct Config {
14-
name: String,
15-
os_name: String,
16-
created_date: String,
17-
created_time: String,
18-
}
19-
208

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

4230

4331
pub fn read_yaml() {
44-
let f = fs::File::open("rustix/init.yml").expect("Could not open file.");
45-
let data: Config = serde_yaml::from_reader(f).expect("Couldn't read");
46-
47-
println!("INFO\n os: {}\n created date: {} - {}\n current path: {}\n\n",
48-
data.os_name, data.created_date, data.created_time, data.name);
32+
fn cut_data(x: String) -> String
33+
{
34+
let mut elem_start_point : i64 = 0;
35+
let mut s = String::new();
36+
37+
for i in x.chars() {
38+
if i == ':' { elem_start_point += 1; }
39+
if elem_start_point >= 1 { s.push(i); }
40+
}
41+
42+
s.remove(0);
43+
s.remove(0);
44+
45+
return s;
46+
}
47+
48+
fn get_data() -> std::io::Result<Vec<String>>
49+
{
50+
let file = File::open("rustix/init.txt")?;
51+
let reader = BufReader::new(file);
52+
let mut info_base = Vec::new();
53+
54+
for line in reader.lines() { info_base.push(cut_data(line.unwrap())); }
55+
56+
Ok(info_base)
57+
}
58+
59+
let info : Vec<String> = get_data().unwrap();
60+
61+
println!("\nINFO\n os: {}\n created date: {} - {}\n current path: {}\n\n",
62+
info[1], info[3], info[2], info[0]);
4963
}
5064

5165

0 commit comments

Comments
 (0)