Skip to content

Commit

Permalink
Handle filename in cli, update docs (#6)
Browse files Browse the repository at this point in the history
* Add tags to package, resolve #5

* Add npx info, reword first section, resolves #3

* Move options footnotes to table, resolve #2

* Add npm badge, resolve #4

* Handle cli file overwriting, resolve #1

* 1.1.2
  • Loading branch information
peterthehan committed Feb 9, 2021
1 parent 78b7d96 commit a682824
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
58 changes: 21 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RuneScape Text

[![Discord](https://discord.com/api/guilds/258167954913361930/embed.png)](https://discord.gg/WjEFnzC) [![Twitter Follow](https://img.shields.io/twitter/follow/peterthehan.svg?style=social)](https://twitter.com/peterthehan)
[![NPM](https://nodei.co/npm/runescape-text.png?mini=true)](https://www.npmjs.com/package/runescape-text) [![Discord](https://discord.com/api/guilds/258167954913361930/embed.png)](https://discord.gg/WjEFnzC) [![Twitter Follow](https://img.shields.io/twitter/follow/peterthehan.svg?style=social)](https://twitter.com/peterthehan)

Convert text to a text image with [RuneScape](https://www.runescape.com/) chat effects.

Expand Down Expand Up @@ -44,9 +44,9 @@ Refer to this wikiHow guide on [How to Write Text Effects on RuneScape](https://

## Table of contents

- [Install](#install)
- [Globally](#globally)
- [Locally](#locally)
- [Getting started](#getting-started)
- [Execute](#execute)
- [Example](#example)
- [Syntax](#syntax)
- [Parameters](#parameters)
- [Options](#options)
Expand All @@ -55,19 +55,15 @@ Refer to this wikiHow guide on [How to Write Text Effects on RuneScape](https://
- [Exceptions](#exceptions)
- [Help](#help)

## Install
## Getting started

### Globally
### Execute

```
$ npm i -g runescape-text
$ npx runescape-text "wave:glow3: hello world"
```

```
$ runescape-text "wave:glow3: hello world"
```

### Locally
### Example

```
$ npm i runescape-text
Expand Down Expand Up @@ -105,31 +101,19 @@ getRuneScapeText(string, [options], [wordWrapOptions]);

#### Options

| Property | Type | Required | Default | Description |
| ---------------- | --------- | -------- | ---------- | -------------------------------------------------------------- |
| version | `string` | No | `"osrs"` | Game version to use [0] |
| color | `string` | No | `"yellow"` | Default color effect of the text [1] |
| motion | `string` | No | `"none"` | Default motion effect of the text [2] |
| suffix | `string` | No | `":"` | String that should suffix each color and motion string |
| replacement | `string` | No | `""` | String to replace characters the font does not support |
| maxMessageLength | `number` | No | `280` | Max message length allowed after the string has been sanitized |
| scale | `number` | No | `2` | Scale factor of the font (multiples of 16px) [3] |
| fps | `number` | No | `20` | Frames per second to render GIFs at [4] |
| cycleDuration | `number` | No | `3000` | Duration of one cycle before the GIF loops |
| quality | `number` | No | `100` | Quality to render GIFs at [5] |
| showLogs | `boolean` | No | `false` | Determines whether to print runtime logs or not |

[0] Must be: `osrs` or `rs3`.

[1] Must be: `yellow`, `red`, `green`, `cyan`, `purple`, `white`, `glow1`, `glow2`, `glow3`, `flash1`, `flash2`, or `flash3`.

[2] Must be: `none`, `wave`, `wave2`, `shake`, `scroll`, or `slide`.

[3] Impacts rendering times. Prefer integer values greater than or equal to 1, decimal values will render blurry text.

[4] Impacts rendering times. Prefer integer values less than or equal to 60.

[5] Impacts rendering times. More information [here](https://github.com/twolfson/gif-encoder#setqualityquality).
| Property | Type | Required | Default | Description |
| ---------------- | --------- | -------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| version | `string` | No | `"osrs"` | Game version to use, either: `osrs` or `rs3` |
| color | `string` | No | `"yellow"` | Default color effect of the text, either: `yellow`, `red`, `green`, `cyan`, `purple`, `white`, `glow1`, `glow2`, `glow3`, `flash1`, `flash2`, or `flash3` |
| motion | `string` | No | `"none"` | Default motion effect of the text, either: `none`, `wave`, `wave2`, `shake`, `scroll`, or `slide` |
| suffix | `string` | No | `":"` | String that should suffix each color and motion string |
| replacement | `string` | No | `""` | String to replace characters the font does not support |
| maxMessageLength | `number` | No | `280` | Max message length allowed after the string has been sanitized |
| scale | `number` | No | `2` | Scale factor of the font (multiples of 16px), prefer integer values greater than or equal to 1, decimal values will render blurry text |
| fps | `number` | No | `20` | Frames per second to render GIFs at, prefer integer values less than or equal to 60 |
| cycleDuration | `number` | No | `3000` | Duration of one cycle before the GIF loops |
| quality | `number` | No | `100` | Quality to render GIFs at, more information [here](https://github.com/twolfson/gif-encoder#setqualityquality) |
| showLogs | `boolean` | No | `false` | Determines whether to print runtime logs or not |

#### WordWrapOptions

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runescape-text",
"version": "1.1.1",
"version": "1.1.2",
"description": "Convert text to a text image with RuneScape chat effects.",
"keywords": [
"cli",
Expand All @@ -14,7 +14,9 @@
"buffer",
"gif",
"text-animation",
"effects"
"effects",
"osrs",
"rs3"
],
"homepage": "https://github.com/peterthehan/runescape-text",
"bugs": {
Expand Down
17 changes: 16 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@
const fs = require("fs");
const getRuneScapeText = require("./index");

const getFilename = () => {
return `runescape-text-${Date.now()}`;
};

const main = async () => {
const filename = getFilename();
if (
fs.existsSync(`./${filename}.gif`) ||
fs.existsSync(`./${filename}.png`)
) {
console.log(`File with name "${filename}" already exists! Exiting...`);
process.exitCode = 1;

return;
}

const [, , ...args] = process.argv;
const string = args.join(" ");
const options = { showLogs: true };

const { extension, buffer } = getRuneScapeText(string, options);

const path = `./runescape-text.${extension}`;
const path = `./${filename}.${extension}`;
fs.writeFileSync(path, await buffer);
console.log(`\nFile written to: ${path}`);
};
Expand Down

0 comments on commit a682824

Please sign in to comment.