Skip to content

Commit 2933a86

Browse files
committed
Refactor project, clean the UI and add hints for the user
1 parent 48775bd commit 2933a86

12 files changed

+432
-322
lines changed

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ opt-level = 1
77
[package]
88
edition = "2021"
99
name = "creator"
10-
version = "0.4.0"
10+
version = "0.5.0"
1111

1212
[dependencies]
13-
cursive = { version = "0.21.1", features = ["toml"] }
14-
directories = "5.0.1"
15-
log = "0.4.24"
16-
regex = "1.11.1"
17-
simplelog = "0.12.2"
18-
walkdir = "2.5.0"
13+
cursive = {version = "0.21", features = [ "toml" ]}
14+
directories = "5.0"
15+
log = "0.4"
16+
once_cell = "1.20.2"
17+
regex = "1.11"
18+
simplelog = "0.12"
19+
walkdir = "2.5"

src/directory_analyzer.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ impl DirectoryAnalyzer {
4646
pub fn get_items(&self) -> (Vec<PathBuf>, Vec<PathBuf>) {
4747
let mut files = Vec::new();
4848
let mut dirs = Vec::new();
49-
49+
5050
// if path does not exists return empty vectors
5151
if !self.path.exists() {
5252
return (files, dirs);
5353
}
5454

5555
for entry in std::fs::read_dir(&self.path).unwrap() {
5656
let entry = entry.unwrap();
57-
57+
5858
// If name is not dotfile
5959
if entry.file_name().to_str().unwrap().starts_with('.') {
6060
continue;
6161
}
62-
62+
6363
if entry.file_type().unwrap().is_file() {
6464
files.push(entry.path());
6565
} else if entry.file_type().unwrap().is_dir() {
@@ -81,7 +81,7 @@ impl DirectoryAnalyzer {
8181
if e.file_name().to_str().unwrap().starts_with('.') {
8282
continue;
8383
}
84-
84+
8585
if e.file_type().is_file() {
8686
files.push(e.path().to_path_buf());
8787
} else if e.file_type().is_dir() {
@@ -110,8 +110,9 @@ impl DirectoryAnalyzer {
110110
}
111111
}
112112
}
113-
114-
pub fn scan_variables(&self) -> HashSet<String> {
113+
114+
/// Return a vector of sorted variables
115+
pub fn scan_variables(&self) -> Vec<String> {
115116
let mut vars: HashSet<String> = HashSet::new();
116117

117118
let (files, dirs) = self.get_items_recursively();
@@ -129,6 +130,8 @@ impl DirectoryAnalyzer {
129130
Self::search_and_append(d.file_name().unwrap().to_str().unwrap(), &mut vars);
130131
}
131132

132-
vars
133+
let mut sorted_vars: Vec<_> = vars.into_iter().collect();
134+
sorted_vars.sort();
135+
sorted_vars
133136
}
134137
}

src/environment.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ pub fn get_storage_path() -> String {
4646

4747
// create the directory if it does not exist
4848
if !std::path::Path::new(&unfolded).exists() {
49-
std::fs::create_dir_all(&unfolded)
50-
.expect("Cannot create storage directory");
49+
std::fs::create_dir_all(&unfolded).expect("Cannot create storage directory");
5150
println!("Created storage directory: {}", unfolded);
5251
}
5352
return unfolded;

src/tui.rs

Lines changed: 0 additions & 306 deletions
This file was deleted.

0 commit comments

Comments
 (0)