Skip to main content

Hopla is a CLI to interact with the habitica.com API

Project description

Hopla

hopla stars - hopla
Continuous Integration

hopla - a command line interface (CLI) for habitica.com

Hopla is a XDG-compliant CLI which uses python3 to interact with the Habitica API.

Hopla is currently under active development so new features are added rapidly.

How to Use Hopla

Installation

Clone this repository by running:

git clone "git@github.com:melvio/hopla.git"
# Or, by using HTTPS:
git clone "https://github.com/melvio/hopla.git"
# Or (my favorite), by using gh:
gh repo clone melvio/hopla

Now cd into the repository with:

cd ./hopla 

And install Hopla by running:

pip install --upgrade --editable .

First Time Usage

Hopla needs your User Id and API Token to connect to Habitica. You can find these over at https://habitica.com/user/settings/api.

Run the following command to configure this automatically:

$ hopla authenticate 
Please enter your credentials.
You can find them over at <https://habitica.com/user/settings/api>.
They have the following format: 'c0ffee69-dada-feed-abb1-5ca1ab1ed004'.
The user id can be found under 'User ID'.
Please paste your user ID here (press Ctrl-C to abort): c0ffee69-dada-feed-abb1-5ca1ab1ed004
Please paste your user API Token here (input remains hidden):

This will create a credentials file at ~/.config/hopla/authenticate.conf that Hopla uses. If you want to use a different file, you can set the ${HOPLA_AUTH_FILE} environment variable to choose your own file.

Autocompletion

If you want bash autocompletion, you can run the following command:

$ hopla complete bash --enable
enabled autocompletion
restart bash to make use of it

To print the autocomplete code for bash|zsh|fish, so that you can install it yourself, optionally run:

# optionally, install the autocomplete code yourself:
hopla complete bash
hopla complete zsh
hopla complete fish

Everyday Usage

After installation, you can use hopla. The supported commands can be found by running:

$ hopla --help
Usage: hopla [OPTIONS] COMMAND [ARGS]...

  hopla - a command line interface (CLI) to interact with habitica.com

Options:
  --version   Show the version and exit.
  -h, --help  Show this message and exit.

Commands:
  add                  GROUP for adding things to Habitica.
  api                  GROUP for requesting Habitica API metadata.
  authenticate         Authorize yourself to access the Habitica.com API.
  buy                  GROUP to buy things.
  complete             Print or enable shell autocompletion.
  # etcetera

More functionality is currently being implemented. Hopla is open-source. Pull request, feature requests, and issues are welcomed at https://github.com/melvio/hopla. If you want to contribute, but don't know where to start, you might want to look in the ./developers. folder.

License

Environment Variables for Hopla's options

Use case: You can use environment variables to set default values for all Hopla options.

Hopla automatically recognizes environment variables starting with HOPLA_. All option (such as --difficulty for hopla add todo and --amount for hopla feed) can be set in this manner.

To get the right environment variable name, use this logic:

  1. Define an environment variable starting with HOPLA_

  2. Append the subcommand to the environment variable as follows:

    • hopla add todo -> HOPLA_ADD_TODO_
    • hopla support-development -> HOPLA_SUPPORT_DEVELOPMENT_
    • hopla feed -> HOPLA_FEED_
  3. Append the option name that you want to set as follows:

    • hopla add todo --difficulty -> HOPLA_ADD_TODO_DIFFICULTY
    • hopla support-development --gems -> HOPLA_SUPPORT_DEVELOPMENT_GEMS
    • hopla feed --amount -> HOPLA_FEED_AMOUNT

For example:

HOPLA_ADD_TODO_DIFFICULTY=hard    hopla add todo "Hello"
HOPLA_SUPPORT_DEVELOPMENT_GEMS=8  hopla support-development
HOPLA_FEED_AMOUNT=3               hopla feed Wolf-Shade Chocolate

Other examples:

# add a To-Do for today
HOPLA_ADD_TODO_DUE_DATE=today hopla add todo "Task with Deadline from today"

# automatically enable autocomplete for bash 
HOPLA_COMPLETE_ENABLE=true    hopla complete bash
HOPLA_COMPLETE_ENABLE=yes     hopla complete bash
HOPLA_COMPLETE_ENABLE=1       hopla complete bash

# only print autocomplete for bash
HOPLA_COMPLETE_ENABLE=0       hopla complete bash   
HOPLA_COMPLETE_ENABLE=false   hopla complete bash   
HOPLA_COMPLETE_ENABLE=no      hopla complete bash   

Background

Hopla is a XDG-compliant bash-based command line interface (CLI). It was created because no other CLI supported the creation of To-Dos with both a due date and a checklist. Hopla provides the following command to create these with the following command:

# Add a hard To-Do. Every line in the specified file will being added as
#  an item of this To-Do's checklist.
hopla add todo --difficulty hard \
               --due-date 2027-12-07 \
               --checklist ./my_todo.txt \
               "my todo name here"

The most simple way to add a To-Do would be to run hopla add todo without arguments. Hopla will then prompt you for a To-Do name:

$ hopla add todo
Please provide a name for your todo: Feed the dog

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hopla-cli-0.0.12a0.tar.gz (65.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hopla_cli-0.0.12a0-py3-none-any.whl (82.9 kB view details)

Uploaded Python 3

File details

Details for the file hopla-cli-0.0.12a0.tar.gz.

File metadata

  • Download URL: hopla-cli-0.0.12a0.tar.gz
  • Upload date:
  • Size: 65.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hopla-cli-0.0.12a0.tar.gz
Algorithm Hash digest
SHA256 ffad63f4f9650f36c8a9034d60e93639ea8a55e0d242471ab3f545eb298d380b
MD5 f8b08fa7538be9ff31b7784e1e0ac5f0
BLAKE2b-256 c7c2f64cb8bdb0c1d808a6890d7368bb6550412e5183a6057ef5a6e367e671aa

See more details on using hashes here.

File details

Details for the file hopla_cli-0.0.12a0-py3-none-any.whl.

File metadata

  • Download URL: hopla_cli-0.0.12a0-py3-none-any.whl
  • Upload date:
  • Size: 82.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hopla_cli-0.0.12a0-py3-none-any.whl
Algorithm Hash digest
SHA256 911382659f15b51275a2b1e1c76a7d65010346dc4951433a4d7a81b39b2240c3
MD5 225d9f467e04b05d08093eab3deee28a
BLAKE2b-256 a7eb834165bffceb16756f7fb8c2b7faa4ded1241b78df5028a3ae7642e2d41b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page