require 'sct/command_interface' require 'sct/command_option' module Sct class PhpCommand IS_PUBLIC_COMMAND = true SYNTAX = 'sct php' SUMMARY = 'Run php commands through SCT' EXAMPLE = 'sct php -r "echo \'Hello World!\';"' EXAMPLE_DESCRIPTION = 'sct php -r will execute a command directly through the php interpreter' DESCRIPTION = "sct will run php commands through the local docker installation" OPTIONS = [ CommandOption.new("-r", String, "Run php code directy through the interpreter"), CommandOption.new("-V", nil, "Get the current php version. Note that it's a capital V. The lowercase v will return the SCT tool version"), ] def execute(args, options) require "sct/docker/php" # Workaround for the version option being caught by the SCT tool itself args=ARGV[1..(ARGV.length+1)].map { |arg| arg == '-V' ? arg = '-v' : arg} # Another workaround for the -r option to add quotes around the value if args.include? '-r' codeIndex = args.index('-r') + 1 args[codeIndex] = "\"#{args[codeIndex]}\"" end Sct::Php.exec(args) end implements CommandInterface end end