Fix code style issues in aws-cost function

- Remove trailing spaces
- Fix inconsistent spacing between code blocks
- Ensure proper blank line spacing throughout function
- Maintain consistency with existing codebase style
This commit is contained in:
Paul Frederiksen 2025-09-13 16:41:52 -07:00
commit 913414b3fd

View file

@ -255,8 +255,8 @@ function aws-cost() {
local start_date="$1" local start_date="$1"
local end_date="$2" local end_date="$2"
local granularity="${3:-DAILY}" local granularity="${3:-DAILY}"
aws ce get-cost-and-usage \ aws ce get-cost-and-usage \
--time-period Start="$start_date",End="$end_date" \ --time-period Start="$start_date",End="$end_date" \
--granularity "$granularity" \ --granularity "$granularity" \
--metrics BlendedCost \ --metrics BlendedCost \
@ -290,7 +290,7 @@ function aws-cost() {
fi fi
month_cost=$(get_cost "$month_start" "$today" "MONTHLY") month_cost=$(get_cost "$month_start" "$today" "MONTHLY")
if [[ -n "$last_month_start" && -n "$last_month_end" ]]; then if [[ -n "$last_month_start" && -n "$last_month_end" ]]; then
last_month_cost=$(get_cost "$last_month_start" "$last_month_end" "MONTHLY") last_month_cost=$(get_cost "$last_month_start" "$last_month_end" "MONTHLY")
fi fi
@ -306,21 +306,21 @@ function aws-cost() {
echo "┌─────────────┬─────────────┬─────────────┐" echo "┌─────────────┬─────────────┬─────────────┐"
echo "│ Period │ Amount │ Change │" echo "│ Period │ Amount │ Change │"
echo "├─────────────┼─────────────┼─────────────┤" echo "├─────────────┼─────────────┼─────────────┤"
if [[ -n "$yesterday" ]]; then if [[ -n "$yesterday" ]]; then
printf "│ Yesterday │ $%8s │ - │\n" "$yesterday_cost" printf "│ Yesterday │ $%8s │ - │\n" "$yesterday_cost"
fi fi
if [[ -n "$week_ago" ]]; then if [[ -n "$week_ago" ]]; then
printf "│ Last 7 days │ $%8s │ - │\n" "$week_cost" printf "│ Last 7 days │ $%8s │ - │\n" "$week_cost"
fi fi
printf "│ This month │ $%8s │ $%+8s │\n" "$month_cost" "$month_change" printf "│ This month │ $%8s │ $%+8s │\n" "$month_cost" "$month_change"
if [[ -n "$last_month_start" && -n "$last_month_end" ]]; then if [[ -n "$last_month_start" && -n "$last_month_end" ]]; then
printf "│ Last month │ $%8s │ - │\n" "$last_month_cost" printf "│ Last month │ $%8s │ - │\n" "$last_month_cost"
fi fi
echo "└─────────────┴─────────────┴─────────────┘" echo "└─────────────┴─────────────┴─────────────┘"
echo "" echo ""
@ -332,10 +332,10 @@ function aws-cost() {
local services_data local services_data
services_data=$(get_cost_by_service) services_data=$(get_cost_by_service)
if [[ -n "$services_data" ]]; then if [[ -n "$services_data" ]]; then
local total_month_cost_num=$(echo "$month_cost" | bc -l 2>/dev/null || echo "0") local total_month_cost_num=$(echo "$month_cost" | bc -l 2>/dev/null || echo "0")
echo "$services_data" | while read -r service cost; do echo "$services_data" | while read -r service cost; do
if [[ -n "$service" && -n "$cost" ]]; then if [[ -n "$service" && -n "$cost" ]]; then
local percentage="0.0" local percentage="0.0"
@ -348,7 +348,7 @@ function aws-cost() {
else else
echo "│ No data available │ - │ - │" echo "│ No data available │ - │ - │"
fi fi
echo "└─────────────────┴─────────────┴─────────────┘" echo "└─────────────────┴─────────────┴─────────────┘"
} }