Commandline Args

Various commandline args exist to ease your life.

shopyo

Usage

shopyo [OPTIONS] COMMAND [ARGS]...

CLI management for shopyo cli. For Example, to run the app in production mode you can run

shopyo --config=production run

Options

--version

Show the flask version

--config <CONFIG NAME>

By default config is set to “development”. Other available configurations are “testing” and “production”. For commands startapp , collectstatic and new this options has no affect.

clean

Usage

shopyo clean [OPTIONS]

or

python manage.py clean [OPTIONS]

removes __pycache__, migrations/, shopyo.db files and drops db if present

Options

-v, --verbose

Show all hidden outputs in terminal

--help

Show the command usage/help message and exit

Initialise

Usage

shopyo initialise [OPTIONS]

or

python manage.py initialise [OPTIONS]

Creates db, migration/, adds default users, add settings. This command need to be run only once before running the project

Options

-v, --verbose

Show all hidden outputs in terminal

--help

Show the command usage/help message and exit

run

Usage

shopyo run [OPTIONS]

or

python manage.py run [OPTIONS]

Run a local development server.

This server is for development purposes only. It does not provide the stability, security, or performance of production WSGI servers.

The reloader and debugger are enabled by default if FLASK_ENV=development` or FLASK_DEBUG=1.

Note

This is wrapper around the flask run command

Options

-h, --host <host>

The interface to bind to.

-p, --port <port>

The port to bind to.

--cert <PATH>

Specify a certificate file to use HTTPS.

--key <FILE>

The key file to use when specifying a certificate.

--reload / --no-reload

Enable or disable the reloader. By default the reloader is active if debug is enabled.

--debugger / --no-debugger

Enable or disable the debugger. By default the debugger is active if debug is enabled.

--eager-loading / --lazy-loader

Enable or disable eager loading. By default eager loading is enabled if the reloader is disabled.

--with-threads / --without-threads

Enable or disable multithreading.

--extra-files PATH

Extra files that trigger a reload on change. Multiple paths are separated by ‘;’.

--help

Show the command usage/help message and exit

rundebug

Usage

shopyo rundebug [OPTIONS]

or

python manage.py rundebug [OPTIONS]

Run a local development server.

same as app.run(debug=True)

runserver

Usage

shopyo runserver [OPTIONS]

or

python manage.py runserver [OPTIONS]

Run a local development server.

same as app.run(debug=False)

startapp

Usage

shopyo startapp [OPTIONS] MODULENAME [BOXNAME]

or

python manage.py startapp [OPTIONS] MODULENAME [BOXNAME]

create a module/app MODULENAME inside modules/. If BOXNAME is provided, create the module inside modules/BOXNAME.

If box BOXNAME does not exist, it is created. If MODULENAME already exists, an error is thrown and command is terminated.

Running shopyo startapp demo will create the following:

modules/demo/
├── forms.py
├── global.py
├── info.json
├── models.py
├── static
├── templates
│   └── demo
│       ├── blocks
│       │   └── sidebar.html
│       └── dashboard.html
├── tests
│   ├── test_demo_functional.py
│   └── test_demo_models.py
└── view.py

Example usage with box:

# create module `dumpling` inside `box__plate`
shopyo startapp dumpling box__plate

startbox

Usage

shopyo startbox [OPTIONS] BOXNAME [BOXNAME]

or

shopyo startbox [OPTIONS] BOXNAME [BOXNAME]

Creates an empty box

shopyo startbox box__api

collectstatic

Usage

shopyo collectstatic [OPTIONS] [SRC]

or

python manage.py collectstatic [OPTIONS] [SRC]

Copies static/ in modules/ or modules/SRC into /static/modules/

modules/
└── box__default/
    ├── auth/
    │   └── static
    └── appadmin/
         └── static

For the modules structure shown above:

  • to collect static in only one module, run either of two commands:

$ shopyo collectstatic box__default/auth
$ shopyo collectstatic modules/box__default/auth
  • to collect static in all modules inside a box, run either of two commands below:

$ shopyo collectstatic box__default
$ shopyo collectstatic modules/box__default
  • to collect static in all modules run either of the two commands below:

$ shopyo collectstatic
$ shopyo collectstatic modules

Options

-v, --verbose

Show all hidden outputs in terminal

--help

Show the command usage/help message and exit

Arguments

SRC
Optional argument
the module path relative to modules/ where static/ exists.

new

Usage

shopyo new [OPTIONS] [PROJNAME]

Creates a new shopyo project.

By default it will create the project(folder) of same name as the parent folder. If PROJNAME is provided shopyo new somename, it will create PROJNAME/PROJNAME under parent folder

For Example, say your current working directory is /path/to/blog. Assuming you have created a virtual environment env and activated it, and installed shopyo. Apart from env folder, your cwd should be empty. Then after running:

shopyo new

the following blog project is created

blog
├── env
├── blog
│   ├── docs
│   ├── modules
│   │   └── ...
│   ├── __init__.py
│   ├── sphinx_source
│   │   └── ...
│   ├── static
│   │   └── ...
│   ├── tests
│   │   └── ...
│   ├── .test.prod.env
│   ├── __init__.py
│   ├── app.py
│   ├── cli.py
│   ├── config.py
│   ├── config_demo.json
│   ├── conftest.py
│   ├── init.py
│   ├── manage.py
│   └── wsgi.py
├── .gitignore
├── dev_requirements.txt
├── MANIFEST.in
├── pytest.ini
├── README.md
├── requirements.txt
├── setup.py
└── tox.ini

Some files are omitted above but the general structure is as shown above. Now you can initialise your project by running:

path/to/blog/blog$ shopyo initialise

and run the project as:

path/to/blog/blog$ shopyo run

You now have a complete Flask based blog application

Options

-v, --verbose

Show all hidden outputs in terminal

--help

Show the command usage/help message and exit

Arguments

PROJNAME
Optional argument
if provided, creates the new project folder PROJNAME/PROJNAME inside cwd

db

Usage

shopyo db [OPTIONS]

or

manage.py db [OPTIONS]

db migrate and db upgrate are used to migrate the db

Note

This is wrapper around the flask db of flask-migrate

routes

Usage

shopyo routes

or

manage.py routes

Shows all routes and methods

Note

This is wrapper around the flask routes command