1- use crate :: types:: LoginRequest ;
2- use clap:: { Parser , Subcommand , ValueEnum } ;
1+ use crate :: {
2+ commands:: {
3+ account_info:: { get_balance, get_rpc_calls} ,
4+ keys:: { delete_api_key, new_api_key} ,
5+ } ,
6+ types:: { ASCII_ART , LoginRequest } ,
7+ } ;
8+ use clap:: { Parser , Subcommand } ;
39use commands:: keys:: get_keys_interactive;
410use console:: Term ;
511use dialoguer:: { Input , Password , theme:: ColorfulTheme } ;
@@ -18,29 +24,13 @@ pub enum Command {
1824 GetApiKey {
1925 #[ arg( short, long) ]
2026 unsafe_print : bool ,
21- } ,
22- DeleteApiKey {
2327 #[ arg( short, long) ]
24- key : String ,
28+ no_url : bool ,
2529 } ,
30+ DeleteApiKey ,
2631 NewApiKey ,
27- TrackUsage {
28- #[ arg( short) ]
29- service : Service ,
30- } ,
32+ TrackUsage ,
3133 Balance ,
32- GetPaymentInfo ,
33- SubmitPayment {
34- #[ arg( short, long) ]
35- hash : String ,
36- #[ arg( short, long) ]
37- plan : Option < String > ,
38- } ,
39- }
40-
41- #[ derive( Debug , Copy , Clone , ValueEnum ) ]
42- pub enum Service {
43- Rpc ,
4434}
4535
4636#[ tokio:: main]
@@ -49,7 +39,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4939 let mut term = Term :: stdout ( ) ;
5040 term. clear_screen ( ) ?;
5141 term. set_title ( "Developer DAO Cloud" ) ;
52- term. write_line ( "Login to Developer DAO Cloud" ) ?;
42+ term. write_line ( ASCII_ART ) ?;
43+ term. write_line ( "Login" ) ?;
5344 term. write_line ( "" ) ?;
5445
5546 let email: String = Input :: with_theme ( & ColorfulTheme :: default ( ) )
@@ -71,18 +62,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
7162 . json ( & login)
7263 . send ( )
7364 . await ?
74- . error_for_status ( ) ?;
65+ . error_for_status ( )
66+ . map_err ( |_| "Invalid username or password" ) ?;
7567
7668 match cli_input. cmd {
77- Command :: GetApiKey { unsafe_print } => {
69+ Command :: GetApiKey { unsafe_print, .. } => {
7870 get_keys_interactive ( & client, & mut term, unsafe_print) . await ?
7971 }
80- Command :: DeleteApiKey { key : _ } => todo ! ( ) ,
81- Command :: NewApiKey => todo ! ( ) ,
82- Command :: TrackUsage { service : _ } => todo ! ( ) ,
83- Command :: Balance => todo ! ( ) ,
84- Command :: GetPaymentInfo => todo ! ( ) ,
85- Command :: SubmitPayment { hash : _, plan : _ } => todo ! ( ) ,
72+ Command :: DeleteApiKey => delete_api_key ( & client) . await ?,
73+ Command :: NewApiKey => new_api_key ( & client) . await ?,
74+ Command :: TrackUsage => get_rpc_calls ( & client) . await ?,
75+ Command :: Balance => get_balance ( & client) . await ?,
8676 } ;
8777
8878 Ok ( ( ) )
0 commit comments