🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@kabeep/forex-cli

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kabeep/forex-cli

A Node.js Library to convert foreign exchange in terminal

Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
35
600%
Maintainers
1
Weekly downloads
 
Created
Source

forex-cli

NodeJS Install Size NPM code style License

English | 简体中文

Insights

usage-png

📖 Introduction

A Node.js Library to convert foreign exchange in terminal.

⚙️ Installation

npm install --global @kabeep/forex-cli
yarn add --global @kabeep/forex-cli
pnpm add --global @kabeep/forex-cli

🚀 Usage

forex -h
forex <command> [options]

Commands:
  forex convert [amount]  Convert currency amounts       [default] [aliases: to]
  forex currency [code]   Get available currency codes and names
                                                         [aliases: cur, ccy, cy]
  forex list              Print list of available currencies       [aliases: ls]
  forex completion        generate completion script

Options:
  -d, --date       The date for the conversion rate, or "latest" for the most re
                   cent                             [string] [default: "latest"]
      --timeout    Request timeout (milliseconds)      [number] [default: 10000]
      --translate  Translate occurrences of currency or region names
                                                      [boolean] [default: false]
  -f, --from       The base currency code or locale code
                                                      [string] [default: "auto"]
  -t, --to         The destination currency code or locale code
                                                      [string] [default: "auto"]
  -h, --help       Show help                                           [boolean]
  -v, --version    Show version number                                 [boolean]

Examples:
  forex list -t US -d 2024-12-01  Use the exchange rate for the specif
                                            ied date
  forex convert -t US -d "Dec 01, 2024"  Use the exchange rate for the specif
                                            ied date
  -------
  forex convert -t US --timeout 30000  Set request timeout
  forex currency -t US --translate  Print the translated currency name o
                                            r region name according to the opera
                                            ting system locale
  forex 1000 -f USD -t EUR        Convert 1000 USD to Euros
  -------
  forex -t USD                    Currency codes using ISO 4217
  forex -t US                     Use locale codes from ISO 3166-1
  forex -t America                Use country or region name
  -------
  forex --from USD --to EUR       Specify base and target currencies
  forex --from USD                Specify one of the currencies and au
                                            tomatically fill in the other curren
                                            cy through the OS's locale
  forex --to USD                  Specify one of the currencies and au
                                            tomatically fill in the other curren
                                            cy through the OS's locale

Quick Start

Convert 1000 Euros to your currency (obtained based on OS's locale).

forex 1000 --from EUR
✔ Get the list of available currencies on latest 381ms
✔ Get the currency exchange rate between EUR and USD on latest 120ms
✨ 1,000.00 Euro (EUR) ≈ 1,050.60 US Dollar (USD)

🔩 Command

CommandAliasesDefaultParameterDescription
converttotrueamountConvert currency amounts
currencycur / ccy / cyfalsecurrency name / currency code / country or region nameGet available currency codes and names
listlsfalse-Print list of available currencies
completion-false-Generate completion script
help-false-Show help

Common Options:

forex list --date "Dec 01, 2024" --timeout 10000 --translate
OptionTypeOptionalDefaultDescription
--date / -dstringtrue"latest"The date for the conversion rate, or "latest" for the most recent
--timeoutnumbertrue10_000Request timeout (milliseconds)
--translatebooleantruefalseTranslate occurrences of currency or region names
--version / -vbooleantruefalseShow version number
--help / -hbooleantruefalseShow help

$ CONVERT (Default)

Convert currency amounts.

Supports numeric separators 10_000, grouped numbers 10,000 and scientific notation 1.23e3.

forex convert -h
forex convert [amount]

Convert currency amounts

Options:
  -d, --date       The date for the conversion rate, or "latest" for the most re
                   cent                             [string] [default: "latest"]
      --timeout    Request timeout (milliseconds)      [number] [default: 10000]
      --translate  Translate occurrences of currency or region names
                                                      [boolean] [default: false]
  -f, --from       The base currency code or locale code
                                                      [string] [default: "auto"]
  -t, --to         The destination currency code or locale code
                                                      [string] [default: "auto"]
  -h, --help       Show help                                           [boolean]
  -v, --version    Show version number                                 [boolean]

Examples:
  forex 1000 -f USD -t EUR   Convert 1000 USD to Euros
  -------
  forex -t USD               Currency codes using ISO 4217
  forex -t US                Use locale codes from ISO 3166-1
  forex -t America           Use country or region name
  -------
  forex --from USD --to EUR  Specify base and target currencies
  forex --from USD           Specify one of the currencies and automat
                                       ically fill in the other currency through
                                        the OS's locale
  forex --to USD             Specify one of the currencies and automat
                                       ically fill in the other currency through
                                        the OS's locale
  • Convert 1000 USD to Euros.

    forex convert 1000 --from USD --to EUR
    
    ✔ Get the list of available currencies on latest 369ms
    ✔ Get the currency exchange rate between USD and EUR on latest 119ms
    ✨ 1,000.00 US Dollar (USD) ≈ 951.83 Euro (EUR)
    
  • Convert your 1000 quantity currency to Euros (acquired based on OS's locale).

    forex convert 1000 --to EUR
    
    ✔ Get the list of available currencies on latest 369ms
    ✔ Get the currency exchange rate between USD and EUR on latest 119ms
    ✨ 1,000.00 US Dollar (USD) ≈ 951.83 Euro (EUR)
    
  • Convert 1000 Euros to your currency (obtained based on OS's locale).

    forex convert 1000 --from EUR
    
    ✔ Get the list of available currencies on latest 369ms
    ✔ Get the currency exchange rate between EUR and USD on latest 119ms
    ✨ 1,000.00 Euro (EUR) ≈ 1,050.60 US Dollar (USD)
    
OptionTypeOptionalDefaultDescription
--from / -fstringtrue"auto"The base currency code or locale code
--to / -tstringtrue"auto"The destination currency code or locale code

$ CURRENCY

Get available currency codes and names.

forex currency [code]

Get available currency codes and names

Options:
  -d, --date       The date for the conversion rate, or "latest" for the most re
                   cent                             [string] [default: "latest"]
      --timeout    Request timeout (milliseconds)      [number] [default: 10000]
      --translate  Translate occurrences of currency or region names
                                                      [boolean] [default: false]
  -v, --version    Show version number                                 [boolean]
  -h, --help       Show help                                           [boolean]

Examples:
  forex cy US       Obtained via ISO-3166-1-alpha-2 region code
  forex cy USD      Obtained via ISO 4217 currency code
  forex cy America  Get by country or region name
  • Obtained via ISO-3166-1-alpha-2 region code.

    forex currency US
    
    ✔ Get the list of available currencies on latest 369ms
    ✨ US Dollar (USD)
    
  • Obtained via ISO 4217 currency code.

    forex currency USD
    
    ✔ Get the list of available currencies on latest 369ms
    ✨ US Dollar (USD)
    
  • Get by country or region name.

    forex currency America
    
    ✔ Get the list of available currencies on latest 369ms
    ✨ US Dollar (USD)
    

$ LIST

Print list of available currencies.

forex list -h
forex list

Print list of available currencies

Options:
  -d, --date       The date for the conversion rate, or "latest" for the most re
                   cent                             [string] [default: "latest"]
      --timeout    Request timeout (milliseconds)      [number] [default: 10000]
      --translate  Translate occurrences of currency or region names
                                                      [boolean] [default: false]
  -p, --pretty     Pretty output format               [boolean] [default: false]
  -v, --version    Show version number                                 [boolean]
  -h, --help       Show help                                           [boolean]

Examples:
  forex ls     Shows the latest list of available currencies
  forex ls -p  Use unicode table to prettier printed content
OptionTypeOptionalDefaultDescription
--pretty / -pbooleantruefalsePretty output format
  • Shows the latest list of available currencies.

    forex list
    
    Bitcoin (BTC)
    Chinese Yuan Renminbi (CNY)
    Ethereum (ETH)
    Euro (EUR)
    Japanese Yen (JPY)
    Hong Kong Dollar (HKD)
    Singapore Dollar (SGD)
    US Dollar (USD)
    Tether (USDT)
    Gold Ounce (XAU)
    ...
    
  • Use unicode table to prettier printed content.

    forex list --pretty
    
    ┌──────┬────────────────────────────────┬──────────────────────────────────────────┐
    │CODE  │NAME                            │TRANSLATION                               │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │BTC   │Bitcoin                         │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │CNY   │Chinese Yuan Renminbi           │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │ETH   │Ethereum                        │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │EUR   │Euro                            │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │JPY   │Japanese Yen                    │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │HKD   │Hong Kong Dollar                │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │SGD   │Singapore Dollar                │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │USD   │US Dollar                       │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │USDT  │Tether                          │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │XAU   │Gold Ounce                      │ -                                        │
    ├──────┼────────────────────────────────┼──────────────────────────────────────────┤
    │...   │...                             │...                                       │
    └──────┴────────────────────────────────┴──────────────────────────────────────────┘
    

$ COMPLETION

Generate completion script.

forex completion -h
###-begin-forex-completions-###
#
# yargs command completion script
#
# Installation: forex completion >> ~/.bashrc
#    or forex completion >> ~/.bash_profile on OSX.
#
_forex_yargs_completions()
{
    local cur_word args type_list

    cur_word="${COMP_WORDS[COMP_CWORD]}"
    args=("${COMP_WORDS[@]}")

    # ask yargs to generate completions.
    type_list=$(forex --get-yargs-completions "${args[@]}")

    COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )

    # if no match was found, fall back to filename completion
    if [ ${#COMPREPLY[@]} -eq 0 ]; then
      COMPREPLY=()
    fi

    return 0
}
complete -o bashdefault -o default -F _forex_yargs_completions forex
###-end-forex-completions-###

$ HELP

Show help.

forex help
  • Show convert help.

    forex convert help
    
  • Show currency help.

    forex currency help
    
  • Show list help.

    forex list help
    

🌐 i18n

Language NameNative NameISO-639-1ISO-3166-1 (Alpha-2)Locale File
English-enUSen-US.ts
Chinese Simplified简体中文zhCNzh-CN.ts
  • forex - 💱 A JavaScript foreign exchange library via fawazahmed0's API.

🤝 Contribution

Contributions via Pull Requests or Issues are welcome.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

Keywords

forex

FAQs

Package last updated on 14 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts