mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
44 lines
980 B
Swift
44 lines
980 B
Swift
//
|
|
// main.swift
|
|
// phpmon-cli
|
|
//
|
|
// Created by Nico Verbruggen on 20/12/2021.
|
|
// Copyright © 2021 Nico Verbruggen. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// First, let's read the initial command line argument
|
|
|
|
// REFACTOR REQUIRED
|
|
// Information about the Homebrew linked alias
|
|
// Information about the PHP versions
|
|
// etc.: needs to be stored in a separate object we can instantiate here and in PHP Monitor.
|
|
|
|
print(CommandLine.arguments)
|
|
|
|
if CommandLine.arguments.count != 3 {
|
|
print("You must enter two arguments.")
|
|
exit(1)
|
|
}
|
|
|
|
let argument = CommandLine.arguments[1]
|
|
|
|
if !AllowedArguments.has(argument) {
|
|
print("The supported arguments are: \(AllowedArguments.rawValues)")
|
|
exit(1)
|
|
}
|
|
|
|
let action = AllowedArguments.init(rawValue: argument)
|
|
|
|
switch action {
|
|
case .use:
|
|
// Read the PHP value
|
|
let version = CommandLine.arguments[2]
|
|
print("Switching to PHP \(version)...")
|
|
break
|
|
case .none:
|
|
print("Action not recognized!")
|
|
exit(1)
|
|
}
|