Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #18

Closed
15 tasks done
sebinsua opened this issue Dec 23, 2015 · 0 comments
Closed
15 tasks done

Refactor #18

sebinsua opened this issue Dec 23, 2015 · 0 comments
Assignees
Labels
Milestone

Comments

@sebinsua
Copy link
Owner

Take a read of this well-written rust code.

  • Refactor 'client':
    • 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.
    • pick_command should be simpler:
      • Only destructure args to get out what you need to match. 'Additional destructuring](http://rustbyexample.com/flow_control/match/destructuring/destructure_structures.html) should happen before the underlying command is called.
      • 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 { ... }.
@sebinsua sebinsua mentioned this issue Dec 23, 2015
Closed
44 tasks
@sebinsua sebinsua added the bug label Dec 23, 2015
@sebinsua sebinsua added this to the v1.0.0 milestone Dec 23, 2015
@sebinsua sebinsua self-assigned this Dec 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant