summaryrefslogtreecommitdiffstats
path: root/scripts/nikola
blob: 4b895d20314dfe3e763e1d789dd501e74045e970 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python

"""Nikola main script."""

import os
import shutil
import sys

import nikola

USAGE = """To create a new site in a folder, run "nikola init foldername [src]".

The destination folder must not exist.

If you pass the src argument, that folder will be used as a template for
the new site instead of Nikola's sample site.
"""


def init(dst):
    """Create a copy of demosite in the current folder."""
    if len(sys.argv) > 3:
        src = sys.argv[3]
    else:
        src = os.path.join(os.path.dirname(nikola.__file__),'data','samplesite')
    shutil.copytree(src, dst)
    print "A new site with some sample data has been created at %s." % dst
    print "See README.txt in that folder for more information."

if __name__ == "__main__":
    if len(sys.argv)>=3 and sys.argv[1] == "init":
        print "Doing init"
        init(sys.argv[2])
    else:
        print USAGE