Skip to content

Commit 5247dcd

Browse files
committed
update docs
1 parent c484473 commit 5247dcd

File tree

2 files changed

+351
-51
lines changed

2 files changed

+351
-51
lines changed

docs/tutorials/cli_usage.md

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
# Command-Line Interface (CLI)
1+
## Overview
22

3-
`psyflow` includes a command-line interface (CLI) to streamline your project setup. The CLI helps you create a new task with a standardized and recommended project structure, so you can get to the science faster.
3+
`psyflow-init` is the command-line interface (CLI) entrypoint for scaffolding new PsychoPy experiments using the built‑in template. It uses Cookiecutter under the hood to generate a standardized project layout, so you can focus on your task logic rather than boilerplate.
44

5-
## Creating a New Project with `psyflow-init`
5+
Key benefits:
66

7-
The primary command is `psyflow-init`, which scaffolds a new project directory for you.
7+
- **Standardization**: Enforce a consistent folder structure across all experiments
8+
- **Rapid setup**: Create a full project scaffold with one command
9+
- **Flexible modes**: Support both new-directory and in-place initialization
810

9-
### Basic Usage
11+
## Quick Reference
1012

11-
To create a new project, open your terminal, navigate to the directory where you want to create your project, and run:
13+
| Command | Purpose | Example |
14+
| ---------------------------- | ----------------------------------------------- | ----------------------------- |
15+
| `psyflow-init <name>` | Create a new folder `<name>` with project files | `psyflow-init my-new-task` |
16+
| `psyflow-init` (no argument) | Initialize current directory in-place | `cd existing && psyflow-init` |
17+
18+
## 1. Creating a New Project
19+
20+
To start from scratch, navigate to the parent directory and run:
1221

1322
```bash
1423
psyflow-init my-new-task
1524
```
1625

17-
This command will create a new folder named `my-new-task` inside your current directory. This new folder contains all the necessary files and subdirectories to start your experiment.
18-
19-
### Project Structure
20-
21-
After running the command, you will see the following structure:
26+
This will create a new folder `my-new-task/` containing all the necessary files and subdirectories:
2227

2328
```
2429
my-new-task/
2530
├── main.py
26-
├── meta.json
2731
├── README.md
2832
├── assets/
2933
├── config/
@@ -35,16 +39,34 @@ my-new-task/
3539
└── utils.py
3640
```
3741

38-
This structure helps organize your code, configuration, and data from the very beginning.
42+
## 2. In‑Place Initialization
3943

40-
### In-Place Initialization
41-
42-
Sometimes, you might have already created a directory for your project and want to initialize it with the `psyflow` structure. You can do this by running `psyflow-init` without any arguments inside that directory:
44+
If you already have (or have just created) an empty directory and wish to populate it with the `psyflow` scaffold, run the command without any arguments:
4345

4446
```bash
45-
mkdir my-existing-folder
46-
cd my-existing-folder
47+
mkdir my-existing-project
48+
cd my-existing-project
4749
psyflow-init
4850
```
4951

50-
This will populate the `my-existing-folder` with the same project structure without creating a new subdirectory. This is useful for integrating `psyflow` into an existing project structure.
52+
Before copying template files, the CLI checks for existing files or folders with the same names. If any conflicts are found, you will be prompted:
53+
54+
```
55+
⚠ Existing file 'main.py' detected. Overwrite? [y/N]:
56+
```
57+
58+
- Enter `y` to proceed and replace the file.
59+
- Enter `n` (or press Enter) to skip that file and continue with others.
60+
61+
This interactive confirmation prevents unintentional data loss during in-place initialization.
62+
63+
## 3. How It Works Internally
64+
65+
1. **Locate template**: Uses `importlib.resources` to find the `psyflow.templates` package and the `cookiecutter-psyflow` folder.
66+
2. **Cookiecutter render**:
67+
- **New‑directory mode**: Directly runs Cookiecutter into `./<project_name>`.
68+
- **In‑place mode**: Renders into a temporary directory, then copies files into the current folder.
69+
3. **Cleanup**: In-place mode deletes the temporary render directory when finished.
70+
71+
> *Tip*: All rendering is done with `no_input=True` so the command never pauses for prompts.
72+

0 commit comments

Comments
 (0)