# HG changeset patch # User Thomas De Schampheleire <[email protected]> # Date 1539806363 -7200 # Wed Oct 17 21:59:23 2018 +0200 # Node ID 795afb2faf6aa22f54f18b8d61eff80e93304ae4 # Parent afaa88076a9e6fb9df4a676b0232f0a3c810fe3d cli: convert 'gearbox make-rcext' in 'kallithea-cli extensions-create'
Note: 'extensions' instead of 'rcextensions' as first step to get away from the 'rc' prefix. 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 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 @@ -20,6 +20,7 @@ import kallithea.bin.kallithea_cli_db import kallithea.bin.kallithea_cli_cache import kallithea.bin.kallithea_cli_celery import kallithea.bin.kallithea_cli_config +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,46 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ -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 +from kallithea.bin.kallithea_cli_base import cli +import kallithea.bin.kallithea_cli_util as cli_util import os import pkg_resources -from kallithea.lib.paster_commands.common import ask_ok, BasePasterCommand - +import kallithea -class Command(BasePasterCommand): - """Kallithea: Write template file for extending Kallithea in Python [email protected]() +@cli_util.auto_setup_app(config_only=True) +def extensions_create(config_file): + """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 cli_util.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 @@ -159,7 +159,6 @@ setuptools.setup( [gearbox.commands] make-index=kallithea.lib.paster_commands.make_index:Command - make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command upgrade-db=kallithea.lib.dbmigrate:UpgradeDb """, ) _______________________________________________ kallithea-general mailing list [email protected] https://lists.sfconservancy.org/mailman/listinfo/kallithea-general
