Skip to content

Wire --version and --help flags to existing display functions#74

Merged
sanny32 merged 1 commit intosanny32:devfrom
jmrplens:fix/version-help-flags
Apr 10, 2026
Merged

Wire --version and --help flags to existing display functions#74
sanny32 merged 1 commit intosanny32:devfrom
jmrplens:fix/version-help-flags

Conversation

@jmrplens
Copy link
Copy Markdown
Contributor

@jmrplens jmrplens commented Apr 8, 2026

Summary

The showVersion() and showHelp() functions in main.cpp were already implemented but never called — the command-line options were not registered with QCommandLineParser, and the isSet() checks were missing.

Changes

  • cmdlineparser.h: Add _help and _version option name constants
  • cmdlineparser.cpp: Register --help and --version options with QCommandLineParser
  • main.cpp: Add isSet() checks to call showVersion()/showHelp() and exit before entering the GUI event loop
  • translations/*.ts: Updated by the build system with new translatable strings

Motivation

The sibling project OpenModSim already has this functionality working correctly (options registered, isSet() checks in place). This PR aligns OpenModScan's CLI behavior with OpenModSim.

Testing

Verified on Linux (Qt 6.8.2):

$ ./omodscan --version
1.14.1

$ ./omodscan --help
Usage: ./omodscan [options]
Open ModScan is a Modbus master (client) utility for modbus-tcp and modbus-rtu protocols.

Options:
  --help                       Displays help on commandline options.
  --version                    Displays version information.
  -p, --profile <profile.omf>  Open the specified profile.

@sanny32 sanny32 self-requested a review April 10, 2026 04:58
@sanny32 sanny32 changed the base branch from main to dev April 10, 2026 04:58
Copy link
Copy Markdown
Owner

@sanny32 sanny32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must resolve conflicts

The showVersion() and showHelp() functions in main.cpp were already
implemented but never called — the command-line options were not
registered with QCommandLineParser, and the isSet() checks were missing.

This commit:
- Registers --help and --version options in CmdLineParser (cmdlineparser.cpp)
- Adds corresponding option name constants (cmdlineparser.h)
- Adds isSet() checks in main() to call showVersion()/showHelp() and
  exit before entering the GUI event loop (main.cpp)
- Updates translation files with new translatable strings

This aligns OpenModScan's CLI behavior with the sibling project
OpenModSim, which already has this functionality working correctly.
@jmrplens jmrplens force-pushed the fix/version-help-flags branch from 4b36d91 to 2761699 Compare April 10, 2026 12:36
@jmrplens
Copy link
Copy Markdown
Contributor Author

Rebased onto dev — all conflicts resolved and ready to go 😉

@sanny32 sanny32 self-requested a review April 10, 2026 18:08
@sanny32 sanny32 merged commit 1eeb95c into sanny32:dev Apr 10, 2026
@jmrplens jmrplens deleted the fix/version-help-flags branch April 10, 2026 18:27
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.

2 participants