Before submitting
Description
Summary
The CLI currently performs a COM availability check during startup, and on Windows this may instantiate xlwings.App() and effectively launch Excel.
Because this can happen even for lightweight commands such as exstruct --help, it significantly degrades perceived CLI responsiveness.
To improve startup UX, we should stop probing COM availability during parser construction and only evaluate it when a COM-dependent feature is actually used.
Problem
At the moment, COM availability is checked while building the argument parser. This creates several issues:
- Heavy initialization can run even for
--help or argument validation failures
- On Windows, startup may involve launching and quitting Excel
- Users experience the CLI as “slow before doing anything”
- Startup latency becomes more variable and less predictable
In particular, options such as --auto-page-breaks-dir do not need to be conditionally exposed based on a startup-time environment probe.
This is better handled as runtime validation.
Proposal
- Remove COM availability probing from
build_parser()
- Always expose
--auto-page-breaks-dir as a CLI option
- Validate COM availability only when that option is actually used and a COM-dependent execution path is reached
- If COM is unavailable, fail at execution time with a clear and explicit error message
Expected benefits
- Significantly faster startup for commands like
exstruct --help
- Cleaner separation between CLI bootstrap and execution-time capability checks
- Better first-response UX
- Fewer side effects during startup
Scope
Potential files:
src/exstruct/cli/main.py
src/exstruct/cli/availability.py
Acceptance criteria
exstruct --help does not trigger COM availability probing
- Parser construction does not launch Excel
--auto-page-breaks-dir is validated at execution time instead
- In COM-unavailable environments, the CLI returns a clear and actionable error message
Notes
README wording may also need to be updated from:
- “the option is shown only when supported”
to:
- “the option is always shown, but validated at runtime based on environment support”
Minimal example (optional)
No response
Additional notes (optional)
No response
Before submitting
Description
Summary
The CLI currently performs a COM availability check during startup, and on Windows this may instantiate
xlwings.App()and effectively launch Excel.Because this can happen even for lightweight commands such as
exstruct --help, it significantly degrades perceived CLI responsiveness.To improve startup UX, we should stop probing COM availability during parser construction and only evaluate it when a COM-dependent feature is actually used.
Problem
At the moment, COM availability is checked while building the argument parser. This creates several issues:
--helpor argument validation failuresIn particular, options such as
--auto-page-breaks-dirdo not need to be conditionally exposed based on a startup-time environment probe.This is better handled as runtime validation.
Proposal
build_parser()--auto-page-breaks-diras a CLI optionExpected benefits
exstruct --helpScope
Potential files:
src/exstruct/cli/main.pysrc/exstruct/cli/availability.pyAcceptance criteria
exstruct --helpdoes not trigger COM availability probing--auto-page-breaks-diris validated at execution time insteadNotes
README wording may also need to be updated from:
to:
Minimal example (optional)
No response
Additional notes (optional)
No response