Project bootstrapping
Closed this issue ยท 3 comments
Is your feature request related to a problem? Please describe.
The new settings infrastructure (#221) introduces a new workflow for configuring and serving apps which is explicit and straight-forward, but relatively high on boilerplate. There's also a risk that the whole thing ends up too complex by lack of standardization.
Describe the solution you'd like
The following shell command:
bocadillo create myproject
should create a new myproject
Python package in the current directory with the following contents:
__init__.py
settings.py
: settings module
from starlette.config import Config
config = Config(".env")
# Define settings here.
app.py
: application definition
from bocadillo import App
app = App()
# Define routes here.
asgi.py
: ASGI server entry point
from bocadillo import configure
from .app import app
from . import settings
configure(app, settings)
It should also create a .gitignore
and a README.md
if not present already in the current directory.
Users should also be able to define the directory where the project should be created using the -d / --directory
option, which defaults to the name of the project.
Describe alternatives you've considered
- Support
bocadillo create .
, ie create project in current directory: we need everything to be inside a package, otherwise relative imports wouldn't work, and it's too much work supporting both versions. Let's keep things simple. - Ask the user whether they want to setup tests (e.g. using pytest): attractive, that would be for another issue.
Implementation ideas
- Use Click to create the CLI. Expose it as an entry point in
setup.py
.
Additional context
/
Published bocadillo-cli as pre-alpha. Here's what the create
command looks like! (@cs01 I took inspiration from create-python-package
. ๐)
I think it's ready (one can already pip install bocadillo-cli
), but will only announce (and close this issue) once 0.14 goes out because the CLI generates >=0.14-compatible projects.
Awesome, love it! ๐ These types of things are so powerful because they remove uncertainty when developers are just getting started and therefore have the most uncertainty about the right way to do things. Plus, devs don't usually care; they just want to start writing an app, not a directory structure.
Thanks! ๐ I opened #256 for documentation changes related to this new feature.