diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc6270..3061cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +Unreleased +---------- +- Formatted code base using `rustfmt` and checked in configuration + + 0.1.3 ----- - Added support for generating completion scripts for shells other than diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..7ba9e5b --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,7 @@ +blank_lines_lower_bound = 0 +blank_lines_upper_bound = 2 +edition = "2018" +imports_layout = "Vertical" +match_block_trailing_comma = true +tab_spaces = 2 +trailing_semicolon = false diff --git a/src/main.rs b/src/main.rs index ee86b1a..1ed1fb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #![type_length_limit = "536870912"] -#![allow( - clippy::large_enum_variant, - clippy::let_and_return, -)] +#![allow(clippy::large_enum_variant, clippy::let_and_return)] mod args; @@ -111,7 +108,8 @@ fn format_account_status(status: account::Status) -> String { account::Status::Active => "active", account::Status::Rejected => "rejected", account::Status::Unknown => "unknown", - }.to_string() + } + .to_string() } @@ -131,7 +129,8 @@ async fn account_get(client: Client) -> Result<(), Error> { .await .with_context(|| "failed to retrieve account information")?; - println!(r#"account: + println!( + r#"account: id: {id} status: {status} buying power: {buying_power} @@ -268,7 +267,8 @@ async fn account_activity_get(client: Client) -> Result<(), Error> { for activity in activities { match activity { account_activities::Activity::Trade(trade) => { - println!(r#"{time} {side} {qty} {sym} @ {price} = {total}"#, + println!( + r#"{time} {side} {qty} {sym} @ {price} = {total}"#, time = format_local_time_short(trade.transaction_time), side = format_activity_side(trade.side), qty = trade.quantity, @@ -278,7 +278,8 @@ async fn account_activity_get(client: Client) -> Result<(), Error> { ); }, account_activities::Activity::NonTrade(non_trade) => { - println!(r#"{date:19} {activity} {amount}"#, + println!( + r#"{date:19} {activity} {amount}"#, date = format_date(non_trade.date), activity = format_activity_type(non_trade.type_), amount = format_price(&non_trade.net_amount, ¤cy), @@ -314,7 +315,8 @@ async fn account_config_get(client: Client) -> Result<(), Error> { .await .with_context(|| "failed to retrieve account configuration")?; - println!(r#"account configuration: + println!( + r#"account configuration: trade confirmation: {trade_confirmation} trading suspended: {trading_suspended} shorting enabled: {shorting}"#, @@ -385,7 +387,8 @@ async fn asset_get(client: Client, symbol: Symbol) -> Result<(), Error> { .await .with_context(|| format!("failed to retrieve asset information for {}", symbol.0))?; - println!(r#"{sym}: + println!( + r#"{sym}: id: {id} asset class: {cls} exchange: {exchg} @@ -488,7 +491,8 @@ async fn stream_account_updates(client: Client, json: bool) -> Result<(), Error> .map_err(Error::from) .try_for_each(|result| async { let update = result.unwrap(); - println!(r#"account update: + println!( + r#"account update: status: {status} created at: {created} updated at: {updated} @@ -636,7 +640,8 @@ async fn stream_trade_updates(client: Client, json: bool) -> Result<(), Error> { .map_err(Error::from) .try_for_each(|result| async { let update = result.unwrap(); - println!(r#"{symbol} {status}: + println!( + r#"{symbol} {status}: order id: {id} status: {order_status} type: {type_} @@ -677,7 +682,8 @@ async fn market(client: Client) -> Result<(), Error> { .await .with_context(|| "failed to retrieve market clock")?; - println!(r#"market: + println!( + r#"market: open: {open} current time: {current} next open: {next_open} @@ -874,7 +880,8 @@ async fn order_change(client: Client, change: ChangeOrder) -> Result<(), Error> limit_price, stop_price, ..Default::default() - }.init(); + } + .init(); let order = client .issue::(&(id.0, request)) @@ -943,7 +950,8 @@ async fn order_get(client: Client, id: OrderId) -> Result<(), Error> { .collect::>() .join(","); - println!(r#"{sym}: + println!( + r#"{sym}: order id: {id} status: {status} created at: {created} @@ -1133,7 +1141,8 @@ async fn position_get(client: Client, symbol: Symbol) -> Result<(), Error> { let position = position.with_context(|| format!("failed to retrieve position for {}", symbol.0))?; - println!(r#"{sym}: + println!( + r#"{sym}: asset id: {id} exchange: {exchg} avg entry: {entry} @@ -1176,7 +1185,8 @@ async fn position_close(client: Client, symbol: Symbol) -> Result<(), Error> { .currency; let order = order.with_context(|| format!("failed to liquidate position for {}", symbol.0))?; - println!(r#"{sym}: + println!( + r#"{sym}: order id: {id} status: {status} quantity: {quantity} diff --git a/utils/shell-complete.rs b/utils/shell-complete.rs index 0bdff68..bdc102e 100644 --- a/utils/shell-complete.rs +++ b/utils/shell-complete.rs @@ -1,10 +1,7 @@ // Copyright (C) 2020-2021 Daniel Mueller // SPDX-License-Identifier: GPL-3.0-or-later -#![allow( - clippy::large_enum_variant, - clippy::let_and_return, -)] +#![allow(clippy::large_enum_variant, clippy::let_and_return)] use std::io::stdout;