Skip to content

Commit 1d98313

Browse files
committed
database is a shit name, its an indexer now
1 parent 24ef340 commit 1d98313

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/database.rs renamed to src/indexer.rs

+33-33
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ use colored::Colorize;
1111

1212
#[derive(Subcommand, Debug)]
1313
#[clap(rename_all = "kebab-case")]
14-
pub enum Database {
15-
/// Initializes your database
14+
pub enum Indexer {
15+
/// Initializes your indexer
1616
Init,
1717

18-
/// Lists all entries in your database
18+
/// Lists all entries in your indexer
1919
List,
2020

21-
/// Removes an entry from your database
21+
/// Removes an entry from your indexer
2222
Remove {
2323
/// Mod ID that you want to remove
2424
id: String
2525
},
2626

27-
/// Exports an entry to your database, updating if it always exists
27+
/// Exports an entry to your indexer, updating if it always exists
2828
Export {
2929
/// Path to the .geode file
3030
package: PathBuf
@@ -55,30 +55,30 @@ fn reset_and_commit(repo: &Repository, msg: &str) {
5555
}
5656

5757
fn initialize() {
58-
let database_path = geode_root().join("database");
59-
if database_path.exists() {
60-
warn!("Database is already initialized. Exiting.");
58+
let indexer_path = geode_root().join("indexer");
59+
if indexer_path.exists() {
60+
warn!("Indexer is already initialized. Exiting.");
6161
return;
6262
}
6363

64-
info!("Welcome to the Database Setup. Here, we will set up your database to be compatible with the Geode index.");
65-
info!("Before continuing, make a github fork of https://github.com/geode-sdk/database.");
64+
info!("Welcome to the Indexer Setup. Here, we will set up your indexer to be compatible with the Geode index.");
65+
info!("Before continuing, make a github fork of https://github.com/geode-sdk/indexer.");
6666

6767
let fork_url = ask_value("Enter your forked URL", None, true);
68-
Repository::clone(&fork_url, database_path).nice_unwrap("Unable to clone your repository.");
68+
Repository::clone(&fork_url, indexer_path).nice_unwrap("Unable to clone your repository.");
6969

7070
done!("Successfully initialized");
7171
}
7272

7373
fn list_mods() {
74-
let database_path = geode_root().join("database");
75-
if !database_path.exists() {
76-
fatal!("Database has not yet been initialized.");
74+
let indexer_path = geode_root().join("indexer");
75+
if !indexer_path.exists() {
76+
fatal!("Indexer has not yet been initialized.");
7777
}
7878

7979
println!("Mod list:");
8080

81-
for dir in fs::read_dir(database_path).unwrap() {
81+
for dir in fs::read_dir(indexer_path).unwrap() {
8282
let path = dir.unwrap().path();
8383

8484
if path.is_dir() && path.join("mod.geode").exists() {
@@ -88,30 +88,30 @@ fn list_mods() {
8888
}
8989

9090
fn remove_mod(id: String) {
91-
let database_path = geode_root().join("database");
92-
if !database_path.exists() {
93-
fatal!("Database has not yet been initialized.");
91+
let indexer_path = geode_root().join("indexer");
92+
if !indexer_path.exists() {
93+
fatal!("Indexer has not yet been initialized.");
9494
}
9595

96-
let mod_path = database_path.join(&id);
96+
let mod_path = indexer_path.join(&id);
9797
if !mod_path.exists() {
9898
fatal!("Cannot remove mod {}: does not exist", id);
9999
}
100100

101101
fs::remove_dir_all(mod_path).nice_unwrap("Unable to remove mod");
102102

103-
let repo = Repository::open(&database_path).nice_unwrap("Unable to open repository");
103+
let repo = Repository::open(&indexer_path).nice_unwrap("Unable to open repository");
104104
reset_and_commit(&repo, &format!("Remove {}", &id));
105105

106106
done!("Succesfully removed {}\n", id);
107107
info!("You will need to force-push this commit yourself. Type: ");
108-
info!("git -C {} push -f", database_path.to_str().unwrap());
108+
info!("git -C {} push -f", indexer_path.to_str().unwrap());
109109
}
110110

111111
fn export_mod(package: PathBuf) {
112-
let database_path = geode_root().join("database");
113-
if !database_path.exists() {
114-
fatal!("Database has not yet been initialized.");
112+
let indexer_path = geode_root().join("indexer");
113+
if !indexer_path.exists() {
114+
fatal!("Indexer has not yet been initialized.");
115115
}
116116

117117
if !package.exists() {
@@ -141,31 +141,31 @@ fn export_mod(package: PathBuf) {
141141
.nice_unwrap("[mod.json].id: Expected string")
142142
.to_string();
143143

144-
let mod_path = database_path.join(format!("{}@{}", &mod_id, &major_version));
144+
let mod_path = indexer_path.join(format!("{}@{}", &mod_id, &major_version));
145145
if !mod_path.exists() {
146146
fs::create_dir(&mod_path).nice_unwrap("Unable to create folder");
147147
}
148148

149149
fs::copy(package, mod_path.join("mod.geode")).nice_unwrap("Unable to copy mod");
150150

151-
let repo = Repository::open(&database_path).nice_unwrap("Unable to open repository");
151+
let repo = Repository::open(&indexer_path).nice_unwrap("Unable to open repository");
152152
reset_and_commit(&repo, &format!("Add/Update {}", &mod_id));
153153

154-
done!("Successfully exported {}@{} to your database\n", mod_id, major_version);
154+
done!("Successfully exported {}@{} to your indexer\n", mod_id, major_version);
155155

156156
info!("You will need to force-push this commit yourself. Type: ");
157-
info!("git -C {} push -f", database_path.to_str().unwrap());
157+
info!("git -C {} push -f", indexer_path.to_str().unwrap());
158158
}
159159

160160

161-
pub fn subcommand(_config: &mut Config, cmd: Database) {
161+
pub fn subcommand(_config: &mut Config, cmd: Indexer) {
162162
match cmd {
163-
Database::Init => initialize(),
163+
Indexer::Init => initialize(),
164164

165-
Database::List => list_mods(),
165+
Indexer::List => list_mods(),
166166

167-
Database::Remove { id } => remove_mod(id),
167+
Indexer::Remove { id } => remove_mod(id),
168168

169-
Database::Export { package } => export_mod(package)
169+
Indexer::Export { package } => export_mod(package)
170170
}
171171
}

src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod sdk;
1616
mod template;
1717
mod util;
1818
mod index;
19-
mod database;
19+
mod indexer;
2020

2121
use util::*;
2222

@@ -81,10 +81,10 @@ enum GeodeCommands {
8181
commands: crate::index::Index,
8282
},
8383

84-
/// Subcommand for interacting with your database
85-
Database {
84+
/// Subcommand for interacting with your indexer
85+
Indexer {
8686
#[clap(subcommand)]
87-
commands: crate::database::Database,
87+
commands: crate::indexer::Indexer,
8888
}
8989
}
9090

@@ -114,7 +114,7 @@ fn main() {
114114

115115
GeodeCommands::Index { commands } => index::subcommand(&mut config, commands),
116116

117-
GeodeCommands::Database { commands } => database::subcommand(&mut config, commands),
117+
GeodeCommands::Indexer { commands } => indexer::subcommand(&mut config, commands),
118118
}
119119

120120
config.save();

0 commit comments

Comments
 (0)