aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/command_init.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2013-03-13 20:58:39 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2013-03-13 20:58:39 -0300
commit8b14a1e5b2ca574fdd4fd2377567ec98a110d4b6 (patch)
tree0895935489e4920d18824f7fb3a0d799649a27c3 /nikola/plugins/command_init.py
parent878ba1152ebc64a4a2609d23c9e400a6111db642 (diff)
Imported Upstream version 5.4.2upstream/5.4.2
Diffstat (limited to 'nikola/plugins/command_init.py')
-rw-r--r--nikola/plugins/command_init.py44
1 files changed, 20 insertions, 24 deletions
diff --git a/nikola/plugins/command_init.py b/nikola/plugins/command_init.py
index e9bd001..bc36266 100644
--- a/nikola/plugins/command_init.py
+++ b/nikola/plugins/command_init.py
@@ -23,7 +23,6 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-from optparse import OptionParser, OptionGroup
import os
import shutil
import codecs
@@ -39,16 +38,23 @@ class CommandInit(Command):
name = "init"
- usage = """Usage: nikola init folder [options].
-
-That will create a sample site in the specified folder.
-The destination folder must not exist.
-"""
+ doc_usage = "[--demo] folder"
+ needs_config = False
+ doc_purpose = """Create a Nikola site in the specified folder."""
+ cmd_options = [
+ {
+ 'name': 'demo',
+ 'long': 'demo',
+ 'default': False,
+ 'type': bool,
+ 'help': "Create a site filled with example data.",
+ }
+ ]
SAMPLE_CONF = {
'BLOG_AUTHOR': "Your Name",
'BLOG_TITLE': "Demo Site",
- 'BLOG_URL': "http://nikola.ralsina.com.ar",
+ 'SITE_URL': "http://nikola.ralsina.com.ar",
'BLOG_EMAIL': "joe@demo.site",
'BLOG_DESCRIPTION': "This is a demo site for Nikola.",
'DEFAULT_LANG': "en",
@@ -67,7 +73,7 @@ The destination folder must not exist.
"wiki": ('.wiki',),
"ipynb": ('.ipynb',),
"html": ('.html', '.htm')
- }""",
+}""",
'REDIRECTIONS': '[]',
}
@@ -95,32 +101,22 @@ The destination folder must not exist.
def get_path_to_nikola_modules():
return os.path.dirname(nikola.__file__)
- def run(self, *args):
+ def _execute(self, options={}, args=None):
"""Create a new site."""
- parser = OptionParser(usage=self.usage)
- group = OptionGroup(parser, "Site Options")
- group.add_option(
- "--empty", action="store_true", dest='empty', default=True,
- help="Create an empty site with only a config.")
- group.add_option("--demo", action="store_false", dest='empty',
- help="Create a site filled with example data.")
- parser.add_option_group(group)
- (options, args) = parser.parse_args(list(args))
-
if not args:
print("Usage: nikola init folder [options]")
- return
+ return False
target = args[0]
if target is None:
print(self.usage)
else:
- if options.empty:
+ if not options or not options.get('demo'):
self.create_empty_site(target)
- print('Created empty site at %s.' % target)
+ print('Created empty site at {0}.'.format(target))
else:
self.copy_sample_site(target)
- print("A new site with example data has been created at %s."
- % target)
+ print("A new site with example data has been created at "
+ "{0}.".format(target))
print("See README.txt in that folder for more information.")
self.create_configuration(target)