1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

🔧 Extra CLI mode (--cli)

This commit is contained in:
2023-01-30 13:07:37 +01:00
parent ad179a325a
commit 9fb5f33770
4 changed files with 41 additions and 1 deletions

View File

@ -89,6 +89,10 @@
argument = "--v"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--cli"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--configuration:~/.phpmon_fconf_working.json"
isEnabled = "NO">

View File

@ -16,7 +16,8 @@ class Log {
case error = 1,
warning = 2,
info = 3,
performance = 4
performance = 4,
cli = 5
public func isApplicable() -> Bool {
return Log.shared.verbosity.rawValue >= self.rawValue

View File

@ -68,6 +68,7 @@ class RealShell: ShellProtocol {
let task = Process()
task.launchPath = self.launchPath
task.arguments = ["--noprofile", "-norc", "--login", "-c", completeCommand]
return task
}
@ -113,6 +114,35 @@ class RealShell: ShellProtocol {
encoding: .utf8
)!
if Log.shared.verbosity == .cli {
var args = task.arguments
let last: String = "\"" + (args?.popLast() ?? "") + "\""
let concat = [self.launchPath] + task.arguments! + [last]
let command = concat.joined(separator: " ")
var log = """
<~~~~~~~~~~~~~~~~~~~~~~~
$ \(command)
[OUT]:
\(stdOut)
"""
if !stdErr.isEmpty {
log.append("""
[ERR]:
\(stdErr)
""")
}
log.append("""
~~~~~~~~~~~~~~~~~~~~~~~~>
""")
print(log)
}
return .out(stdOut, stdErr)
}

View File

@ -70,6 +70,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
Log.info("Extra verbose mode has been activated.")
}
if CommandLine.arguments.contains("--cli") {
logger.verbosity = .cli
Log.info("Extra CLI mode has been activated.")
}
Log.separator(as: .info)
Log.info("PHP MONITOR by Nico Verbruggen")
Log.info("Version \(App.version)")