-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert(json): remove json because it was really bad
- Loading branch information
Showing
13 changed files
with
49 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
use serde_json::json; | ||
|
||
use crate::utils::{ | ||
paths::d_packages, | ||
state::{ResponseKind::*, Responses, Result}, | ||
state::Result, | ||
}; | ||
|
||
pub fn run(res: &mut Responses) -> Result<bool> { | ||
res.pushs(vec![ | ||
Value(json!({ | ||
"path": d_packages(), | ||
})), | ||
Message(format!("Packages are located at: '{}'", d_packages())), | ||
]); | ||
pub fn run() -> Result<bool> { | ||
println!("Packages are located at: '{}'", d_packages()); | ||
Ok(true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,31 @@ | ||
use owo_colors::OwoColorize; | ||
use serde_json::{json, Map, Value}; | ||
use std::fs; | ||
|
||
use crate::utils::{ | ||
paths::d_packages, | ||
state::{ResponseKind::*, Responses, Result}, | ||
state::Result, | ||
}; | ||
|
||
pub fn run(res: &mut Responses) -> Result<bool> { | ||
pub fn run() -> Result<bool> { | ||
let typ = d_packages(); | ||
if !res.json { | ||
println!("{}", "Tree listing of your packages\n".bold()) | ||
}; | ||
println!("{}", "Tree listing of your packages\n".bold()); | ||
let dirs = fs::read_dir(&typ)?; | ||
|
||
let mut data: Vec<Value> = vec![]; | ||
|
||
for dir_res in dirs { | ||
let dir = dir_res?; | ||
if !res.json { | ||
println!("@{}:", dir.file_name().to_str().unwrap().green().bold()); | ||
} | ||
println!("@{}:", dir.file_name().to_str().unwrap().green().bold()); | ||
let subupdirs = fs::read_dir(dir.path())?; | ||
|
||
let mut map = Map::new(); | ||
let mut list: Vec<Value> = vec![]; | ||
|
||
for dir_res in subupdirs { | ||
let dir = dir_res?; | ||
if !res.json { | ||
println!(" {}:", dir.file_name().to_str().unwrap().green().bold()); | ||
} | ||
println!(" {}:", dir.file_name().to_str().unwrap().green().bold()); | ||
|
||
let subdirs = fs::read_dir(dir.path())?; | ||
|
||
let mut map2 = Map::new(); | ||
let mut list2: Vec<Value> = vec![]; | ||
|
||
for sub_dir_res in subdirs { | ||
let subdir = sub_dir_res?; | ||
list2.push(json!(subdir.file_name().to_str())); | ||
if !res.json { | ||
println!(" - {}", subdir.file_name().to_str().unwrap().green()); | ||
} | ||
println!(" - {}", subdir.file_name().to_str().unwrap().green()); | ||
} | ||
|
||
let array2 = Value::Array(list2); | ||
map2.insert(dir.file_name().to_str().unwrap().into(), array2); | ||
let dir_dataa: Value = Value::Object(map2); | ||
|
||
list.push(dir_dataa) | ||
} | ||
let array = Value::Array(list); | ||
map.insert(dir.file_name().to_str().unwrap().into(), array); | ||
let dir_data: Value = Value::Object(map); | ||
|
||
data.push(dir_data); | ||
} | ||
// TODO: It's working for now but it will be changed one day | ||
if res.json { | ||
res.push(Value(json!(data))) | ||
}; | ||
} | ||
Ok(true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.