Skip to content

Commit

Permalink
Merge 557eb31 into c9b8858
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Jun 9, 2013
2 parents c9b8858 + 557eb31 commit 9a3c2d1
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 541 deletions.
26 changes: 21 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ Facio

Facio: /ˈfa.ki.oː/ - Latin, meaning to make, do, act, perform, cause, bring about.

|PyPi_version| |PyPi_downloads| |travis_master| |coveralls_master|
|PyPi_version| |PyPi_downloads|

Stable State
------------
|travis_master| |coveralls_master|

Development State
-----------------
|travis_develop| |coveralls_develop|

What is it?
-----------
Expand Down Expand Up @@ -32,10 +40,6 @@ Documentation for ``Facio`` can be found on `Read the Docs`_.

.. Images
.. |travis_master| image:: https://travis-ci.org/krak3n/Facio.png?branch=master
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Master Branch

.. |PyPi_version| image:: https://pypip.in/v/facio/badge.png
:target: https://crate.io/packages/facio/
:alt: Latest PyPI version
Expand All @@ -47,3 +51,15 @@ Documentation for ``Facio`` can be found on `Read the Docs`_.
.. |coveralls_master| image:: https://coveralls.io/repos/krak3n/Facio/badge.png?branch=master
:target: https://coveralls.io/r/krak3n/Facio?branch=master
:alt: Latest PyPI version

.. |travis_master| image:: https://travis-ci.org/krak3n/Facio.png?branch=master
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Master Branch

.. |coveralls_develop| image:: https://coveralls.io/repos/krak3n/Facio/badge.png?branch=develop
:target: https://coveralls.io/r/krak3n/Facio?branch=develop
:alt: Coder Coverage on Develop Branch

.. |travis_develop| image:: https://travis-ci.org/krak3n/Facio.png?branch=develop
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Develop Branch
26 changes: 21 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ Facio Documentation

Facio: /ˈfa.ki.oː/ - Latin, meaning to make, do, act, perform, cause, bring about.

|PyPi_version| |PyPi_downloads| |travis_master| |coveralls_master|
|PyPi_version| |PyPi_downloads|

Stable State
------------
|travis_master| |coveralls_master|

Development State
-----------------
|travis_develop| |coveralls_develop|

What is it?
-----------
Expand Down Expand Up @@ -75,10 +83,6 @@ Indices and tables

.. Images
.. |travis_master| image:: https://travis-ci.org/krak3n/Facio.png?branch=master
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Master Branch

.. |PyPi_version| image:: https://pypip.in/v/facio/badge.png
:target: https://crate.io/packages/facio/
:alt: Latest PyPI version
Expand All @@ -90,3 +94,15 @@ Indices and tables
.. |coveralls_master| image:: https://coveralls.io/repos/krak3n/Facio/badge.png?branch=master
:target: https://coveralls.io/r/krak3n/Facio?branch=master
:alt: Latest PyPI version

.. |travis_master| image:: https://travis-ci.org/krak3n/Facio.png?branch=master
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Master Branch

.. |coveralls_develop| image:: https://coveralls.io/repos/krak3n/Facio/badge.png?branch=develop
:target: https://coveralls.io/r/krak3n/Facio?branch=develop
:alt: Coder Coverage on Develop Branch

.. |travis_develop| image:: https://travis-ci.org/krak3n/Facio.png?branch=develop
:target: https://travis-ci.org/krak3n/Facio
:alt: Travis build status on Develop Branch
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def read(fname):
'clint2==0.3.2',
'sh==1.08',
'six==1.3.0',
'docopt==0.6.1'
]

test_requires = [
Expand Down
15 changes: 0 additions & 15 deletions src/facio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
__version__ = '1.1.1'




class Facio(object):

def __init__(self):
'''Constructor, fires all required methods.'''

from .config import Config
from .install import Install
from .template import Template
from .virtualenv import Virtualenv

from clint.textui import puts, indent
from clint.textui.colored import green
Expand All @@ -33,16 +29,5 @@ def __init__(self):
self.template = Template(self.config)
self.template.copy_template()

# Create python virtual environment
if self.config.venv_create:
self.venv = Virtualenv(self.config)

# Install the project to python path
if hasattr(self.config, 'install'):
if self.config.install:
self.install = Install(self.config,
self.template,
getattr(self, 'venv', None))

with indent(4, quote=' >'):
puts(green('Done'))
127 changes: 35 additions & 92 deletions src/facio/cli.py
Original file line number Diff line number Diff line change
@@ -1,107 +1,50 @@
"""
facio.cli
---------
# -*- coding: utf-8 -*-

Prompt user to enter options for Facio, determines how Facio behaves. Options
are split into 3 groups:
- Project Options
- Template Options
- Experimental Options
"""
.. module:: facio.cli
:synopsis: Facio command line entry point and configuration.
"""


import optparse
import re
import sys

from . import __version__

from docopt import docopt
from facio import __version__

class CLIOptions(object):

MANDATORY_OPTS = ['project_name', ]
class CLI(object):
"""
Facio.
def __init__(self):
self._parser = optparse.OptionParser(
usage='Usage: %prog -n <project_name> <options>',
version='%prog version {0}'.format(__version__),
description='Facio is a project scaffolding tool origionally '
'developed for Django and expanded to be framework '
'agnostic. You can use facio to bootstrap any sort '
'of project.',
epilog='Example: facio -n hello_world -c --vars foo=bar')
self._add_project_options()
self._add_template_options()
self._add_experimental_options()
self.opts, self.args = self._parser.parse_args()
self._validate()

def __getattr__(self, name):
opt = getattr(self.opts, name, None)
if not opt is None:
return opt
else:
raise AttributeError
Facio is a project scaffolding tool originally developed for Django and
expanded to be framework agnostic. You can use facio to bootstrap any sort
of project.
def _add_project_options(self):
group = optparse.OptionGroup(self._parser, 'Project Options')
group.add_option('-n', '--name', dest='project_name',
help='The Project Name (Mandatory), only use '
'alphanumeric chracters and underscores.',
type='string', metavar='<ARG>')
self._parser.add_option_group(group)
Usage:
facio <project_name> [--template <path>|--select] [--vars <variables>]
def _add_template_options(self):
group = optparse.OptionGroup(self._parser, 'Template Options')
group.add_option('-t', '--template', dest='template', action='store',
help='Path to your custom template, absolute paths '
'only , git repositories can also be specified by '
'prefixing with git+ for example: git+git@gitbub.com'
'/path/to/repo.git', type='string', metavar='<ARG1>')
group.add_option('-c', '--choose_template', dest='choose_template',
help='If you have more than 1 template defined use '
'this flag to override the default template, Note: '
'specifying -t (--template) will mean this '
'flag is ignored.', action='store_true',
default=False)
group.add_option('-s', '--template_settings_dir', action='store',
help='Template settings directory name',
type='string', metavar='<ARG>')
group.add_option('--vars', dest='variables', action='store',
default=False, help='Custom variables, e.g --vars '
'hello=world,sky=blue', metavar='<ARG>'),
self._parser.add_option_group(group)
Options:
-h --help Show this help text.
--version Show version.
-t --template <path> Template path, can be repository link
(git+ / hg+) or a template name defined in
~/.facio.cfg.
-s --select Lists templates in ~/.facio.cfg prompting you
to select a template from this list.
--vars <variables> Comma separated key=value pairs of values to be
used in processing templates.
def _add_experimental_options(self):
group = optparse.OptionGroup(self._parser, 'Experimental Options')
group.add_option('-i', '--install', action='store_true', default=False,
help='Install the project onto your path, e.g '
'python setup.py develop'),
group.add_option('-e', '--venv_create', dest='venv_create',
action='store_true', default=False,
help='Create python virtual environment'),
group.add_option('-p', '--venv_path', dest='venv_path', action='store',
help='Python virtualenv home directory',
type='string', metavar='<ARG>'),
group.add_option('-S', '--venv_use_site_packages',
dest='venv_use_site_packages', action='store_true',
default=False, help='Create python vittual '
'environment without --no-site-packages'),
group.add_option('-x', '--venv_prefix', dest='venv_prefix',
action='store',
help='Virtual environment name prefix',
type='string', metavar='<ARG>')
self._parser.add_option_group(group)
Example:
facio hello_world -t git+git@github.com:you/django.git --vars foo=bar
"""

def _validate(self):
self._validate_required()
def __init__(self):
self.arguments = docopt(
self.__doc__,
version='Facio {0}'.format(__version__))
self._validate_project_name()

def _validate_required(self):
for opt in self.MANDATORY_OPTS:
if not getattr(self.opts, opt, None):
self._parser.error('A mandatory option is missing, see --help')

def _validate_project_name(self):
if not re.match('^\w+$', self.opts.project_name):
self._parser.error('Project names can only contain numbers'
'letters and underscores')
if not re.match('^\w+$', self.arguments.get('<project_name>')):
sys.exit('Project names can only contain numbers letters and '
'underscores')

0 comments on commit 9a3c2d1

Please sign in to comment.