Skip to content

Commit

Permalink
Release/0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Dziura committed May 16, 2018
1 parent 26aecf2 commit abfb69e
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 191 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ Cargo.lock
.history

# End of https://www.gitignore.io/api/rust

sterling-conf.yml
24 changes: 24 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
image: "rust:latest"
stages:
- test
- deploy

cargo:test:
stage: test
only:
- master
script:
- cargo test --verbose

cargo:build:
stage: deploy
only:
- master
script:
- cargo build --release
cache:
paths:
- target/
artifacts:
paths:
- target/release/sterling
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: rust
os:
- osx
branches:
only:
- master
rust:
- stable
script:
- cargo test --verbose
- cargo build --release
before_deploy:
- git config --local user.name "Zachary Dziura"
- git config --local user.email "zcdziura@gmail.com"
- git tag "$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)-osx"
deploy:
provider: releases
api_key:
secure: "NVH5d3CH0QUyFSu0MbeB3WvSo52qwjxH98wIL7kieD/kbTrTzTCbTWiTCV+/OM41nWOdxTy9T5TLqDsrh4k4xCkb4VbKTcsfIpBaQqwMvT6Co/GgLr4xSiHBI/ENBVwbnyDavMxh/E5AAAPF/HgGci2tEqzNuu9V7jon6uhb8+WovbfZeEA4tSNLsWV5g3MwssMfdaWzDPTHsiWXFPn6AVhkmy4fKAIHoUtp37A7bqx1hGPpFD3OGYN1oDxtJK5jRBSXegyWh08RQkLQ74PJTWD6Xw+Hvp1ewP1vitP69VJgsBC496jPasqAEOVeD3KogtcmBEyaIG+I5LZWLTibs41qF83cxJDdWxw69H827IXSQobM+7Sc51chWJR0H3OA1yDPQvorI1C17zvXd4wPpDfSUeY5ZqAplnYMOxk3jDbbX099bEyRE/skWHRaqL99fV7i5bO3aHDFP/BDjp03hnzpvfKs9zm05e87LStriNYQ5NsCPkdX+W18Q15DLhS2D9cp37PPAUA5jLNUFiEY5x9fwl5XEpefBqrqmE8qbmkc9GTr3MZikmTfB51Nx5NvkybCTKhMoKw5AhNLmw0fnkaqxrei7Uif7WqxTkngJep6VLidmt2pRJ9Qj3AWOXsLZJPm0ZQuo71dWC049EeEVtfQkyz/9K2J+iNVRgdiEeg="
file_glob: true
file: target/release/sterling
skip_cleanup: true
on:
repo: zcdziura/sterling
branch: master
addons:
artifacts: true
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sterling"
version = "0.2.0"
version = "0.3.0"
description = "Converts a given D&D 5e currency value to the Silver Standard."
authors = ["Zachary Dziura <zcdziura@gmail.com>"]
readme = "README.md"
Expand All @@ -9,9 +9,9 @@ repository = "https://gitlab.com/zcdziura/sterling"
keywords = ["dnd", "coins", "converter", "currency", "5e"]

[dependencies]
clap = "2.31.1"
lazy_static = "1.0.0"
regex = "0.2"
clap = "2.31"
lazy_static = "1.0"
regex = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_yaml = "0.7"
Expand Down
File renamed without changes.
File renamed without changes.
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@ and [I make Silver Standard for 5th Edition (Spreadsheets.)](https://www.reddit.

```
USAGE:
sterling.exe [FLAGS] [OPTIONS] [VALUE]...
sterling [FLAGS] [OPTIONS] [VALUE]... [SUBCOMMAND]
FLAGS:
-f, --full Print currencies with full name, rather than with alias.
-h, --help Prints help information
-V, --version Prints version information
-o, --optional Include currencies marked as optional when converting.
-f, --full Print currencies with full name, rather than with alias.
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --config <CONFIG> Specify location of config file; defaults to './sterling-conf.yml'.
ARGS:
<VALUE>... The value to be converted; should be suffixed with the coin's short-hand
abbreviation, i.e. p, g, e, s, or c.
<VALUE>... The value to be converted; should be suffixed with the coin's short-hand abbreviation, i.e. p, g,
e, s, or c.
SUBCOMMANDS:
add Add two currency amounts together; uses the currencies defined in your config file
help Prints this message or the help of the given subcommand(s)
sub Subtract two currency amounts from one another; uses the currencies defined in your config file
```

## Examples
## Converting Currency Examples

```
// Convert one hundred platinum coins:
Expand All @@ -41,22 +47,43 @@ sterling --full 1p 36g 12e 82s 469c // 64 silver, 89 copper
// Convert one platinum, thirty-six gold, twelve electrum, eighty-two silver, and four hundred
// sixty-nine copper coins, printing the full names of the coins, using the custom config file
// detailed below.
sterling --full -c "~/Documents/D&D/sterling-conf.yml" 1p 36g 12e 82s 469c // 27 sterling, 9 farthing
// detailed below, including optional currencies
sterling --full -o -c "~/Documents/D&D/sterling-conf.yml" 1p 36g 12e 82s 469c // 27 sterling, 9 farthing
```

## Adding and Subtracting Currency Examples

```
// Add together ten and twenty pense, using the custom config file detailed below
sterling add "10p" "20p" // 1s, 10p
// Subtract two sterling and ten pence from one florin
sterling sub "1F" "2s 10p" --full // 33 sterling, 10 pence
// Subtract one florin from two sterling and ten pence. Note that, regardless of order, the smaller
// value is ALWAYS subtracted from the larger value.
sterling sub "2s 10p" "1F" --full // 33 sterling, 10 pence
```

Note that `sterling` doesn't allow for negative currencies. Therefore, when subtracting currencies,
the smaller currency value will always be subtracted from the larger currency value, regardless of
the order of the currencies in the `sub` command.

## Custom Currencies

`sterling` allows for user-defined currencies, with their own names and conversion rates. By
default, `sterling` will look at a file within the current directory called `sterling-conf.yml`, or
in whatever location as supplied by the `-c` flag. Below is an example `sterling-conf.yml` file,
showing the actual currencies that I use within my own campaign!
in whatever location as supplied by the `-c` flag. You can also specify that a currency be optional,
which will prevent that currency from being used when converting values, unless the `-o` flag is
passed. Below is an example `sterling-conf.yml` file, showing the actual currencies that I use
within my own campaign!

```
-
name: "florin"
rate: 8640
alias: "F"
optional: true
-
name: "sterling"
rate: 240
Expand Down Expand Up @@ -94,15 +121,16 @@ while a suit of heavy plate armor equals fifteen gold coins, rather than fifteen

## Installation

Make sure that you first have `rust` and `cargo` installed onto your computer before downloading
`sterling`. Just follow the simple
[Installation Guide](https://doc.rust-lang.org/cargo/getting-started/installation.html) on the
official Rust language website to install both programs.

Once `rust` and `cargo` are installed onto your computer, run the following command:
The easiest way to install `sterling` is to do so with `cargo`, the build tool that's installed
along with the `rust` compiler. If you already have `rust` and `cargo` installed onto your computer,
simply run the following command from a command prompt:

`cargo install sterling`
```
$ cargo install sterling
```

This will install `sterling` into the `.cargo/bin` directory within your User directory
(`/home/YOUR_USER_NAME` on Linux and macOS, `C:\Users\YOUR_USER_NAME` on Windows). Be sure to add
this directory to your PATH.
If you do not have the `rust` compiler installed, you can also find pre-built binaries for 64-bit
Windows, macOS, and Linux computers in the "Tags" navigation link, which is displayed above this
README. Simply download the correct binary for your computer's operating system, extract it
somewhere into your file system (such as a "bin" folder within your user directory), and add that
location to your system's PATH.
29 changes: 29 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
os: Visual Studio 2015
branches:
only:
- master
environment:
matrix:
- channel: stable
target: x86_64-pc-windows-gnu
artifacts:
- path: target/release/sterling.exe
name: sterling
install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %channel% --default-host %target%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -vV
- cargo -vV
build: false
test_script:
- cargo test --verbose
- cargo build --release
deploy:
provider: GitHub
description: ''
auth_token:
secure: bvA/4J1T0h65ur6tsg6k/wlZFjP3qr2QsyRsmGMEmm7DOF61xmzTnjuBcPjQYrba
artifact: target/release/sterling.exe
on:
branch: master
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::convert::From;
use std::error::Error;
use std::fmt::{self, Display, Formatter};
use std::convert::From;
use std::fs::File;
use std::io::{self, BufReader, ErrorKind};

Expand All @@ -18,10 +18,10 @@ pub fn load_config(filename: &str) -> Result<Vec<Currency>, ConfigError> {

pub fn default_config() -> Vec<Currency> {
vec![
Currency::new("platinum", 1000000, "p", None),
Currency::new("gold", 10000, "g", None),
Currency::new("silver", 100, "s", None),
Currency::new("copper", 1, "c", None),
Currency::new("platinum", 1000000, "p", None, None),
Currency::new("gold", 10000, "g", None, None),
Currency::new("silver", 100, "s", None, None),
Currency::new("copper", 1, "c", None, None),
]
}

Expand Down
Loading

0 comments on commit abfb69e

Please sign in to comment.