Skip to content

CLI: Allow watching custom include / exclude patterns [feature-request] #594

@nhairs

Description

@nhairs

First of all, great project :)

Currently the CLI reloader only allows specifying the base path path to watch for changes (--watch path/to/watch). However the watcher is configured so that it only listens to changes on *.py files (source code).

I would like to be able to use the reloader with changes to other files such as configuration files.

It might look like the following:

        # cli.py
        parser.add_argument(
            "-i",
            "--watch-include",
            action="append",
            dest="include_patterns",
            help="Additional patterns to watch for changes",
        )

        parser.add_argument(
            "-x",
            "--watch-exclude",
            action="append",
            dest="exclude_patterns",
            help="Patterns to ignore for changes",
        )

Which would then be used like:

dramatiq [...] --watch path/to/watch -i *.yml -i templates/*.html -x templates/*.png

Aside: in documentation / help strings it might be worth noting that prior to Python 3.13 these patterns only support multiple name (**) globbing at the start of the pattern (ref)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions