Answer --help so agents can open files in Omawrite - #35
Open
jankeesvw wants to merge 1 commit into
Open
Conversation
Ask a coding agent to open a Markdown file in Omawrite and the first thing it runs is `omawrite --help`, to work out how. Today that opens a window that says "Could not open --help.", prints nothing to the terminal, and keeps running until the window is closed. So the agent hangs on a process that never exits, and never learns that Omawrite takes a file. Parse the arguments before QApplication starts, so the usage prints even without a desktop session to open a window in, and reject unknown options instead of treating them as file names. The usage also says the process stays up until the window is closed, which is the other half of what a script needs to know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ask a coding agent to open a Markdown file in Omawrite and the first thing it does is check how the command works. That check never comes back.
What an agent does
Four agents, same instruction ("open
<file>in Omawrite"), no other guidance. Three of the four reached for--helpbefore anything else. Taken fromps, not from what they reported:None of them got an answer:
So they went looking elsewhere. Between them, before any of them opened the file, they ran:
They all got there in the end, 15 to 67 seconds later, by guessing that a bare file argument would work. Each
--helpalso put a window on screen showingCould not open --help.in the footer.Why
main.cpppassesargv[1]straight toBackend::open()as a file name, so--helpis read as a file that cannot exist. Nothing reaches the terminal, and the process stays up until the window is closed.Built from
master(8f98892) on Arch with Qt 6.11.2, run withQT_QPA_PLATFORM=offscreen:After
Same machine, same Qt, this branch:
omawrite FILEis unchanged: it opens the window and stays up as before.What changed
Arguments are parsed in a small
src/cli.cppbeforeQApplicationis constructed, so the usage prints even without a desktop session to open a window in. Anything starting with a dash that isn't-h/--helpgets an error plus the usage on stderr and exit 1, instead of being treated as a file name.There's a test in
tests/tst_omawrite.cpp;bin/testpasses 13/13.I left
--versionout because there is no version constant in the source yet. Happy to add one if you want it.