changeset 7415:f9c8fec48185

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.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sun, 18 Nov 2018 20:02:17 +0100
parents 3158cf0dafb7
children 502b9bd0a24d
files docs/usage/customization.rst kallithea/bin/kallithea_cli.py kallithea/bin/kallithea_cli_extensions.py kallithea/lib/paster_commands/make_rcextensions.py setup.py
diffstat 5 files changed, 58 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/docs/usage/customization.rst	Sun Nov 18 20:02:17 2018 +0100
+++ b/docs/usage/customization.rst	Sun Nov 18 20:02:17 2018 +0100
@@ -55,7 +55,7 @@
 
 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
--- a/kallithea/bin/kallithea_cli.py	Sun Nov 18 20:02:17 2018 +0100
+++ b/kallithea/bin/kallithea_cli.py	Sun Nov 18 20:02:17 2018 +0100
@@ -18,6 +18,7 @@
 # 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kallithea/bin/kallithea_cli_extensions.py	Sun Nov 18 20:02:17 2018 +0100
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+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
+
+import kallithea
+from kallithea.lib.paster_commands.common import ask_ok
+
+@cli_base.register_command(config_file=True)
+def extensions_create():
+    """Write template file for extending Kallithea in Python.
+
+    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.
+    """
+    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
+
+    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)
--- a/kallithea/lib/paster_commands/make_rcextensions.py	Sun Nov 18 20:02:17 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# 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.
-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 os
-import pkg_resources
-
-from kallithea.lib.paster_commands.common import ask_ok, BasePasterCommand
-
-
-class Command(BasePasterCommand):
-    """Kallithea: Write template file for extending Kallithea in Python
-
-    A 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
-
-    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
--- a/setup.py	Sun Nov 18 20:02:17 2018 +0100
+++ b/setup.py	Sun Nov 18 20:02:17 2018 +0100
@@ -161,7 +161,6 @@
     [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
     """,
 )