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
mahara
mahara
Commits
a87d409e
Commit
a87d409e
authored
Nov 24, 2014
by
Son Nguyen
Committed by
Gerrit Code Review
Nov 24, 2014
Browse files
Merge "Making sure options exist for _get_cli_params() (Bug 1394754)"
parents
5ee6bc05
0a547afc
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/cli.php
View file @
a87d409e
...
...
@@ -235,28 +235,30 @@ class cli {
// Remove the script name
unset
(
$options
[
0
]);
// Trim off anything after a -- with no arguments
if
((
$key
=
array_search
(
'--'
,
$options
))
!==
false
)
{
$options
=
array_slice
(
$options
,
0
,
$key
);
}
$this
->
arguments
=
array
();
$this
->
unmatched
=
array
();
foreach
(
$options
as
$argument
)
{
// Attempt to match arguments
preg_match
(
'/^(-(-)?)([^=]*)(=(.*))?$/'
,
$argument
,
$matches
);
if
(
count
(
$matches
)
&&
!
empty
(
$matches
[
3
]))
{
$argname
=
$matches
[
3
];
if
(
$matches
[
1
]
==
'-'
&&
isset
(
$this
->
shortoptions
[
$argname
]))
{
$argname
=
$this
->
shortoptions
[
$argname
];
}
$argdata
=
isset
(
$matches
[
5
])
?
$matches
[
5
]
:
true
;
$this
->
arguments
[
$argname
]
=
$argdata
;
if
(
!
empty
(
$options
))
{
// Trim off anything after a -- with no arguments
if
((
$key
=
array_search
(
'--'
,
$options
))
!==
false
)
{
$options
=
array_slice
(
$options
,
0
,
$key
);
}
else
{
// The argument didn't match a known setting so store it in
// case this was expected
$this
->
unmatched
[]
=
$argument
;
foreach
(
$options
as
$argument
)
{
// Attempt to match arguments
preg_match
(
'/^(-(-)?)([^=]*)(=(.*))?$/'
,
$argument
,
$matches
);
if
(
count
(
$matches
)
&&
!
empty
(
$matches
[
3
]))
{
$argname
=
$matches
[
3
];
if
(
$matches
[
1
]
==
'-'
&&
isset
(
$this
->
shortoptions
[
$argname
]))
{
$argname
=
$this
->
shortoptions
[
$argname
];
}
$argdata
=
isset
(
$matches
[
5
])
?
$matches
[
5
]
:
true
;
$this
->
arguments
[
$argname
]
=
$argdata
;
}
else
{
// The argument didn't match a known setting so store it in
// case this was expected
$this
->
unmatched
[]
=
$argument
;
}
}
}
...
...
Write
Preview
Supports
Markdown
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