Intellij idea 在PhpStorm打开的情况下从命令行运行代码格式化程序
如果我转到PhpStorm\bin文件夹,我可以运行format.bat命令从命令行格式化文件,例如Intellij idea 在PhpStorm打开的情况下从命令行运行代码格式化程序,intellij-idea,phpstorm,Intellij Idea,Phpstorm,如果我转到PhpStorm\bin文件夹,我可以运行format.bat命令从命令行格式化文件,例如 phpstorm format -r C:\path\to\my\code -r -s c:\path\to\my\settings.xml 这很有效。但是,如果PhpStorm处于打开状态,我无法运行该命令,我会收到一个错误: 一次只能运行一个PhpStorm实例 必须关闭IDE才能运行第三方代码生成器并不理想。有什么解决办法吗?没有安装PhpStorm的另一个副本。这是一个已知的问题,请参
phpstorm format -r C:\path\to\my\code -r -s c:\path\to\my\settings.xml
这很有效。但是,如果PhpStorm处于打开状态,我无法运行该命令,我会收到一个错误:
一次只能运行一个PhpStorm实例
必须关闭IDE才能运行第三方代码生成器并不理想。有什么解决办法吗?没有安装PhpStorm的另一个副本。这是一个已知的问题,请参阅:来自y.bedrov的链接将我带到这里,并提供了一个潜在的解决方案 不幸的是,我似乎无法让它工作,我不得不求助于复制我的PhpStorm目录,并使用副本。但我把它加在这里是希望它能帮助其他人 在IDE运行时运行命令行格式化程序 在Linux/MacOS上
- 转到/bin目录,其中是安装Intellij IDEA或基于Intellij IDEA的产品的目录
- 将idea.properties复制到其他文件,例如format.properties
- 修改format.properties,如下所示:
@ECHO OFF
::----------------------------------------------------------------------
:: IntelliJ IDEA formatting script.
::----------------------------------------------------------------------
SET IDE_BIN_DIR=%~dp0
SET IDEA_PROPERTIES=%IDE_BIN_DIR%\format.properties
CALL "%IDE_BIN_DIR%\idea.bat" format %*
- #idea.config.path=${user.home}/.IntelliJIdea/config
- #idea.system.path=${user.home}/.IntelliJIdea/system
- idea.config.path=${user.home}/.IntelliJIdea/format/config
- idea.system.path=${user.home}/.IntelliJIdea/format/system
\#!/bin/sh
\# ------------------------------------------------------
\# IntelliJ IDEA formatting script.
\# ------------------------------------------------------
IDE_BIN_HOME="${0%/*}"
export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
exec "$IDE_BIN_HOME/idea.sh" format "$@"
在不关闭IDE的情况下运行format.sh,它应提供以下输出:
IntelliJ IDEA ..., build ... Formatter
Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
-h|-help Show a help message and exit.
-s|-settings A path to Intellij IDEA code style settings .xml file.
-r|-R Scan directories recursively.
-m|-mask A comma-separated list of file masks.
path.. A path to a file or a directory.
在窗户上
您必须为Linux/MacOS创建一个单独的format.properties文件,如上所述。
通过添加一行IDEA_PROPERTIES变量更改format.bat文件,如下所示:
@ECHO OFF
::----------------------------------------------------------------------
:: IntelliJ IDEA formatting script.
::----------------------------------------------------------------------
SET IDE_BIN_DIR=%~dp0
SET IDEA_PROPERTIES=%IDE_BIN_DIR%\format.properties
CALL "%IDE_BIN_DIR%\idea.bat" format %*
运行format.bat,它将列出命令行格式化程序选项