Skip to content

Commit d0d9db6

Browse files
docs for create + cleanup (#109)
1 parent cc7e545 commit d0d9db6

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,23 @@ To avoid opening a browser window, use `--silent` option.
8989
```shell
9090
$ pyscript run <path_of_folder> --silent
9191
```
92+
93+
### create
94+
95+
#### Create a new pyscript project with the passed in name, creating a new directory
96+
97+
```shell
98+
$ pyscript create <name_of_app>
99+
```
100+
101+
This will create a new directory named `name_of_app` under the current directory.
102+
103+
The interactive prompts will further ask for information such as `description of the app`,
104+
`name of the author`, `email of the author`, etc. These of course can be provided via
105+
options such as `--author-name` etc. Use `pyscript create --help` for more information.
106+
107+
The following files will be created:
108+
109+
- `index.html`: start page for the project
110+
- `pyscript.toml`: project metadata and config file
111+
- `main.py`: a "Hello world" python starter module

src/pyscript/_generator.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ def create_project(
121121
"""
122122
New files created:
123123
124-
pyscript.json - project metadata
125-
index.html - a "Hello world" start page for the project.
126-
127-
TODO: more files to add to the core project start state.
124+
pyscript.toml - project metadata and config file
125+
main.py - a "Hello world" python starter module
126+
index.html - start page for the project
128127
"""
129128
date_stamp = datetime.date.today()
130129
context = {
@@ -138,11 +137,8 @@ def create_project(
138137
app_dir = Path(".") / app_name
139138
app_dir.mkdir()
140139
manifest_file = app_dir / config["project_config_filename"]
141-
with manifest_file.open("w", encoding="utf-8") as fp:
142-
if str(manifest_file).endswith(".json"):
143-
json.dump(context, fp)
144-
else:
145-
toml.dump(context, fp)
140+
141+
save_config_file(manifest_file, context)
146142

147143
index_file = app_dir / "index.html"
148144
if project_type == "app":

src/pyscript/plugins/create.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ def create(
2727
"""
2828
Create a new pyscript project with the passed in name, creating a new
2929
directory in the current directory.
30-
Inspired by Sphinx guided setup.
31-
TODO: Agree on the metadata to be collected from the user.
3230
"""
3331
try:
3432
create_project(
35-
app_name, app_description, author_name, author_email, pyscript_version
33+
app_name,
34+
app_description,
35+
author_name,
36+
author_email,
37+
pyscript_version,
38+
project_type,
3639
)
3740
except FileExistsError:
3841
raise cli.Abort(

0 commit comments

Comments
 (0)