<table><tr><td style="">sitter created this revision.<br />Restricted Application added a project: Frameworks.<br />Restricted Application added a subscriber: Frameworks.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D7216" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>A notable advantage of qcommandlineoption is that using the objects the<br />
compiler makes sure that everyone is talking about the same option.<br />
Previously kpackagetool would create the option objects in main but then<br />
not use them to grab values out of the commandlineparser, instead relying<br />
on the stringy representation of the option. This is a tad harder to<br />
read but more importantly, it bypasses the compiler opening the code up for<br />
typos. Namely one could do <tt style="background: #ebebeb; font-size: 13px;">d->parser->value("hahs")</tt> while doing<br />
<tt style="background: #ebebeb; font-size: 13px;">d->parser->value(Options::hahs)</tt> will result in a build failure.</p>
<p>To preven this, refactor the entire option handling to use static option<br />
instances from a new Options namespace as to let the compiler help us not<br />
write typos.</p>
<p>In the future option handling could be additionally changed to parse all<br />
options at once early on and construct an option struct or something to<br />
reduce code clutter from calling isSet a million times.</p></div></div><br /><div><strong>TEST PLAN</strong><div><ul class="remarkup-list">
<li class="remarkup-list-item">all existing tests pass</li>
<li class="remarkup-list-item"><tt style="background: #ebebeb; font-size: 13px;">--help</tt> still looks correct</li>
</ul></div></div><br /><div><strong>REPOSITORY</strong><div><div>R290 KPackage</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D7216" rel="noreferrer">https://phabricator.kde.org/D7216</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/kpackagetool/kpackagetool.cpp<br />
src/kpackagetool/main.cpp<br />
src/kpackagetool/options.h</div></div></div><br /><div><strong>To: </strong>sitter, sebas, apol<br /><strong>Cc: </strong>Frameworks<br /></div>