Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Appmonitor CLI client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Appmonitor CLI client
Commits
d17c16fc
Commit
d17c16fc
authored
3 weeks ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
v0.9 add --explain; hardening using more intensive validation
parent
289758f6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/amcli.php
+56
-1
56 additions, 1 deletion
src/amcli.php
with
56 additions
and
1 deletion
src/amcli.php
+
56
−
1
View file @
d17c16fc
...
...
@@ -20,6 +20,7 @@
* 2025-03-14 v0.6 add meta tags, check count+visual; add _json2array()
* 2025-03-17 v0.7 update help
* 2025-03-17 v0.8 check missing 'function' in check. get php client version
* 2025-03-20 v0.9 add --explain; hardening using more intensive validation
* ======================================================================
*/
...
...
@@ -28,7 +29,7 @@ $argc = $_SERVER['argc'];
$argv
=
$_SERVER
[
'argv'
];
$FLAG_DEBUG
=
0
;
$VERSION
=
"0.
8
"
;
$VERSION
=
"0.
9
"
;
$PHPCLIENTVERSION
=
"not-detected"
;
$AMCLI_BUILD_DATE
=
"never"
;
...
...
@@ -145,6 +146,8 @@ You find example snippets in the source code of this project in tests/config/.
-v, --verbose Enable verbose output (written to STDERR)
-b, --buildinfos show build information and exit
-e, --explain <CHECK>
Explain a check and exit
-l, --list list available checks and exit
-m, --modules list available Php modules in this binary and exit
-V, --version Show version and exit
...
...
@@ -248,6 +251,49 @@ if (isset($ARGS['-h']) || isset($ARGS['--help'])) {
// ----------------------------------------------------------------------
// explain
if
(
isset
(
$ARGS
[
'-e'
])
||
isset
(
$ARGS
[
'--explain'
]))
{
$sCheckname
=
$inifile
=
$ARGS
[
"--explain"
]
??
(
$ARGS
[
"-e"
]
??
""
);
_wd
(
"Explain check '
$sCheckname
'"
);
$sCheckClass
=
"check
$sCheckname
"
;
if
(
!
class_exists
(
$sCheckClass
))
{
echo
"❌ ERROR: Check '
$sCheckname
' does not exist. Use -l to list existing checks.
\n
"
;
exit
(
8
);
}
$oPlugin
=
new
$sCheckClass
;
if
(
!
method_exists
(
$oPlugin
,
"explain"
)){
echo
"❌ ERROR: Check '
$sCheckname
' has no method explain (yet).
\n
"
;
exit
(
9
);
}
$a
=
$oPlugin
->
explain
();
// print_r($a);
echo
"
\e
[90m
; -----------------------------------------------------------------------------
;
;
$a[name]
;
$a[description]
;
\e
[0m
\e
[34m[<Your check name>]
\e
[0m
description=
\"
A short description what will be tested
\"
function=
\"
$sCheckname
\"
"
;
foreach
(
$a
[
'parameters'
]
as
$sKey
=>
$aInfos
){
echo
"
\n
"
;
echo
"
\e
[90m; key '
$sKey
' "
.
(
$aInfos
[
'type'
]
??
false
?
"{"
.
$aInfos
[
'type'
]
.
"}"
:
' (type not provided)'
)
.
" "
.
(
$aInfos
[
'required'
]
??
false
?
'🔸(required)'
:
'🔹(optional)'
)
.
"
\n
"
;
echo
";
$aInfos[description]
\n
"
;
echo
"; example: "
.
(
$aInfos
[
'example'
]
??
false
?
$aInfos
[
'example'
]
:
'(not provided)'
)
.
"
\n
"
;
echo
"; default: "
.
(
$aInfos
[
'default'
]
??
false
?
$aInfos
[
'default'
]
:
'(not provided)'
)
.
"
\e
[0m
\n
"
;
echo
"params[
$sKey
]=<Your value here>
\n
"
;
}
echo
"
\n\n
"
;
exit
(
0
);
}
// show builtin checks
if
(
isset
(
$ARGS
[
'-l'
])
||
isset
(
$ARGS
[
'--list'
]))
{
...
...
@@ -280,6 +326,15 @@ if (!file_exists($inifile)) {
try
{
$aIni
=
parse_ini_file
(
$inifile
,
true
);
array_walk_recursive
(
$aIni
,
function
(
&
$value
,
$key
)
{
if
(
is_numeric
(
$value
))
{
$value
=
(
string
)((
int
)
$value
)
===
$value
?
(
int
)
$value
:
(
double
)
$value
;
}
});
}
catch
(
Exception
$e
)
{
echo
"❌ ERROR: INI File '
$inifile
' could not be parsed.
\n
"
;
exit
(
5
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment