You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/19 15:43:30 UTC

[GitHub] [superset] betodealmeida commented on a change in pull request #18082: chore: split CLI into multiple files

betodealmeida commented on a change in pull request #18082:
URL: https://github.com/apache/superset/pull/18082#discussion_r787882172



##########
File path: superset/cli/main.py
##########
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import logging
+from typing import Any, Dict
+
+import click
+from colorama import Fore, Style
+from flask.cli import FlaskGroup, with_appcontext
+
+from superset import app, appbuilder, security_manager
+from superset.cli import celery, examples, importexport, test, thumbnails, update
+from superset.cli.lib import feature_flags, normalize_token
+from superset.extensions import db
+
+logger = logging.getLogger(__name__)
+
+
+@click.group(
+    cls=FlaskGroup, context_settings={"token_normalize_func": normalize_token},
+)
+@with_appcontext
+def superset() -> None:
+    """This is a management script for the Superset application."""
+
+    @app.shell_context_processor
+    def make_shell_context() -> Dict[str, Any]:
+        return dict(app=app, db=db)
+
+
+# add sub-commands
+superset.add_command(celery.flower)

Review comment:
       At this point the file is still manageable, but I'm planning to add more commands in the next months (for syncing to/from DBT and other metric stores) and I'm worried it's going to get too big.
   
   I followed the pattern described in the docs (https://click.palletsprojects.com/en/6.x/quickstart/#nesting-commands). Not sure if there's a better way of doing this that doesn't require touching this file when adding a new command. :-/




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org