Skip to content

Silliness automated: Generates random words based on templates.

Notifications You must be signed in to change notification settings

CaptainSpof/random-ramble

Repository files navigation

Random Ramble

Refactor in progess

EWW! Your code is ugly!

Yes, I know and I am very self consious about it! I’ll eventually get good at writing Rust… Maybe. In the meantime, checkout the todo list.

Table of Contents

Description

Random Ramble is a simple random words generator written in rust.

It aims to generate a couple of words randomly based on parameters, such as starting patterns, themes etc.

One of its (few) usecase is to generate a sprint name or a release name.

Installation

Building from sources

To build from source: first, clone this repository.

git clone https://github.com/CaptainSpof/random-ramble.git

Prerequisites

Requires cargo 1.40 or newer

Build for dev

cargo build

Build for release

cargo build --release

Build a Docker image

docker build -t random-ramble .

Features

Template

By default, random-ramble will generate a couple of adjective and theme. It is however possible to specify a manual template.

The template follow the tera notation (which is inspired by Jinja2)

This allow multiple features:

  • random entry from all themes / adjs

    Available choices are:

    • adj for adjectives
    • theme for themes
    {{ adj }} {{ theme }}
        
  • random entry from a specific subset

    Allow you to limit the categorie of either adj or theme

    {{ adjs.en.0 }} {{ themes.superhero.0 }}
        
  • filter the output

    You can apply a filter to the output:

    {{ adj | title }} {{ themes.superhero.0 | upper }}
        

Limitations

nested objects need to have an index

field in the dot notation need an index .i.e:

{{ themes.superhero.0 }} {{ themes.superhero.1 }}

SubCommands

add

Add one or multiple entries to a theme or create a new one if the theme is not found.

Examples

Add to an existing theme
rr add superhero Batman
Add from a list in a file
rr add superhero < /tmp/heroes.txt
Add to an adjective
rr add -a fr Inutile

delete

Remove one or multiple entries from a theme.

Aliases

  • remove
  • del

Examples

Remove from a theme
rr del superhero Batman
Remove from a list in a file
rr del superhero < /tmp/heroes.txt
Remove from an adjective
rr del -a fr Inutile

Usage

random-ramble 0.3.0
Cédric Da Fonseca <dafonseca.cedric@gmail.com>
A simple random words generator

USAGE:
    rr [FLAGS] [OPTIONS] [pattern] [SUBCOMMAND]

FLAGS:
    -h, --help
            Prints help information

    -V, --version
            Prints version information

    -v, --verbose
            -v:		INFO|WARN|ERROR
            -vv:	INFO|WARN|ERROR|DEBUG
            -vvv:	INFO|WARN|ERROR|DEBUG|TRACE

OPTIONS:
    -a, --adjectives <adjectives>...
            A list of adjectives to be chosen from

        --adjectives-path <adjectives-path>
            Path to the adjectives files [env: RR_ADJS_PATH=~/Projects/Rust/random-ramble/dict/adjectives]
            [default: ./dict/adjectives]
    -n <number>
            The length of the list to be returned [env: RR_NB_RESULT=]  [default: 10]

    -T, --template <template>
            Provide a template from which to generate words

    -t, --themes <themes>...
            A list of themes to be chosen from

            Themes preceded by '!' will be excluded
        --themes-path <themes-path>
            Path to the themes files [env: RR_THEMES_PATH=~/Projects/Rust/random-ramble/dict/themes]  [default:
            ./dict/themes]

ARGS:
    <pattern>
            The pattern to start with


SUBCOMMANDS:
    add       Add entries to a theme, or create a new theme
    delete    Delete entries from a theme [aliases: remove, del]
    help      Prints this message or the help of the given subcommand(s)

Configuration

This project is configured via environment variables or by setting the desired values via the CLI.

General

number

The number of results to be generated.

default value: 10

Example

Environment Variable
export RR_NB_RESULT=25
Command Line
./rr -n 25 [...]

themes path

The path to the themes files.

default value: “./dict/themes”

Example

Environment Variable
export RR_THEMES_PATH="~/.local/random_ramble/themes"
Command Line
./rr --themes-path="~/.local/random_ramble/themes" [...]

adjectives path

The path to the adjectives files.

default value: “./dict/adjectives”

Example

Environment Variable
export RR_ADJS_PATH="~/.local/random_ramble/adjectives"
Command Line
./rr --adjectives-path="~/.local/random_ramble/adjectives" [...]

Examples

Pattern - starts with

Generate random words with default parameters, for words starting with ‘A’:

./rr a

output:

Awful All-father Hercules
Abusive Abe Sapien
Abnormal Ariel
Awesome Airman
Athletic Aegis
Adorable All For One
Awkward Adam Destine
Abject Agent Mulder
Aboriginal Amunet Black
Able Aegeus

Specify a length

Generate 3 random words with default parameters, for words starting with ‘A’:

./rr a -n 3

output:

Absorbed Ajax
Abnormal Akron
Angelic Alexander Anderson

Specify a theme

Generate 3 random words of theme ‘animals’ with default parameters, for words starting with ‘A’:

./rr a -n 3 --themes animal

output:

Arrogant Aardvark
Apprehensive Anteater
Alive Antelope

Exclude a theme

Generate 3 random words of any available theme besides ‘disney’ with default parameters:

./rr -n 3 --themes '!disney'

output:

Ambitious Dogfish
Stormy Fironic
Resourceful Magpie

Specify a template

Generate a template with random entries:

./rr -T '{{ themes.male_name.0 }}, the {{adjs.superlative.0 | lower }} {{ adj | lower }} {{ themes.color.0 | lower }} {{ themes.videogame.0 }}' -n 4

output:

Alexander, the faintest mission-critical pink Peach
Asher, the funniest condescending yellow Agent 47
Thomas, the bloodiest tough white Vault Boy
Mateo, the busiest gangsta tilleul Dovahkiin

Generate random words for each themes (with fd)

fd . -t f dict/themes --exec ./rr -t '{/}'

Troubleshooting

About

Silliness automated: Generates random words based on templates.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published