Skip to main content

Bert's Cheat Notes cli

Project description

Introduction

bt-cheater is a general-purpose cheatsheet tool powered by python.

The tool provides a way search through snippets of text stored in plain-text files using keywords, and all from the commandline.

The search logic relies on a simple structure for the text: a cheat header and body, e.g.

# python ternary assignments # ternary # variables
    This is a note on python ternary variable assignments
# bash loops # loops
    This is text on bash loop structures
# civil # war # us
    Dates: Apr 12, 1861 - May 9, 1865

As illustrated above, the header is comprised of Cheat Terms, which are keywords delimited by octothorpes (#).

The whitespace padding is optional and improves readability.

Configuration file

cheater can read yaml config files formatted as:

search:
  paths:
    - ~/Documents/notes
    - ${HOME}/Documents/more_notes
    - ~/notes
  filters:
    - md
    - txt

These are the settings recognized by the tool:

Key Value
paths List of cheat file paths to search against
filters List of file extensions to search for

If no config file is specified, the tool will attempt to read one from the following locations, in order of precedence:

  • /etc/bt-cheater/config.yaml
  • ./config.yaml
  • ~/.bt-cheater/config.yaml

Usage

Usage: cheater find [OPTIONS] TOPICS...

  Find cheat notes according to keywords

Options:
  --version                     Show the version and exit.
  -e, --explode-topics          Write results to their own cheat files
  -c, --cheatfile TEXT          Manually specify cheat file(s) to search
                                against
  -p, --cheatfile-path TEXT     Manually specify cheat file paths to search
                                against
  -L, --local_cheat_cache TEXT  Specify root folder you want to store cheats
                                as retrieved from git (defaults to ~/.cheater)
  -F, --force_git_updates       Force updates for cheat repos retrieved via
                                git
  -a, --any                     Any search term can occur in the topic header
                                (default is "all")
  -b, --search-body             Search against cheat note content instead of
                                topic headers
  --no-pause                    Do not pause between topic output
  --help                        Show this message and exit.

  Examples:
  bt-cheater find -c ~/Documents/cheats.md foo bar baz
  bt-cheater find -c ~/Documents/cheats.md foo bar baz
  bt-cheater -C my_special_config.yaml find -c ~/Documents/cheats.md foo bar baz

  If no config file is specified, the tool will attempt to read one from the
  following locations, in order of precedence:

  - /etc/bt-cheater/config.yaml 
  - ./config.yaml 
  - ~/.bt-cheater/config.yaml

Usage examples

Given: Your config file is configured to search through '~/Documents/notes' for cheat files, that is, your configuration file is ~/.cheater/config.yaml, with contents:

search:
  paths:
    - ${HOME}/Documents/notes
  filters:
    - md
    - txt
  • You want to find topic headers containing the words foo bar and baz
    • bt-cheater find foo bar baz
  • You want to search a specific cheat file, ~/Documents/cheats.md, for topic headers containing the words foo bar and baz
    • bt-cheater find -c ~/Documents/cheats.md foo bar baz
  • Same as above, but you also want to specify your own configuration file my_special_config.yaml
    • bt-cheater -C my_special_config.ini find -c ~/Documents/cheats.md foo bar baz
      Note: Because you explicitly specified the cheat file, any cheat paths defined in your config will be skipped

Tips

As bodies of text may overlap in their keyword designation, specifying multiple terms can help narrow down search results if you specify a search condition.

As such, the default search logic is all, where all search terms must occur in the topic header (logically equivalent to AND).

If you want to broaden your search criteria, use the -a/--any flag, instructing cheater to consider any search term present in the topic header (logically equivalent to OR).

How do I get started?

Installation

Using Pip

Just run pip install git+https://github.com/berttejeda/bert.cheater.git

Or clone this repo, switch to the project root cd bert.cheater, and pip install -e ., then calling python bertdotcheater/cli.py --help

Using Standalone Script

Install requirements with pip install -r requirements.txt and copy the bertdotcheater/cli.py script to wherever your heart desires.

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

bt-cheater-2.0.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

bt_cheater-2.0.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file bt-cheater-2.0.0.tar.gz.

File metadata

  • Download URL: bt-cheater-2.0.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for bt-cheater-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c36591dd683e834837e853e705c469861b966480f6ae69588979d3f015d37d45
MD5 2aecfde42e80473531ad111fc6711c90
BLAKE2b-256 fe677443599736ec8621964a74ff713365fa10dbb015c99f266b9ade57d6923c

See more details on using hashes here.

File details

Details for the file bt_cheater-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: bt_cheater-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for bt_cheater-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbebcd5f7c1784099711c0e6a8cd6110bac42985b2562628c5c63937fa7bb4a9
MD5 c8eb0644f28b18ce97348029f66999ac
BLAKE2b-256 676f9f8b5e8a413506d238e531df1548c9c9abc9615783b6a368f205175daa47

See more details on using hashes here.

Supported by

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