##// END OF EJS Templates
cli: initial introduction of 'kallithea-cli' command...
Thomas De Schampheleire -
r7326:e4b9a1d1 default
parent child Browse files
Show More
@@ -0,0 +1,16 b''
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 # 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
16 from kallithea.bin.kallithea_cli_base import cli
@@ -0,0 +1,55 b''
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 import click
16 import functools
17 import os
18
19 import kallithea
20 import logging.config
21 import paste.deploy
22
23
24 # This placeholder is the main entry point for the kallithea-cli command
25 @click.group()
26 def cli():
27 """Various commands to manage a Kallithea instance."""
28
29 def register_command(config_file=False, config_file_initialize_app=False):
30 """Register a kallithea-cli subcommand.
31
32 If one of the config_file flags are true, a config file must be specified
33 with -c and it is read and logging is configured. The configuration is
34 available in the kallithea.CONFIG dict.
35
36 If config_file_initialize_app is true, Kallithea, TurboGears global state
37 (including tg.config), and database access will also be fully initialized.
38 """
39 cli_command = cli.command()
40 if config_file or config_file_initialize_app:
41 def annotator(annotated):
42 @click.option('--config_file', '-c', help="Path to .ini file with app configuration.",
43 type=click.Path(dir_okay=False, exists=True, readable=True), required=True)
44 @functools.wraps(annotated) # reuse meta data from the wrapped function so click can see other options
45 def runtime_wrapper(config_file, *args, **kwargs):
46 path_to_ini_file = os.path.realpath(config_file)
47 kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file)
48 logging.config.fileConfig(path_to_ini_file)
49 if config_file_initialize_app:
50 kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf)
51 kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG)
52 return annotated(*args, **kwargs)
53 return cli_command(runtime_wrapper)
54 return annotator
55 return cli_command
@@ -61,6 +61,7 b' requirements = ['
61 "decorator >= 3.3.2, < 4.4",
61 "decorator >= 3.3.2, < 4.4",
62 "Paste >= 2.0.3, < 3",
62 "Paste >= 2.0.3, < 3",
63 "bleach >= 3.0, < 3.1",
63 "bleach >= 3.0, < 3.1",
64 "Click >= 7.0, < 8",
64 ]
65 ]
65
66
66 if sys.version_info < (2, 7):
67 if sys.version_info < (2, 7):
@@ -152,6 +153,7 b' setuptools.setup('
152 kallithea-api = kallithea.bin.kallithea_api:main
153 kallithea-api = kallithea.bin.kallithea_api:main
153 kallithea-gist = kallithea.bin.kallithea_gist:main
154 kallithea-gist = kallithea.bin.kallithea_gist:main
154 kallithea-config = kallithea.bin.kallithea_config:main
155 kallithea-config = kallithea.bin.kallithea_config:main
156 kallithea-cli = kallithea.bin.kallithea_cli:cli
155
157
156 [paste.app_factory]
158 [paste.app_factory]
157 main = kallithea.config.middleware:make_app
159 main = kallithea.config.middleware:make_app
General Comments 0
You need to be logged in to leave comments. Login now