Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running pcreate without scaffold, list scaffolds #1566

Merged
merged 7 commits into from
Feb 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Next release
Features
--------

- pcreate when run without a scaffold argument will now print information on
the missing flag, as well as a list of available scaffolds.
See https://github.com/Pylons/pyramid/pull/1566 and
https://github.com/Pylons/pyramid/issues/1297

- Added support / testing for 'pypy3' under Tox and Travis.
See https://github.com/Pylons/pyramid/pull/1469

Expand Down
12 changes: 10 additions & 2 deletions pyramid/scripts/pcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def main(argv=sys.argv, quiet=False):
class PCreateCommand(object):
verbosity = 1 # required
description = "Render Pyramid scaffolding to an output directory"
usage = "usage: %prog [options] output_directory"
usage = "usage: %prog [options] -s <scaffold> output_directory"
parser = optparse.OptionParser(usage, description=description)
parser.add_option('-s', '--scaffold',
dest='scaffold_name',
Expand Down Expand Up @@ -63,8 +63,16 @@ def __init__(self, argv, quiet=False):
def run(self):
if self.options.list:
return self.show_scaffolds()
if not self.options.scaffold_name and not self.args:
if not self.quiet: # pragma: no cover
self.parser.print_help()
self.out('')
self.show_scaffolds()
return 2
if not self.options.scaffold_name:
self.out('You must provide at least one scaffold name')
self.out('You must provide at least one scaffold name: -s <scaffold name>')
self.out('')
self.show_scaffolds()
return 2
if not self.args:
self.out('You must provide a project name')
Expand Down
11 changes: 8 additions & 3 deletions pyramid/tests/test_scripts/test_pcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def _getTargetClass(self):
from pyramid.scripts.pcreate import PCreateCommand
return PCreateCommand

def _makeOne(self, *args):
def _makeOne(self, *args, **kw):
effargs = ['pcreate']
effargs.extend(args)
cmd = self._getTargetClass()(effargs)
cmd = self._getTargetClass()(effargs, **kw)
cmd.out = self.out
return cmd

Expand All @@ -34,8 +34,13 @@ def test_run_show_scaffolds_none_exist(self):
out = self.out_.getvalue()
self.assertTrue(out.startswith('No scaffolds available'))

def test_run_no_scaffold_no_args(self):
cmd = self._makeOne(quiet=True)
result = cmd.run()
self.assertEqual(result, 2)

def test_run_no_scaffold_name(self):
cmd = self._makeOne()
cmd = self._makeOne('dummy')
result = cmd.run()
self.assertEqual(result, 2)
out = self.out_.getvalue()
Expand Down