diff --git a/docs/usage/customization.rst b/docs/usage/customization.rst --- a/docs/usage/customization.rst +++ b/docs/usage/customization.rst @@ -55,7 +55,7 @@ overwrite an entire function, change a g To generate a skeleton extensions package, run:: - gearbox make-rcext -c my.ini + kallithea-cli extensions-create -c my.ini This will create an ``rcextensions`` package next to the specified ``ini`` file. See the ``__init__.py`` file inside the generated ``rcextensions`` package diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py --- a/kallithea/bin/kallithea_cli.py +++ b/kallithea/bin/kallithea_cli.py @@ -18,6 +18,7 @@ from kallithea.bin.kallithea_cli_base im # import commands (they will add themselves to the 'cli' object) import kallithea.bin.kallithea_cli_config import kallithea.bin.kallithea_cli_db +import kallithea.bin.kallithea_cli_extensions import kallithea.bin.kallithea_cli_iis import kallithea.bin.kallithea_cli_ishell import kallithea.bin.kallithea_cli_repo diff --git a/kallithea/lib/paster_commands/make_rcextensions.py b/kallithea/bin/kallithea_cli_extensions.py rename from kallithea/lib/paster_commands/make_rcextensions.py rename to kallithea/bin/kallithea_cli_extensions.py --- a/kallithea/lib/paster_commands/make_rcextensions.py +++ b/kallithea/bin/kallithea_cli_extensions.py @@ -12,52 +12,45 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ -kallithea.lib.paster_commands.make_rcextensions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -make-rcext gearbox command for Kallithea - -This file was forked by the Kallithea project in July 2014. +This file was forked by the Kallithea project in July 2014 and later moved. Original author and date, and relevant copyright and licensing information is below: :created_on: Mar 6, 2012 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details. """ - +import click +import kallithea.bin.kallithea_cli_base as cli_base import os import pkg_resources -from kallithea.lib.paster_commands.common import ask_ok, BasePasterCommand - +import kallithea +from kallithea.lib.paster_commands.common import ask_ok -class Command(BasePasterCommand): - """Kallithea: Write template file for extending Kallithea in Python +@cli_base.register_command(config_file=True) +def extensions_create(): + """Write template file for extending Kallithea in Python. - A rcextensions directory with a __init__.py file will be created next to + An rcextensions directory with a __init__.py file will be created next to the ini file. Local customizations in that file will survive upgrades. The file contains instructions on how it can be customized. """ - - requires_db_session = False + here = kallithea.CONFIG['here'] + content = pkg_resources.resource_string( + 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') + ) + ext_file = os.path.join(here, 'rcextensions', '__init__.py') + if os.path.exists(ext_file): + msg = ('Extension file %s already exists, do you want ' + 'to overwrite it ? [y/n] ') % ext_file + if not ask_ok(msg): + click.echo('Nothing done, exiting...') + return - def take_action(self, args): - here = self.config['here'] - content = pkg_resources.resource_string( - 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') - ) - ext_file = os.path.join(here, 'rcextensions', '__init__.py') - if os.path.exists(ext_file): - msg = ('Extension file %s already exists, do you want ' - 'to overwrite it ? [y/n]') % ext_file - if not ask_ok(msg): - print 'Nothing done, exiting...' - return - - dirname = os.path.dirname(ext_file) - if not os.path.isdir(dirname): - os.makedirs(dirname) - with open(ext_file, 'wb') as f: - f.write(content) - print 'Wrote new extensions file to %s' % ext_file + dirname = os.path.dirname(ext_file) + if not os.path.isdir(dirname): + os.makedirs(dirname) + with open(ext_file, 'wb') as f: + f.write(content) + click.echo('Wrote new extensions file to %s' % ext_file) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -161,7 +161,6 @@ setuptools.setup( [gearbox.commands] celeryd=kallithea.lib.paster_commands.celeryd:Command make-index=kallithea.lib.paster_commands.make_index:Command - make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command upgrade-db=kallithea.lib.dbmigrate:UpgradeDb """, )