Skip to main content

A command line tool for watching files and running shell commands when they change.

Project description

Latest PyPI version

Spotter is a simple command line tool for watching files and running shell commands when they change. Directives are read from a text file, and spotter will look for a file named .spotter in the current directory if no filenames are given.

Usage

spotter [-h] [-v] [-q] [-c] [filename [filename ...]]
Positional arguments:
  • filename: A list of files containing directives to load, defaulting to [".spotter"].

Optional arguments:
  • -h, --help: Explain the command line options.

  • -v, --version: Show the current version number.

  • -q, --quiet: The output of commands is not printed unless they fail.

  • -c, --continue: Failed commands will not stop spotter from continuing.

Spotter can also be run as a python module:

python -m spotter ...

Directives

All directives are in the following form:

<directive>: <argument> [-> <second argument>]

Not all directives take a second argument, but all of them take a first argument.

Watch

watch: <pattern> -> <command>

The Watch directive takes two arguments: <pattern> is a unix-style filename pattern, and <command> is a shell command to run when a file matching the pattern is created or changed. More information on the pattern matching used can be found in the fnmatch library documentation.

watch: *.txt -> echo "Text file changed"

Multiple watch directives can be given, and spotter will continue to run matching watch directives until one fails (i.e. returns an exit code above 0) or until it runs a matching watch-final directive.

watch: * -> return 1
watch: * -> echo "This command will not run"

The --continue command line argument can be used to disable this behaviour, forcing spotter to continue processing watches even if one fails.

Watch-Final

watch-final: <pattern> -> <command>

Watch-final has exactly the same syntax and behaviour as the Watch directive. Unlike the Watch directive, if the pattern matches and the command is run, no further watches will be processed.

watch-final: *.txt -> echo "No commands will run after this"

Start / Stop

start: <command>
stop: <command>

The start and stop directives can be used to run commands when spotter starts running and when spotter stops running.

start: echo "Started watching files"
stop: echo "Stopped watching files"

Define

define: <name> -> <value>

The Define directive allows values to be stored and then included in other directives when they are run. filename is always available in watch commands, and contains the path of the file that matched the pattern. Definitions are included in the commands using python format specifications, and are inserted when the command is run, not when the command is loaded.

define: python_command -> python2.6

watch: *.py -> {python_command} "{filename}"

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

spotter-1.7.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

spotter-1.7.1-py2.py3-none-any.whl (8.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file spotter-1.7.1.tar.gz.

File metadata

  • Download URL: spotter-1.7.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spotter-1.7.1.tar.gz
Algorithm Hash digest
SHA256 f77f90af3c586c3382718a5128f2b6b61c7f8c1b1c8879d42fb1b43b2e900c0c
MD5 36043a19a89a87e2c369a2daad6d50f0
BLAKE2b-256 763209b4197063725ab1312f811b63d2efe3fa5f51a3efb13f6c2fab5aa7baf4

See more details on using hashes here.

File details

Details for the file spotter-1.7.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for spotter-1.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 be0971d2a0612fe6ac64528f64095ad820ba71762448345a229a60b3cc78daf5
MD5 bcd5c88b3bd9303b3122b9e641771cd3
BLAKE2b-256 70135d234d285896287daf4e378d4ccb29ed730a0142019919a4f5b562f588f7

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