Skip to content

fix: make module print order configurable via DEFAULT_OPTIONS#26

Open
gandzekas wants to merge 1 commit into
brick-24:mainfrom
gandzekas:bugfix/cron-20260713-1
Open

fix: make module print order configurable via DEFAULT_OPTIONS#26
gandzekas wants to merge 1 commit into
brick-24:mainfrom
gandzekas:bugfix/cron-20260713-1

Conversation

@gandzekas

Copy link
Copy Markdown

Summary

Fixes issue #24: the order in which modules are printed was hardcoded in daily_arg.py. Now the print order is driven by config.DEFAULT_OPTIONS.

Changes

  • daily_arg.py: Refactored to use a central OPTION_HANDLERS mapping and dynamic execution order:
    • Added OPTION_HANDLERS (OrderedDict) mapping option names to (handler_fn, arg_getter, is_flag)
    • Added DEFAULT_ORDER = DEFAULT_OPTIONS + remaining handlers in declaration order
    • Added _is_option_enabled(args, opt) and _get_active_options(args) helpers
    • Simplified main() to iterate handlers in resolved order
    • When no explicit flags: enables DEFAULT_OPTIONS in configured order
    • When explicit flags provided: executes requested options in DEFAULT_ORDER priority
    • Improved argparse help strings for clarity

Behavior

  • Default (no flags): prints modules in DEFAULT_OPTIONS order (configurable in config.py)
  • Explicit flags (e.g. --markets --weather): prints only requested modules, ordered by DEFAULT_ORDER priority
  • Mixed flags (e.g. --xkcd --quote --stock AAPL): executes in DEFAULT_ORDER (quote → xkcd → stock)

Testing

  • python -m py_compile daily_arg.py config.py printer.py function/*.py — syntax OK
  • Manual logic verification with mocked dependencies:
    • Default run prints in DEFAULT_OPTIONS order (weather → markets → quote)
    • Explicit flags respect DEFAULT_ORDER priority
    • Options not in DEFAULT_OPTIONS (xkcd, text, image, stock, forecast) follow after

Related

Addresses issue brick-24#24: the order in which modules are printed was hardcoded
in daily_arg.py. Now the print order is driven by config.DEFAULT_OPTIONS.

- Added OPTION_HANDLERS mapping option names to (handler, arg_getter, is_flag)
- Added DEFAULT_ORDER = DEFAULT_OPTIONS + remaining handlers
- Refactored main() to execute handlers in DEFAULT_ORDER
- When no explicit flags provided, DEFAULT_OPTIONS are enabled in configured order
- When explicit flags provided, they execute in DEFAULT_ORDER priority
- Improved argparse help strings for clarity
- Added _is_option_enabled() and _get_active_options() helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: module print order is not dynamic

1 participant