published on in about programs documentation projects
tags: mq perl6 maths

mq

A command line program that tests your knowledge of arithmetic (addition/subtraction, multiplication/division), and then logs the results, written in Perl 6, and licensed under the GNU GPL v3.0 (or any later version)

This document is about mq version 1.5.x, but the installation instructions will install the latest version

Note: $MQ_CONFIG_DIR was added in v1.4.0

What is mq?

mq is a program that asks you maths questions

How to use?

mq <mode> <max>

Mode "level1"
Addition, subtraction
Mode "level2"
Multiplication, division
Mode "get-group"
Get the group length
Mode "get-max"
Get the maximum number
Optional named argument "disable-log"
Disable the log file, added in v1.5.0
Optional named argument "group"
Set the group length, added in v1.5.0

Example: mq --disable-log --group 5 level1 10

Configuration file

Where is the configuration file?

If $MQ_CONFIG exists, then the config file is $MQ_CONFIG.
If it does not exist, but $MQ_CONFIG_DIR exists then the config file is $MQ_CONFIG_DIR/config.toml.
Otherwise, the config file is ~/.mq/config.toml (default).

What format is it in?

It is written in TOML 0.4.0

What keys/sections are there?

The section "mq"

The integer "group"
The length of the group, can be set to any integer

What does it look like?

[mq]
group = 20
length = 10

Log file

Where is the log file?

If $MQ_LOG exists, then the config file is $MQ_LOG.
If it does not exist, but $MQ_CONFIG_DIR exists then the config file is $MQ_CONFIG_DIR/log.slf.
Otherwise, the config file is ~/.mq/log.slf (default).

What format is it in?

SLF (The Simple Log Format), basically CSV/DSV separated with spaces

Installation instructions

These instructions use GitHub, but you can use GitLab or Noisytoot Git instead, by replacing the URI you get mq from

For UNIX and UNIX-like operating systems (like GNU/Linux, BSD, Mac OS X)

Using git

Install mq:

cd ~
git clone https://github.com/Noisytoot/mq.git
cd mq
ln -s $PWD/mq.p6 /usr/local/bin/mq # Replace /usr/local/bin/mq with where you want to install mq, you may need root permissions to run this
mkdir ~/.mq

Update mq:

cd ~/mq
git pull

Using wget

Install, and update mq:

cd /usr/local # Replace /usr/local with where you want to install mq
wget https://raw.githubusercontent.com/Noisytoot/mq/master/mq.p6 -O mq # You may need root permissions to run this
chmod +x mq

For other operating systems (like Windows)

I do not currently have instructions for other operating systems, but basically you need to download mq.p6, add executable permissions if the OS has them, and put it into your PATH

GitHub GitLab Noisytoot Git