[PATCH 1 of 3 PoC] cli: initial introduction of 'kallithea' command
Thomas De Schampheleire
patrickdepinguin at gmail.com
Mon Sep 24 20:45:22 UTC 2018
# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1537819512 -7200
# Mon Sep 24 22:05:12 2018 +0200
# Node ID dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
# Parent a73e2822dd99eb5bdc551174d9d4f9c76f8f1667
cli: initial introduction of 'kallithea' command
This commit adds a command 'kallithea' that intends to replace the existing
set of 'gearbox' commands that relate to setting up kallithea. Gearbox
would still be used for 'gearbox serve', but other commands like
'make-config', 'setup-db', etc. would be converted to 'kallithea' commands.
The python package 'Click' is used to generate the CLI. Using decorators,
this package makes it very easy to generate a CLI out of simple methods.
See: http://click.pocoo.org/6/
Using Gearbox for custom commands is possible, but documentation on this
topic is limited. As the added value of Gearbox for that use case is not
clear, we can well switch to something else if it seems better/easier.
diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
new file mode 100644
--- /dev/null
+++ b/kallithea/bin/kallithea_cli.py
@@ -0,0 +1,20 @@
+# -*- 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/>.
+
+import click
+
+ at click.group()
+def cli():
+ """Various commands to set up a Kallithea instance."""
+ pass
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,6 +60,7 @@ requirements = [
"mercurial >= 4.1.1, < 4.8",
"decorator >= 3.3.2, < 4.4",
"Paste >= 2.0.3, < 3",
+ "Click >= 6.7, < 7",
]
if sys.version_info < (2, 7):
@@ -151,6 +152,7 @@ setuptools.setup(
kallithea-api = kallithea.bin.kallithea_api:main
kallithea-gist = kallithea.bin.kallithea_gist:main
kallithea-config = kallithea.bin.kallithea_config:main
+ kallithea = kallithea.bin.kallithea_cli:cli
[paste.app_factory]
main = kallithea.config.middleware:make_app
More information about the kallithea-general
mailing list