如何撤消混合 phoenix.gen.html?
How do I undo mix phoenix.gen.html?
mix phoenix.gen.html
生成一堆文件。我该如何撤消这一代?还是我必须手工完成?
我相信 source code 或 mix help
命令中没有 'undo' 选项。但是,此混合命令 phoenix.gen.html
确实显示了生成的文件,如下所示:
$ mix phoenix.gen.html Tweet tweets tweet:string
* creating web/controllers/tweet_controller.ex
* creating web/templates/tweet/edit.html.eex
* creating web/templates/tweet/form.html.eex
* creating web/templates/tweet/index.html.eex
* creating web/templates/tweet/new.html.eex
* creating web/templates/tweet/show.html.eex
* creating web/views/tweet_view.ex
* creating test/controllers/tweet_controller_test.exs
* creating priv/repo/migrations/20160118194027_create_tweet.exs
* creating web/models/tweet.ex
* creating test/models/tweet_test.exs
由此您知道要删除哪些文件。
我认为代码生成工具能够撤消它所做的任何更改并不是一个特别好的主意;这太复杂且容易出错,为此目的(跟踪和管理更改)创建了版本控制系统。
因此,首先,我强烈建议使用版本控制系统,例如 git
。在使用 mix phx.gen.html
或任何其他方式生成代码之前,请确保您已将所有更改提交到版本控制系统。然后很容易通过从存储库恢复工作树状态来回滚所有更改(并且可能重试多次直到生成正确的东西)。即使生成了新文件,使用版本控制系统也可以让您看到哪些文件已添加到工作树中,因此您无需复制 mix phx.gen.html
的输出以供以后参考。版本控制系统还允许比较修改后的文件以了解所做的更改。
mix phoenix.gen.html
生成一堆文件。我该如何撤消这一代?还是我必须手工完成?
我相信 source code 或 mix help
命令中没有 'undo' 选项。但是,此混合命令 phoenix.gen.html
确实显示了生成的文件,如下所示:
$ mix phoenix.gen.html Tweet tweets tweet:string
* creating web/controllers/tweet_controller.ex
* creating web/templates/tweet/edit.html.eex
* creating web/templates/tweet/form.html.eex
* creating web/templates/tweet/index.html.eex
* creating web/templates/tweet/new.html.eex
* creating web/templates/tweet/show.html.eex
* creating web/views/tweet_view.ex
* creating test/controllers/tweet_controller_test.exs
* creating priv/repo/migrations/20160118194027_create_tweet.exs
* creating web/models/tweet.ex
* creating test/models/tweet_test.exs
由此您知道要删除哪些文件。
我认为代码生成工具能够撤消它所做的任何更改并不是一个特别好的主意;这太复杂且容易出错,为此目的(跟踪和管理更改)创建了版本控制系统。
因此,首先,我强烈建议使用版本控制系统,例如 git
。在使用 mix phx.gen.html
或任何其他方式生成代码之前,请确保您已将所有更改提交到版本控制系统。然后很容易通过从存储库恢复工作树状态来回滚所有更改(并且可能重试多次直到生成正确的东西)。即使生成了新文件,使用版本控制系统也可以让您看到哪些文件已添加到工作树中,因此您无需复制 mix phx.gen.html
的输出以供以后参考。版本控制系统还允许比较修改后的文件以了解所做的更改。