Your requirement needs to be called Rails::Generator,想想看 rails generateIsn’t this how the command works?
In fact, there are many ready-made Gems that you can use as a reference. Most of them bundle install 完了之后还要运行命令,比如说 rake xxx:install 或者 rake xxx:generate will do this.
Recommend one to you: https://github.com/ryanb/nifty-generators, pay attention to the libgenerators below.
In addition, if you are not very urgent to open source, for example, you only need to do it on a small scale, you can do it without Gem. Just take a look at Creating and Customizing Rails Generators & Templates in Rails Guides. Of course, this is also the same for writing Gem. helpful.
Your requirement needs to be called
Rails::Generator
,想想看rails generate
Isn’t this how the command works?In fact, there are many ready-made Gems that you can use as a reference. Most of them
bundle install
完了之后还要运行命令,比如说rake xxx:install
或者rake xxx:generate
will do this.Recommend one to you: https://github.com/ryanb/nifty-generators, pay attention to the
In addition, if you are not very urgent to open source, for example, you only need to do it on a small scale, you can do it without Gem. Just take a look at Creating and Customizing Rails Generators & Templates in Rails Guides. Of course, this is also the same for writing Gem. helpful.lib
generators below.