在我的情况下,我需要回答一些没有 Y 或 N 而是文本或空白的问题。我发现在我的情况下最好的方法是创建一个 shellscript 文件。在我的例子中,我称之为 autocomplete.sh
我需要为学说模式导出器回答一些问题,所以我的文件看起来像这样。
-- 这只是一个例子 --
php vendor/bin/mysql-workbench-schema-export mysqlworkbenchfile.mwb ./doctrine << EOF
`#Export to Doctrine Annotation Format` 1
`#Would you like to change the setup configuration before exporting` y
`#Log to console` y
`#Log file` testing.log
`#Filename [%entity%.%extension%]`
`#Indentation [4]`
`#Use tabs [no]`
`#Eol delimeter (win, unix) [win]`
`#Backup existing file [yes]`
`#Add generator info as comment [yes]`
`#Skip plural name checking [no]`
`#Use logged storage [no]`
`#Sort tables and views [yes]`
`#Export only table categorized []`
`#Enhance many to many detection [yes]`
`#Skip many to many tables [yes]`
`#Bundle namespace []`
`#Entity namespace []`
`#Repository namespace []`
`#Use automatic repository [yes]`
`#Skip column with relation [no]`
`#Related var name format [%name%%related%]`
`#Nullable attribute (auto, always) [auto]`
`#Generated value strategy (auto, identity, sequence, table, none) [auto]`
`#Default cascade (persist, remove, detach, merge, all, refresh, ) [no]`
`#Use annotation prefix [ORM\]`
`#Skip getter and setter [no]`
`#Generate entity serialization [yes]`
`#Generate extendable entity [no]` y
`#Quote identifier strategy (auto, always, none) [auto]`
`#Extends class []`
`#Property typehint [no]`
EOF
我喜欢这个策略的一点是你可以评论你的答案是什么,并且使用 EOF 一个空行就是这样(默认答案)。事实证明,这个导出器工具有自己的 JSON 对应物来回答这些问题,但我在这样做之后发现了这一点 =)。
要运行脚本,只需在您想要的目录中并在终端中运行'sh autocomplete.sh'。
简而言之,通过使用 结合Return Lines,您可以根据需要回答提示的每个问题。 每一行都是一个新的答案。
我的示例只是展示了如何使用 cmets 完成此操作,同时使用 ` 字符,以便您记住每个步骤是什么。
请注意,此方法的另一个优点是您可以用 Y 或 N 来回答……事实上,您可以用空格来回答!
希望这对某人有所帮助。