Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SDK
KDE Development Scripts
Commits
0f1fe6e9
Commit
0f1fe6e9
authored
Jul 18, 2014
by
Laurent Montel
😁
Browse files
Fix script
parent
568e2461
Changes
1
Hide whitespace changes
Inline
Side-by-side
kf5/convert-kcmdlineargs.pl
View file @
0f1fe6e9
...
...
@@ -23,11 +23,11 @@ foreach my $file (@ARGV) {
functionUtilkde::
substInFile
{
if
(
/KCmdLineOptions (\w*)/
)
{
$opt
=
$
1
;
s/KCmdLineOptions /QCommandLineParser
\*
/
;
s/$opt/parser
= new QCommandLineParser
/
;
s/KCmdLineOptions /QCommandLineParser /
;
s/$opt/parser/
;
$_
.=
"
app.setApplicationVersion(INSERT_VERSION_HERE);
\n
";
$_
.=
"
parser
->
addVersionOption();
\n
";
$_
.=
"
parser
->
addHelpOption(
INSERT_DESCRIPTION_HERE
);
\n
";
$_
.=
"
parser
.
addVersionOption();
\n
";
$_
.=
"
parser
.
addHelpOption();
\n
";
}
elsif
(
defined
$opt
&&
/KCmdLineArgs::addCmdLineOptions\s*\(\s*$opt\s*\)/
||
/KCmdLineArgs::init/
)
{
$_
=
"";
}
elsif
(
defined
$opt
&&
/(.*)$opt.add\s*\(\s*"([^\"]*)"\s*\)/
)
{
# short option
...
...
@@ -50,7 +50,7 @@ foreach my $file (@ARGV) {
$negatedOptions
{
$name
}
=
1
;
}
my
$translate
=
defined
$use_tr
?
"
QCoreApplication::translate(
$context
,
$description
)
"
:
"
$i18n
(
$description
)
";
$_
=
"
${prefix}
parser
->
addOption(QCommandLineOption(QStringList() <<
$short
\"
$name
\"
,
$translate$trail
));
\n
";
$_
=
"
${prefix}
parser
.
addOption(QCommandLineOption(QStringList() <<
QLatin1String(
$short
\"
$name
\"
)
,
$translate$trail
));
\n
";
$short
=
"";
}
elsif
(
/KCmdLineArgs\s*\*(\w*)\s*=\s*KCmdLineArgs::parsedArgs\(\s*\)/
)
{
$args
=
$
1
;
...
...
@@ -59,12 +59,12 @@ foreach my $file (@ARGV) {
s/KCmdLineArgs::qtArgc\(\)/argc/
;
s/KCmdLineArgs::qtArgv\(\)/argv/
;
if
(
defined
$args
)
{
s/${args}\->getOptionList/parser
->
arguments/
;
s/${args}\->getOption/parser
->
argument/
;
s/${args}\->isSet/parser
->
isSet/
;
s/${args}\->count/parser
->remaining
Arguments().count/
;
s/${args}\->usage\s*\(\)/parser
->
showHelp()/
;
s/KCmdLineArgs::usage\s*\(\)/parser
->
showHelp()/
;
s/${args}\->getOptionList/parser
.
arguments/
;
s/${args}\->getOption/parser
.
argument/
;
s/${args}\->isSet/parser
.
isSet/
;
s/${args}\->count/parser
.positional
Arguments().count/
;
s/${args}\->usage\s*\(\)/parser
.
showHelp()/
;
s/KCmdLineArgs::usage\s*\(\)/parser
.
showHelp()/
;
if
(
/arguments?\(\"(\w*)/
||
/isSet\(\"(\w*)/
)
{
my
$optionName
=
$
1
;
if
(
defined
$negatedOptions
{"
no
$optionName
"})
{
...
...
@@ -78,8 +78,10 @@ foreach my $file (@ARGV) {
}
$file
;
if
(`
grep QCommand
$file
| grep -v '#include'
`)
{
functionUtilkde::
removeIncludeInFile
(
$file
,
"
kcmdlineargs.h
");
functionUtilkde::
addIncludeInFile
(
$file
,
"
qcommandlineparser.h
");
functionUtilkde::
addIncludeInFile
(
$file
,
"
qcommandlineoption.h
");
functionUtilkde::
removeIncludeInFile
(
$file
,
"
KCmdLineArgs
");
functionUtilkde::
removeIncludeInFile
(
$file
,
"
KCmdLineOptions
");
functionUtilkde::
addIncludeInFile
(
$file
,
"
QCommandLineParser
");
functionUtilkde::
addIncludeInFile
(
$file
,
"
QCommandLineOption
");
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment