mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
feat: add currency picker to menubar plugin
Adds a Currency submenu to the SwiftBar/xbar dropdown with 16 common currencies. Clicking one runs codeburn config currency and refreshes the plugin. Active currency is marked with *. The full 162 ISO 4217 currencies are available via the CLI for any not listed in the menubar.
This commit is contained in:
parent
d248f0d6df
commit
df69c2aadf
1 changed files with 33 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import { chmod, mkdir, unlink, writeFile } from 'fs/promises'
|
|||
import { homedir, platform } from 'os'
|
||||
import { join } from 'path'
|
||||
import { formatCost, formatTokens } from './format.js'
|
||||
import { getCurrency } from './currency.js'
|
||||
|
||||
const PLUGIN_REFRESH = '5m'
|
||||
|
||||
|
|
@ -149,8 +150,40 @@ export function renderMenubarFormat(
|
|||
|
||||
lines.push('---')
|
||||
const home = process.env.HOME ?? '~'
|
||||
const bin = getCodeburnBin()
|
||||
lines.push(`Open Full Report | terminal=true shell=/bin/bash param1=-c param2="cd '${home}/codeburn' && npx tsx src/cli.ts report; echo ''; echo 'Press any key to close...'; read -n1"`)
|
||||
lines.push(`Export CSV to Desktop | terminal=false shell=/bin/bash param1=-c param2="cd '${home}/codeburn' && npx tsx src/cli.ts export -o '${home}/Desktop/codeburn-report.csv' 2>/dev/null"`)
|
||||
|
||||
// Currency submenu -- common currencies as clickable items.
|
||||
// Clicking one runs 'codeburn config currency XXX' and refreshes the plugin.
|
||||
const activeCurrency = getCurrency().code
|
||||
const currencies = [
|
||||
{ code: 'USD', name: 'US Dollar' },
|
||||
{ code: 'GBP', name: 'British Pound' },
|
||||
{ code: 'EUR', name: 'Euro' },
|
||||
{ code: 'AUD', name: 'Australian Dollar' },
|
||||
{ code: 'CAD', name: 'Canadian Dollar' },
|
||||
{ code: 'NZD', name: 'New Zealand Dollar' },
|
||||
{ code: 'JPY', name: 'Japanese Yen' },
|
||||
{ code: 'CHF', name: 'Swiss Franc' },
|
||||
{ code: 'INR', name: 'Indian Rupee' },
|
||||
{ code: 'BRL', name: 'Brazilian Real' },
|
||||
{ code: 'SEK', name: 'Swedish Krona' },
|
||||
{ code: 'SGD', name: 'Singapore Dollar' },
|
||||
{ code: 'HKD', name: 'Hong Kong Dollar' },
|
||||
{ code: 'KRW', name: 'South Korean Won' },
|
||||
{ code: 'MXN', name: 'Mexican Peso' },
|
||||
{ code: 'ZAR', name: 'South African Rand' },
|
||||
]
|
||||
lines.push(`Currency: ${activeCurrency} | size=14`)
|
||||
for (const { code, name } of currencies) {
|
||||
const check = code === activeCurrency ? ' *' : ''
|
||||
const cmd = code === 'USD'
|
||||
? `${bin} config currency --reset`
|
||||
: `${bin} config currency ${code}`
|
||||
lines.push(`--${name} (${code})${check} | terminal=false refresh=true shell=/bin/bash param1=-c param2="${cmd}"`)
|
||||
}
|
||||
|
||||
lines.push(`Refresh | refresh=true`)
|
||||
|
||||
return lines.join('\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue