Skip to content

Commit

Permalink
Add subcommands dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jan 19, 2022
1 parent 63db854 commit b50c0ca
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions superset/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import importlib
import logging
import pkgutil
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 import app, appbuilder, cli, security_manager
from superset.cli.lib import normalize_token
from superset.extensions import db

logger = logging.getLogger(__name__)
Expand All @@ -43,25 +44,13 @@ def make_shell_context() -> Dict[str, Any]:


# add sub-commands
superset.add_command(celery.flower)
superset.add_command(celery.worker)
superset.add_command(examples.load_examples)
superset.add_command(importexport.export_dashboards)
if not feature_flags.get("VERSIONED_EXPORT"):
superset.add_command(importexport.export_datasource_schema)
superset.add_command(importexport.export_datasources)
superset.add_command(importexport.import_dashboards)
superset.add_command(importexport.import_datasources)
superset.add_command(importexport.import_directory)
superset.add_command(test.alert)
superset.add_command(test.load_test_users)
superset.add_command(thumbnails.compute_thumbnails)
superset.add_command(update.re_encrypt_secrets)
superset.add_command(update.refresh_druid)
superset.add_command(update.set_database_uri)
superset.add_command(update.sync_tags)
superset.add_command(update.update_api_docs)
superset.add_command(update.update_datasources_cache)
for load, module_name, is_pkg in pkgutil.walk_packages(
cli.__path__, cli.__name__ + "." # type: ignore
):
module = importlib.import_module(module_name)
for attribute in module.__dict__.values():
if isinstance(attribute, click.core.Command):
superset.add_command(attribute)


@superset.command()
Expand Down

0 comments on commit b50c0ca

Please sign in to comment.