You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a struct that receives an authToken on instantiation and implements basic methods to fetch data - each of these should use some kind of underlying auth_request method. This is instead of everything receiving &Config (a class that belongs to another module). Move to a separate crate teller_api.
The remaining non-HTTP parts of 'client' should perhaps be renamed to 'inform' and receive the data from the API instead of creating it (the information that is applied, does not belong to the client).
Refactor 'inquirer':
Into a module directory.
Refactor 'main':
structs and impl Decodables should remain where they are as are command definition related.
Only get_config once, if it is successful then pass the &config onto the commands, otherwise configure_cli. get_config should not be concerned with execution of configure_cli itself. This will mean you will attempt to detect whether cmd_init was picked first, separately to the rest of the other commands prior to get_config being executed.
get_config should belong to the 'config' module.
init_config should become ask_questions_for_config. Behind the scenes it should use inquirer::ask_questions and some kind of find_answers* function to get the answers out for the config.
Commands should be moved into a module 'command'. This includes configure_cli, list_accounts, show_balance, list_transactions, etc.
Table writing and other response writing should live in 'represent'. This includes get_account_alias_for_id, represent_list_accounts, represent_show_balance, represent_list_transactions, represent_list_amounts, represent_list_balances, represent_list_outgoings, represent_list_incomings, etc.
Carefully remove many of the unwrap statements and clean up many of the deeply-nested matches in the usual ways (separate functions, early returns, let expected_value = match thing { ... }.
The text was updated successfully, but these errors were encountered:
Take a read of this well-written rust code.
'client'
:authToken
on instantiation and implements basic methods to fetch data - each of these should use some kind of underlyingauth_request
method. This is instead of everything receiving&Config
(a class that belongs to another module). Move to a separate crateteller_api
.'client'
should perhaps be renamed to'inform'
and receive the data from the API instead of creating it (the information that is applied, does not belong to the client).'inquirer'
:'main'
:struct
s andimpl Decodable
s should remain where they are as are command definition related.pick_command
should be simpler:get_config
once, if it is successful then pass the&config
onto the commands, otherwiseconfigure_cli
.get_config
should not be concerned with execution ofconfigure_cli
itself. This will mean you will attempt to detect whethercmd_init
was picked first, separately to the rest of the other commands prior toget_config
being executed.get_config
should belong to the'config'
module.init_config
should becomeask_questions_for_config
. Behind the scenes it should useinquirer::ask_questions
and some kind offind_answers*
function to get the answers out for the config.'command'
. This includesconfigure_cli
,list_accounts
,show_balance
,list_transactions
, etc.'represent'
. This includesget_account_alias_for_id
,represent_list_accounts
,represent_show_balance
,represent_list_transactions
,represent_list_amounts
,represent_list_balances
,represent_list_outgoings
,represent_list_incomings
, etc.unwrap
statements and clean up many of the deeply-nested matches in the usual ways (separate functions, early returns,let expected_value = match thing { ... }
.The text was updated successfully, but these errors were encountered: