Skip to content

PRBorges/dobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dobs

A console app that converts USD to BES (Venezuelan Bolivars) and viceversa. The exchange rate is scraped (and cached) from the BCV website.

Written in C# on .NET 8.

Usage

To get the current USD exchange rate from the BCV (Banco Central of Venezuela) just invoke the app:

$dobs
Bs. 36.56 | 05/08/2024

In the output, 36.56 is the result of converting US$ 1 —the default amount— to Venezuelan Bolivars with the exchange rate for the day shown: 05/08/2024. Dobs stores the current rate, and the previous one, if it has one, in a file within its subfolder in the ApplicationData folder and, by default, uses both rates for the conversions. The previous output occurs if the app has only one rate available.

To convert Bolivars to US Dollars, provide the -u flag:

$dobs 100 -u
US$ 2.73 | 05/06/2024
US$ 2.74 | 05/08/2024

If you only want the conversion with the last rate available, pass the -l flag:

$dobs 100 -u -l
US$ 2.74 | 05/08/2024

The exchange rates are rounded to 2 decimal places for the conversions, and the results are displayed with 2 decimals by default. The decimal places to display in the result of the conversion can be set with -d:

$dobs 25.75  -d 4
Bs. 941.4200 | 05/08/2024
Bs. 941.9350 | 05/09/2024

The standard -h or --help options are also available.

Notes:

  • Amounts and dates are formatted according to your system settings (i.e. the CurrentCulture).
  • The amount argument can not have any thousand separators.
  • The BCV usually updates the exchange rate each working day after 3:30 PM with the rate for the next working day. This means that the last rate can be one or more days ahead. For example, if the dobs app runs on a Friday after 3:30 PM it will fetch the rate for the following Monday.
  • When Dobs runs for the first time, it shows a warning message because it can not find the file with the app data from the previous run.

Installing

On the Download page, you will find binaries for win-x64 and linux-x64. Simply download the binary for your system and move the file to a directory of your choice, preferably on your path. For Windows, download dobs.exe, and for Linux, download dobs.

These binaries have been run in Windows 10 and WSL Ubuntu 22.04, respectively. For other platforms, or if you encounter any issues, you may build the app from source code.

Building from source code

Prerequisites

You will need .NET SDK 8.0 or newer. You can get it from the .NET Download Page.

Building

  1. Clone the repository: use git clone https://github.com/prborges/dobs.git.
  2. Navigate to the project directory: use cd dobs/src/Dobs.
  3. Build the application: run dotnet build.
  4. At this point, you can run the app with dotnet run.
  5. Generate the executable: run dotnet publish.
  6. You will find the executable at bin/Release/net8.0/<your-platform>/publish/ along with some .pdb files, which you can ignore.

For more information about this process visit Single-file deployment, and Publish .NET apps with the .NET CLI for other ways of publishing .NET apps.

Running the tests

The app code is organized in 2 projects: src/Dobs/dobs.csproj, and the RateProvider library in /src/RateProvider/RateProvider.csproj. Correspondingly, there are 2 test projects: tests/DobsTests/DobsTests.csproj and tests/RateProviderTests/RateProviderTests.csproj, as well as a helper library in tests/Utils/Utils.csproj.

To run any of the test projects, move to the folder with the project and run dotnet test. To run both test projects at once, run dotnet test in the app's root folder.

Contributing

I am not expecting any contribution, but you'll be welcome. Just contact me or open an issue, and we'll go from there.

License

© 2024 Pedro R. Borges(pedroborg@gmail.com). Released under the MIT License — see the LICENSE file for details. This software carries no warranty of any kind.