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

rebar3 shell improvements (escript, rebar.config shell defaults) #893

Merged
merged 1 commit into from
Nov 13, 2015

Conversation

archaelus
Copy link
Contributor

Runs a user-specified escript to initialize a system before starting the project Apps and the interactive shell. This allows for development-only frameworks and scaffolding to start before brining up the system for interactive use.

@@ -86,6 +89,7 @@ shell(State) ->
setup_name(State),
setup_paths(State),
setup_shell(),
maybe_run_script(State),
Copy link
Collaborator

Choose a reason for hiding this comment

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

A gotcha there is that apps booting is what loads the sys.config file if any is defined. Do you expect the script to run after or before that has been loaded?

If it needs to run after, then it must run after the apps have been loaded, but before they've been booted, and should be moved down inside maybe_boot_apps (or rather, maybe_boot_apps needs to be blown up in: maybe_load_apps, maybe_load_config, maybe_run_script and then maybe_boot_apps) -- but that depends on the intent of the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the script stuff should run before booting Apps - I'm intending that people use it to setup fake servers that they would connect to on boot anyway. It would be nice to get access to their OTP config, but that would require splitting load and start as you say. I'm going to try the easier thing for now.

@archaelus
Copy link
Contributor Author

OK, this thing seems to work (no tests, hahaha :/).

I also added the ability to pull defaults for rebar shell options from the rebar.config file. e.g.

{shell, [{script_file, FileName}, {config, ConfigFileName}]}.

@ferd
Copy link
Collaborator

ferd commented Nov 13, 2015

+1, waiting for squash as discussed off-channel

@archaelus
Copy link
Contributor Author

Incoming squash.

@archaelus archaelus changed the title WIP: Adds rebar3 shell --script=<FILE> rebar3 shell improvements (escript, rebar.config shell defaults) Nov 13, 2015
@ferd
Copy link
Collaborator

ferd commented Nov 13, 2015

+1.

Adds the ability to run an escript before starting the apps and
interactive shell for a project. This is intended to improve the
local development experience for projects by providing an easy way to
run companion services (mock rest APIs, databases etc) that the
project relies on.

This patch also adds {shell, Defaults} to the rebar config file so
that a project can supply default values for many of the new or
improved 'rebar3 shell' options:
* {apps, OTPApps}
* {script_file, EscriptFileName}
* {config, ConfigFileName}

The order of option precedence is command line, rebar.config, relx.
@archaelus
Copy link
Contributor Author

Fixed the dialyzer warning and associated bug.

ferd added a commit that referenced this pull request Nov 13, 2015
rebar3 shell improvements (escript, rebar.config shell defaults)
@ferd ferd merged commit 2d6dc1c into erlang:master Nov 13, 2015
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.

2 participants