CLI Reference

The application provides two sets of CLI commands:

  • Flask commands (flask <command>) — manage the web application’s database and users.

  • Urn commands (urn <command>) — interact directly with the randomization engine for scripting and batch operations.

Flask Commands

These commands manage the web application. Run them from the project root with flask <command>.

flask createdb

Initializes flask app DB with available studies & creates user tables

Usage

flask createdb [OPTIONS]

flask add_user

Adds a user

Usage

flask add_user [OPTIONS] UNAME EMAIL

Arguments

UNAME

Required argument

EMAIL

Required argument

flask list_users

Lists available users

Usage

flask list_users [OPTIONS]

flask delete_user

Deletes user linked to email

Usage

flask delete_user [OPTIONS] EMAIL

Arguments

EMAIL

Required argument

Urn Commands

These commands interact directly with the randomization engine. They are useful for scripting, batch operations, and data management.

urn

Perform urn randomization as described by Wei (1978)

Usage

urn [OPTIONS] COMMAND [ARGS]...

Options

-s, --study-name <study_name>

Required Name of study

dummy-study

Populate a study with dummy data

Usage

urn dummy-study [OPTIONS]

Options

--n_participants <n_participants>

Required Study size

--seed <seed>

Required Seed

export

Export study history to OUTFILE

Usage

urn export [OPTIONS] OUTFILE

Arguments

OUTFILE

Required argument

randomize

Randomize new participant

Usage

urn randomize [OPTIONS]

Options

--id <id>

Participant ID

-u, --user <user>

Username

upload-participants

Export study history to OUTFILE

Usage

urn upload-participants [OPTIONS] INFILE

Arguments

INFILE

Required argument

Examples

Set up a new study from scratch:

# Initialize the database
flask createdb

# Add users
flask add_user alice alice@hospital.org
flask add_user bob bob@hospital.org

# Randomize from the command line
urn -s "My Study" randomize --id P001 --user alice

# Export all participant data
urn -s "My Study" export participants.csv

# Seed a study with dummy data for testing
urn -s "My Study" dummy_study --n_participants 50 --seed 42