class KubectlLexer(RegexLexer): """Provides highlighting for commands, subcommands, arguments, and options. """ completer = KubectlCompleter() tokens = { 'root': [ (words(tuple(['kubectl', 'clear', 'exit']), prefix=r'\b', suffix=r'\b'), Literal.String), # (words( # tuple(completer.all_commands), # prefix=r'\b', # suffix=r'\b'), # Name.Class), # (words( # tuple(completer.all_args), # prefix=r'\b', # suffix=r'\b'), # Name.Class), # (words( # tuple(completer.all_opts), # prefix=r'', # suffix=r'\b'), # Keyword), # (words( # tuple(completer.global_opts), # prefix=r'', # suffix=r'\b'), # Keyword), # Everything else (r'.*\n', Text), ] }
from kubeshell.style import StyleFactory from kubeshell.completer import KubectlCompleter from kubeshell.lexer import KubectlLexer from kubeshell.toolbar import Toolbar from kubeshell.client import KubernetesClient, kubeconfig_filepath import os import click import sys import subprocess import yaml import logging logger = logging.getLogger(__name__) inline_help = True completer = KubectlCompleter() client = KubernetesClient() class KubeConfig(object): clustername = user = "" namespace = "default" current_context_index = 0 current_context_name = "" @staticmethod def parse_kubeconfig(): if not os.path.exists(os.path.expanduser(kubeconfig_filepath)): return ("", "", "")