@@ -11,20 +11,20 @@ use colored::Colorize;
11
11
12
12
#[ derive( Subcommand , Debug ) ]
13
13
#[ clap( rename_all = "kebab-case" ) ]
14
- pub enum Database {
15
- /// Initializes your database
14
+ pub enum Indexer {
15
+ /// Initializes your indexer
16
16
Init ,
17
17
18
- /// Lists all entries in your database
18
+ /// Lists all entries in your indexer
19
19
List ,
20
20
21
- /// Removes an entry from your database
21
+ /// Removes an entry from your indexer
22
22
Remove {
23
23
/// Mod ID that you want to remove
24
24
id : String
25
25
} ,
26
26
27
- /// Exports an entry to your database , updating if it always exists
27
+ /// Exports an entry to your indexer , updating if it always exists
28
28
Export {
29
29
/// Path to the .geode file
30
30
package : PathBuf
@@ -55,30 +55,30 @@ fn reset_and_commit(repo: &Repository, msg: &str) {
55
55
}
56
56
57
57
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." ) ;
61
61
return ;
62
62
}
63
63
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 ." ) ;
66
66
67
67
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." ) ;
69
69
70
70
done ! ( "Successfully initialized" ) ;
71
71
}
72
72
73
73
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." ) ;
77
77
}
78
78
79
79
println ! ( "Mod list:" ) ;
80
80
81
- for dir in fs:: read_dir ( database_path ) . unwrap ( ) {
81
+ for dir in fs:: read_dir ( indexer_path ) . unwrap ( ) {
82
82
let path = dir. unwrap ( ) . path ( ) ;
83
83
84
84
if path. is_dir ( ) && path. join ( "mod.geode" ) . exists ( ) {
@@ -88,30 +88,30 @@ fn list_mods() {
88
88
}
89
89
90
90
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." ) ;
94
94
}
95
95
96
- let mod_path = database_path . join ( & id) ;
96
+ let mod_path = indexer_path . join ( & id) ;
97
97
if !mod_path. exists ( ) {
98
98
fatal ! ( "Cannot remove mod {}: does not exist" , id) ;
99
99
}
100
100
101
101
fs:: remove_dir_all ( mod_path) . nice_unwrap ( "Unable to remove mod" ) ;
102
102
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" ) ;
104
104
reset_and_commit ( & repo, & format ! ( "Remove {}" , & id) ) ;
105
105
106
106
done ! ( "Succesfully removed {}\n " , id) ;
107
107
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( ) ) ;
109
109
}
110
110
111
111
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." ) ;
115
115
}
116
116
117
117
if !package. exists ( ) {
@@ -141,31 +141,31 @@ fn export_mod(package: PathBuf) {
141
141
. nice_unwrap ( "[mod.json].id: Expected string" )
142
142
. to_string ( ) ;
143
143
144
- let mod_path = database_path . join ( format ! ( "{}@{}" , & mod_id, & major_version) ) ;
144
+ let mod_path = indexer_path . join ( format ! ( "{}@{}" , & mod_id, & major_version) ) ;
145
145
if !mod_path. exists ( ) {
146
146
fs:: create_dir ( & mod_path) . nice_unwrap ( "Unable to create folder" ) ;
147
147
}
148
148
149
149
fs:: copy ( package, mod_path. join ( "mod.geode" ) ) . nice_unwrap ( "Unable to copy mod" ) ;
150
150
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" ) ;
152
152
reset_and_commit ( & repo, & format ! ( "Add/Update {}" , & mod_id) ) ;
153
153
154
- done ! ( "Successfully exported {}@{} to your database \n " , mod_id, major_version) ;
154
+ done ! ( "Successfully exported {}@{} to your indexer \n " , mod_id, major_version) ;
155
155
156
156
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( ) ) ;
158
158
}
159
159
160
160
161
- pub fn subcommand ( _config : & mut Config , cmd : Database ) {
161
+ pub fn subcommand ( _config : & mut Config , cmd : Indexer ) {
162
162
match cmd {
163
- Database :: Init => initialize ( ) ,
163
+ Indexer :: Init => initialize ( ) ,
164
164
165
- Database :: List => list_mods ( ) ,
165
+ Indexer :: List => list_mods ( ) ,
166
166
167
- Database :: Remove { id } => remove_mod ( id) ,
167
+ Indexer :: Remove { id } => remove_mod ( id) ,
168
168
169
- Database :: Export { package } => export_mod ( package)
169
+ Indexer :: Export { package } => export_mod ( package)
170
170
}
171
171
}
0 commit comments