Skip to content

Commit 49d438a

Browse files
feat: start command
1 parent 4bf53e5 commit 49d438a

3 files changed

Lines changed: 55 additions & 10 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616

1717
# Welcome to pythoncms
1818

19+
## Try
20+
21+
In virtual env
22+
23+
```
24+
pip install pythoncms==1.2.0
25+
pythoncms start mysite
26+
cd mysite
27+
shopyo initialise
28+
flask --debug run
29+
```
1930

2031
## Local dev
2132

@@ -106,3 +117,9 @@ unconfirmed.html
106117
}
107118
}
108119
```
120+
## Changelog
121+
122+
1.2.0
123+
124+
- Tiny MCE configured
125+
- start command

pythoncms/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (1, 1, 0)
1+
version_info = (1, 2, 0)
22
__version__ = ".".join([str(v) for v in version_info])

pythoncms/cli.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@
1313
- To get your project version, run ``pythoncms --version``
1414
- Run the sample command as ``pythoncms welcome [OPTIONS] NAME``
1515
"""
16+
from pathlib import Path
17+
1618
import click
19+
from shopyo.api.file import trycopytree
20+
from shopyo.api.file import trymkfile
21+
from shopyo.api.file import tryrmfile
22+
from shopyo.api.file import tryrmtree
1723

1824
from pythoncms import __version__
1925

26+
path = Path(__file__)
27+
import os
28+
2029

2130
@click.group()
2231
@click.version_option(__version__)
@@ -26,15 +35,34 @@ def cli(ctx):
2635
pass
2736

2837

29-
@cli.command("welcome")
30-
@click.argument("name")
31-
@click.option("--verbose", "-v", is_flag=True, default=False)
32-
def welcome(name, verbose):
33-
"""Sample command to welcome users.
38+
# @cli.command("welcome")
39+
# @click.argument("name")
40+
# @click.option("--verbose", "-v", is_flag=True, default=False)
41+
# def welcome(name, verbose):
42+
# """Sample command to welcome users.
43+
44+
# NAME will be printed along with the welcome message
45+
# """
46+
# click.secho(f"Hi {name}. Welcome to pythoncms", fg="cyan")
47+
48+
# if verbose:
49+
# click.echo("See you soon")
3450

35-
NAME will be printed along with the welcome message
51+
reqs = f"""pythoncms=={__version__}"""
52+
53+
54+
@cli.command("start")
55+
@click.argument("name")
56+
def start(name):
57+
"""
58+
New project
3659
"""
37-
click.secho(f"Hi {name}. Welcome to pythoncms", fg="cyan")
60+
dest = os.getcwd() + f"/{name}"
3861

39-
if verbose:
40-
click.echo("See you soon")
62+
trycopytree(str(path.parent.absolute()), dest)
63+
tryrmtree(dest + "/__pycache__")
64+
tryrmtree(dest + "/migrations")
65+
tryrmtree(dest + "/instance")
66+
tryrmfile(dest + "/config.json")
67+
trymkfile(dest + "/requirements.txt", reqs)
68+
click.echo(f"🍭 Pythoncms project {name} is ready to go!")

0 commit comments

Comments
 (0)