Clean up solana-tokens (#10667)

* Use a trait object in solana-tokens' ThinClient

* Inline arg resolution

Not worth the code complexity

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Greg Fitzgerald
2020-06-17 23:14:41 -06:00
committed by GitHub
parent b81998be69
commit 6d810b9e3c
5 changed files with 128 additions and 136 deletions

View File

@@ -1,19 +1,14 @@
use solana_cli_config::Config;
use solana_cli_config::CONFIG_FILE;
use solana_client::rpc_client::RpcClient;
use solana_tokens::{
arg_parser::parse_args,
args::{resolve_command, Command},
commands,
thin_client::ThinClient,
};
use solana_tokens::{arg_parser::parse_args, args::Command, commands, thin_client::ThinClient};
use std::env;
use std::error::Error;
use std::path::Path;
use std::process;
fn main() -> Result<(), Box<dyn Error>> {
let command_args = parse_args(env::args_os());
let command_args = parse_args(env::args_os())?;
let config = if Path::new(&command_args.config_file).exists() {
Config::load(&command_args.config_file)?
} else {
@@ -27,7 +22,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let json_rpc_url = command_args.url.unwrap_or(config.json_rpc_url);
let client = RpcClient::new(json_rpc_url);
match resolve_command(command_args.command)? {
match command_args.command {
Command::DistributeTokens(args) => {
let thin_client = ThinClient::new(client, args.dry_run);
commands::process_distribute_tokens(&thin_client, &args)?;