@@ -16,7 +16,7 @@ use tokio::time::Instant;
16
16
mod cli;
17
17
mod util;
18
18
19
- use self :: cli:: { io, parser, Cli , CliCommand , Command , DatabaseCommand } ;
19
+ use self :: cli:: { io, parser, Cli , Command , ShellCommand , ShellCommandDatabase } ;
20
20
21
21
#[ tokio:: main]
22
22
async fn main ( ) {
@@ -29,7 +29,7 @@ async fn run() -> Result<()> {
29
29
let args = Cli :: parse ( ) ;
30
30
31
31
match args. command {
32
- CliCommand :: Open { relays } => {
32
+ Command :: Shell { relays } => {
33
33
let db = NostrLMDB :: open ( "./db/nostr-lmdb" ) ?;
34
34
let client = Client :: builder ( ) . database ( db) . build ( ) ;
35
35
@@ -49,7 +49,7 @@ async fn run() -> Result<()> {
49
49
rl. add_history_entry ( line. as_str ( ) ) ?;
50
50
let mut vec: Vec < String > = parser:: split ( & line) ?;
51
51
vec. insert ( 0 , String :: new ( ) ) ;
52
- match Command :: try_parse_from ( vec) {
52
+ match ShellCommand :: try_parse_from ( vec) {
53
53
Ok ( command) => {
54
54
if let Err ( e) = handle_command ( command, & client) . await {
55
55
eprintln ! ( "Error: {e}" ) ;
@@ -75,7 +75,7 @@ async fn run() -> Result<()> {
75
75
76
76
Ok ( ( ) )
77
77
}
78
- CliCommand :: Serve => {
78
+ Command :: Serve => {
79
79
let mock = MockRelay :: run ( ) . await ?;
80
80
81
81
println ! ( "Relay running at {}" , mock. url( ) ) ;
@@ -115,15 +115,15 @@ async fn run() -> Result<()> {
115
115
}
116
116
}
117
117
118
- async fn handle_command ( command : Command , client : & Client ) -> Result < ( ) > {
118
+ async fn handle_command ( command : ShellCommand , client : & Client ) -> Result < ( ) > {
119
119
match command {
120
- Command :: Generate => {
120
+ ShellCommand :: Generate => {
121
121
let keys: Keys = Keys :: generate ( ) ;
122
122
println ! ( "Secret key: {}" , keys. secret_key( ) . to_bech32( ) ?) ;
123
123
println ! ( "Public key: {}" , keys. public_key( ) . to_bech32( ) ?) ;
124
124
Ok ( ( ) )
125
125
}
126
- Command :: Sync {
126
+ ShellCommand :: Sync {
127
127
public_key,
128
128
relays,
129
129
direction,
@@ -179,7 +179,7 @@ async fn handle_command(command: Command, client: &Client) -> Result<()> {
179
179
180
180
Ok ( ( ) )
181
181
}
182
- Command :: Query {
182
+ ShellCommand :: Query {
183
183
id,
184
184
author,
185
185
kind,
@@ -255,8 +255,8 @@ async fn handle_command(command: Command, client: &Client) -> Result<()> {
255
255
256
256
Ok ( ( ) )
257
257
}
258
- Command :: Database { command } => match command {
259
- DatabaseCommand :: Populate { path } => {
258
+ ShellCommand :: Database { command } => match command {
259
+ ShellCommandDatabase :: Populate { path } => {
260
260
if path. exists ( ) && path. is_file ( ) {
261
261
// Open JSON file
262
262
let file = File :: open ( path) ?;
@@ -299,13 +299,12 @@ async fn handle_command(command: Command, client: &Client) -> Result<()> {
299
299
300
300
Ok ( ( ) )
301
301
}
302
- DatabaseCommand :: Stats => {
302
+ ShellCommandDatabase :: Stats => {
303
303
println ! ( "TODO" ) ;
304
304
Ok ( ( ) )
305
305
}
306
306
} ,
307
- Command :: Dev { } => Ok ( ( ) ) ,
308
- Command :: Exit => std:: process:: exit ( 0x01 ) ,
307
+ ShellCommand :: Exit => std:: process:: exit ( 0x01 ) ,
309
308
}
310
309
}
311
310
0 commit comments