Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to set custom directory when using custom.init #464

Merged
merged 3 commits into from
Mar 14, 2020

Conversation

jwoertink
Copy link
Member

Fixes #339

Right now we have a custom.init generator that I don't think is used much. It only does the same as the wizard, but all through the command line. Now we can start to allow for some really custom options like setting a custom directory!

This PR adds a new --dir DIR flag to set the directory of where to generate your application. All it really does is cd in to that custom directory, and then generate the app as normal from that directory. This may be helpful for people using docker, or automating a build on to a server.

lucky custom.init my-project --dir /home/me/projects

@@ -38,6 +38,7 @@ require "../spec_helper"
private def generate_heroku_app_name
app_name_base + "-" + Random::Secure.hex(4)
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the crystal formatter did this

@@ -9,7 +9,7 @@ end
describe "Initializing a new web project" do
it "creates a full web app successfully" do
puts "Web app: Running integration spec. This might take awhile...".colorize(:yellow)
should_run_successfully "crystal run src/lucky.cr -- init.custom test-project test-project"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no clue why we had this doubled on all these specs lol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

britney-spears-confused

@@ -13,14 +13,18 @@ class LuckyCli::CustomInit < LuckyCli::Init
private def generate_project(project_name)
api_only = false
authentication = true
project_directory = "."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just default it to the current directory you're in like it does now

)
Dir.cd(File.expand_path(project_directory))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expand_path allows us to pass things like "." or ~/Projects and have it expand properly. We just cd in to the directory we want the project, then run everything as normal.

Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Just one note on the example for custom.init

@@ -9,7 +9,7 @@ end
describe "Initializing a new web project" do
it "creates a full web app successfully" do
puts "Web app: Running integration spec. This might take awhile...".colorize(:yellow)
should_run_successfully "crystal run src/lucky.cr -- init.custom test-project test-project"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

britney-spears-confused

spec/integration/init_web_spec.cr Outdated Show resolved Hide resolved
src/custom_init.cr Outdated Show resolved Hide resolved
…o custom.init. Adding another example to the OptionParser output to make it clear that the arguments are optional
@jwoertink jwoertink merged commit 2e8c1ff into master Mar 14, 2020
@jwoertink jwoertink deleted the features/339 branch March 14, 2020 18:36
paulcsmith pushed a commit that referenced this pull request Apr 7, 2020
* ran formatter

* adding in custom directory support for custom.init generator. Fixes #339

* a few more spec updates to remove duplicate options being passed in to custom.init. Adding another example to the OptionParser output to make it clear that the arguments are optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Allow to specify output directory for init via command line option
2 participants