Git Product home page Git Product logo

exch's Introduction

exch

travis CI stability badge python version supported badge code coverage percentage of the current build badge PyPI version of the app badge

An application to see the currency exchange rates right from your command-line.

Features:

  • offline support
  • default curreny
  • list the available currencies

Installation

$ pip install exch

basic usage

$ exch -a 99 -b USD -t INR
99.0 USD = 6372.61 INR

$ exch --amount 199 --base EUR --target JPY
199.0 EUR = 25613.29 JPY

Demo

asciicast

Commands

Short Long Description Example
-t --target Currency you're converting to. exch -t INR
-b --base Currency you're converting from. exch -b EUR
-a --amount Amount of money to convert exch -a 99
-st --set_target Set the new tagert currency exch -t CAD -st
-sb --set_base Set the new tagert currency exch -b USD -sb
--help Show help message. exch --help
currencies List the Currencies that are available. exch currencies
sync Get the latest exchange rates for local use exch sync

Advance usage

Default amount is 1

$ exch -b USD -t PHP
1.0 USD = 51.23 PHP

Default currencies

When no base or target given, the program assumes the default currencies.

$ exch
1.0 USD = 64.02 INR

Set the currency in use as default with -sb for base and -st for target.

$ exch -a 99 -b EUR -t NZD -sb -st
99.0 EUR = 168.00 NZD

$ exch
1.0 EUR = 1.70 NZD

Built with

Programming language

Libraries used:

  • Click - for making the command-line interface
  • Requests - for API calls

Contribution

For contribution, please refer CONTRIBUTING.md

Changlog

For changelog, please refer CHANGELOG.md

License

This project is licensed under the MIT License - see the LICENSE file for details

exch's People

Contributors

anshulxyz avatar kxze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

exch's Issues

exception handling

handle exceptions such as:

  • lost internet connection
  • improper input given

put it on pypi ?

sounds like something I would use but I would rather install it from pypi
python3 -mpip install -U exch --user didn't work is it available there ?

cheers

Change default currency

Currently the default are set like this:

@click.option('--base', '-b', default='USD', type=str, show_default=True,
              help='Currency you are converting from.')
@click.option('--target', '-t', default='INR', type=str, show_default=True,
              help='Currency you\'re converting to.')

Where defaults are set to USD and INR.

User should be able to change this to his preference.

list currencies

Hi,

It's sometimes tough to guess the currency names, would it be possible to have a flag, for instance -l, to list currencies andtheir country ? it could be loaded from hardcoded json for offline support too.

Nb: I am currently packaging this for nixos.org

refactor some code

  • Q. Why am I using isinstance() here:
    output = fixer(base, target, amount)
    if isinstance(output, float):
        output = "{} {} = {} {}".format(amount, base, output, target)

    click.echo(output)
  • A. Because when the currency is invalid the operation is returning a string.
except KeyError:
        result = 1.00 if base == target else "KeyError: Invalid curreny"

    return result
  • Add newline at the end of the JSON files that are being written. Such as here

  • Look for a better way to handle Connection Error Exception.

  • Refactor file_handling.py

add offline support

I shouldn't make an API call every a command is fired. That will be abusing the
free API. Running something locally will always be faster than making online
requests. So I'll save the JSON. And have the --sync option to update the
rates.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.