def SetUp(self): test_data_dir = self.Resource( 'tests', 'unit', 'calliope', 'testdata', 'sdk14') loader = cli.CLILoader( name='test', command_root_directory=test_data_dir) self.my_cli = loader.Generate()
def CreateCLI(surfaces): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') generated_cli = loader.Generate() return generated_cli
def CLILoader(name, command_root_directory, allow_non_existing_modules=False, version_func=None, help_dir=None): """Get a ready-to-go CLI for Cloud SDK tools. Args: name: str, The name of your CLI. Should probably be the same as the executable name. command_root_directory: str, The absolute path to the tools root. allow_non_existing_modules: bool, If true, module directories that don't exist will be ignored rather than cause errors. version_func: func, Function to call with -v, --version. help_dir: str, The path to the directory containing help documents or None if the CLI does not support man pages. Returns: calliope.CLILoader, An object that will run the tools from the command line. """ paths = config.Paths() return calliope.CLILoader( name=name, command_root_directory=command_root_directory, load_context=None, logs_dir=paths.logs_dir, allow_non_existing_modules=allow_non_existing_modules, version_func=version_func, help_func=GetHelp(help_dir), )
def SetUp(self): calliope_test_home = self.Resource('tests', 'unit', 'calliope', 'testdata') loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( calliope_test_home, 'sdk3')) self.generator = markdown.CommandMarkdownGenerator( loader.Generate()._TopElement())
def CreateCLI(surfaces, translator=None): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. translator: yaml_command_translator.Translator, an alternative translator. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) def HandleKnownErrorFunc(): crash_handling.ReportError(is_crash=False) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc, known_error_handler=HandleKnownErrorFunc, yaml_command_translator=(translator or yaml_command_translator.Translator()), ) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) # TODO(b/128465608): Remove cloned ml-engine commands and PreRunHook after a # suitable deprecation period. # Clone 'ai-platform' surface into 'ml-engine' for backward compatibility. loader.AddModule('ml_engine', os.path.join(pkg_root, 'surface', 'ai_platform')) loader.RegisterPreRunHook(_IssueAIPlatformAliasWarning, include_commands=r'gcloud\..*ml-engine\..*') # Clone 'container/hub' surface into 'container/fleet' # for backward compatibility. loader.AddModule('container.hub', os.path.join(pkg_root, 'surface', 'container', 'fleet')) # Check for updates on shutdown but not for any of the updater commands. # Skip update checks for 'gcloud version' command as it does that manually. exclude_commands = r'gcloud\.components\..*|gcloud\.version' loader.RegisterPostRunHook(UpdateCheck, exclude_commands=exclude_commands) loader.RegisterPostRunHook(SurveyPromptCheck) generated_cli = loader.Generate() return generated_cli
def CreateCLI(): """Generates the gcloud CLI.""" sdk_root = config.Paths().sdk_root if sdk_root: help_dir = os.path.join(sdk_root, 'help') else: help_dir = None loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join( cli.GoogleCloudSDKPackageRoot(), 'gcloud', 'sdktools', 'root'), allow_non_existing_modules=True, version_func=VersionFunc, help_func=cli.GetHelp(help_dir)) pkg_root = cli.GoogleCloudSDKPackageRoot() loader.AddModule('auth', os.path.join(pkg_root, 'gcloud', 'sdktools', 'auth')) loader.AddModule('bigquery', os.path.join(pkg_root, 'bigquery', 'commands')) loader.AddModule('components', os.path.join(pkg_root, 'gcloud', 'sdktools', 'components')) loader.AddModule('compute', os.path.join(pkg_root, 'compute', 'subcommands')) loader.AddModule('config', os.path.join(pkg_root, 'gcloud', 'sdktools', 'config')) loader.AddModule('dns', os.path.join(pkg_root, 'dns', 'dnstools')) loader.AddModule('endpoints', os.path.join(pkg_root, 'endpoints', 'commands')) loader.AddModule('internal', os.path.join(pkg_root, 'gcloud', 'sdktools', 'internal')) loader.AddModule('preview', os.path.join(pkg_root, 'preview', 'commands')) # Put app and datastore under preview for now. loader.AddModule('preview.analysis', os.path.join(pkg_root, 'analysis', 'commands')) loader.AddModule('preview.app', os.path.join(pkg_root, 'appengine', 'app_commands')) loader.AddModule('preview.container', os.path.join(pkg_root, 'container', 'commands')) loader.AddModule('preview.datastore', os.path.join(pkg_root, 'appengine', 'datastore_commands')) loader.AddModule('preview.dns', os.path.join(pkg_root, 'dns', 'commands')) loader.AddModule('preview.genomics', os.path.join(pkg_root, 'genomics', 'commands')) # TODO(user): Put logging in preview for now. loader.AddModule('preview.logging', os.path.join(pkg_root, 'logging', 'commands')) loader.AddModule('preview.projects', os.path.join(pkg_root, 'projects', 'commands')) loader.AddModule('preview.rolling_updates', os.path.join( pkg_root, 'updater', 'commands', 'rolling_updates')) loader.AddModule('preview.test', os.path.join(pkg_root, 'test', 'commands')) loader.AddModule('sql', os.path.join(pkg_root, 'sql', 'tools')) # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') return loader.Generate()
def _CreateCLI(self): pkg_root = self.Resource('tests', 'unit', 'command_lib', 'deprecation_manager', 'test_data') loader = calliope.CLILoader( name='test', command_root_directory=pkg_root) loader.AddReleaseTrack(calliope_base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'alpha')) return loader.Generate()
def SetUp(self): # Set up calliope to load the sdk5 test cli test_data_dir = self.Resource('tests', 'unit', 'calliope', 'testdata') pkg_root = os.path.join(test_data_dir, 'sdk5') loader = calliope.CLILoader(name='test', command_root_directory=pkg_root) self.cli = loader.Generate() self.named_config_dir = os.path.join(self.global_config_path, 'configurations')
def MakeCLI(self, spec, name='describe'): """Creates a CLI with one command that implements the given spec.""" test_cli_dir = self.Resource('tests', 'unit', 'command_lib', 'util', 'apis', 'testdata', 'sdk1') loader = calliope_cli.CLILoader(name='gcloud', command_root_directory=test_cli_dir, allow_non_existing_modules=True, yaml_command_translator=MockTranslator( spec, name=name)) return loader.Generate()
def SetUp(self): self.known_error_handler = mock.MagicMock() self._loader = calliope.CLILoader( name='gcloud', command_root_directory=self.Resource('surface'), allow_non_existing_modules=True, known_error_handler=self.known_error_handler, yaml_command_translator=yaml_command_translator.Translator()) self.cli = self._loader.Generate()
def SetUp(self): calliope_test_home = self.Resource('tests', 'unit', 'calliope', 'testdata') loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( calliope_test_home, 'sdk3')) self.generator = markdown.CommandMarkdownGenerator( loader.Generate()._TopElement()) self.generator._SetArgSections() self.arg = sorted(self.generator._arg_sections[0].args.arguments, key=usage_text.GetArgSortKey)[0]
def CreateCLI(surfaces): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) def HandleKnownErrorFunc(exc): crash_handling.ReportError(exc, is_crash=False) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc, known_error_handler=HandleKnownErrorFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) if os.path.exists(os.path.join(pkg_root, 'surface', 'beta')): # TODO(b/35758009): Remove cloned beta.test commands and PreRunHook after a # suitable deprecation period. # Clone 'firebase test' surface into 'beta test' for backward compatibility. loader.AddModule('beta.test', os.path.join(pkg_root, 'surface', 'firebase', 'test')) # The above call to AddModule() hides the `beta test android devices` group, # so add it back. loader.AddModule( 'beta.test.android.devices', os.path.join(pkg_root, 'surface', 'test', 'android', 'devices')) loader.RegisterPreRunHook(_IssueTestWarning, include_commands=r'gcloud\.beta\.test\..*') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') generated_cli = loader.Generate() return generated_cli
def CreateCLI(surfaces, translator=None): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. translator: yaml_command_translator.Translator, an alternative translator. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) def HandleKnownErrorFunc(exc): crash_handling.ReportError(exc, is_crash=False) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc, known_error_handler=HandleKnownErrorFunc, yaml_command_translator=(translator or yaml_command_translator.Translator()), ) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) # TODO(b/63771276): Remove cloned xpn commands and PreRunHook after a # suitable deprecation period. # Clone 'compute shared-vpc' surface into 'compute xpn' for backward # compatibility. loader.AddModule( 'compute.xpn', os.path.join(pkg_root, 'surface', 'compute', 'shared_vpc')) loader.RegisterPreRunHook(_IssueTestWarning, include_commands=r'gcloud\.compute\.xpn\..*') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') generated_cli = loader.Generate() return generated_cli
def SetUp(self): self.maxDiff = None self._loader = calliope_cli.CLILoader( name='test', command_root_directory=os.path.join( self.Resource('tests', 'unit', 'calliope', 'testdata', 'sdk1')), allow_non_existing_modules=True) self._loader.AddReleaseTrack( calliope_base.ReleaseTrack.ALPHA, os.path.join( self.Resource('tests', 'unit', 'calliope', 'testdata', 'alpha'))) self.cli = self._loader.Generate()
def GetCLI(self, force_init=True): """Loads the test commands with a temporary logging directory. Args: force_init: bool, True to completely reset the logger, False to add a new handler. Returns: calliope.CLI, The CLI object. """ log.Reset() loader = calliope.CLILoader(name='test', command_root_directory=os.path.join( self.calliope_test_home, 'sdk1'), logs_dir=self.logs_dir) loader.AddModule('sdk2', os.path.join(self.calliope_test_home, 'sdk2')) return loader.Generate()
def CreateCLI(surfaces): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) if os.path.exists(os.path.join(pkg_root, 'surface', 'beta')): for mod in ['jobs', 'local', 'models', 'operations', 'versions', 'init_project.py', 'predict.py']: loader.AddModule( 'beta.ml.{}'.format(mod.replace('.py', '')), os.path.join(pkg_root, 'surface', 'ml_engine', mod)) loader.RegisterPreRunHook(IssueMlWarning, include_commands=r'gcloud\.beta\.ml\..*', exclude_commands=r'gcloud\.beta\.ml\.vision\..*') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') generated_cli = loader.Generate() return generated_cli
def CreateCLI(surfaces, translator=None): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. translator: yaml_command_translator.Translator, an alternative translator. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) def HandleKnownErrorFunc(): crash_handling.ReportError(is_crash=False) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc, known_error_handler=HandleKnownErrorFunc, yaml_command_translator=(translator or yaml_command_translator.Translator()), ) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) # Check for updates on shutdown but not for any of the updater commands. # Skip update checks for 'gcloud version' command as it does that manually. exclude_commands = r'gcloud\.components\..*|gcloud\.version' loader.RegisterPostRunHook(UpdateCheck, exclude_commands=exclude_commands) generated_cli = loader.Generate() return generated_cli
def CreateCLI(): """Generates the gcloud CLI.""" pkg_root = os.path.dirname(googlecloudsdk.__file__) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') loader.AddModule('services', os.path.join(pkg_root, 'service_management', 'subcommands'), component=None) # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') return loader.Generate()
def SetUp(self): self.known_error_handler = mock.MagicMock() self._loader = calliope.CLILoader( name='test', command_root_directory=os.path.join(self.calliope_test_home, 'sdk1'), allow_non_existing_modules=True, known_error_handler=self.known_error_handler) self._loader.AddModule('sdk2', os.path.join(self.calliope_test_home, 'sdk2')) self._loader.AddModule( 'sdk3', os.path.join(self.calliope_test_home, 'nested_sdk', 'sdk1')) self._loader.AddModule('sdk7', os.path.join(self.calliope_test_home, 'sdk7')) self._loader.AddModule('sdk11', os.path.join(self.calliope_test_home, 'sdk11')) self._loader.AddModule( 'broken_sdk', os.path.join(self.calliope_test_home, 'broken_sdk')) self._loader.AddModule('does-not-exist', os.path.join(self.calliope_test_home, 'does_not_exist'), component='does_not_exist') self._loader.AddReleaseTrack( calliope_base.ReleaseTrack.ALPHA, os.path.join(self.calliope_test_home, 'track_does_not_exist')) # This breaks a lot and is obviously wrong. I don't understand # tracks/modules enough to handle this better. self._loader.AddReleaseTrack( calliope_base.ReleaseTrack.BETA, # sdk2 is an arbitrary valid subdirectory. Binding BETA to the root # caused flag collisions. os.path.join(self.calliope_test_home, 'sdk2')) self.cli = self._loader.Generate()
def SetUp(self): test_data_dir = self.Resource('tests', 'unit', 'calliope', 'testdata') pkg_root = os.path.join(test_data_dir, 'sdk1') loader = calliope.CLILoader(name='test', command_root_directory=pkg_root) self.cli = loader.Generate()
def CreateCLI(surfaces): """Generates the gcloud CLI from 'surface' folder with extra surfaces. Args: surfaces: list(tuple(dot_path, dir_path)), extra commands or subsurfaces to add, where dot_path is calliope command path and dir_path path to command group or command. Returns: calliope cli object. """ def VersionFunc(): generated_cli.Execute(['version']) pkg_root = os.path.dirname(os.path.dirname(surface.__file__)) loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') for dot_path, dir_path in surfaces: loader.AddModule(dot_path, dir_path, component=None) if os.path.exists(os.path.join(pkg_root, 'surface', 'beta')): for mod in [ 'jobs', 'local', 'models', 'operations', 'versions', 'init_project.py', 'predict.py' ]: loader.AddModule( 'beta.ml.{}'.format(mod.replace('.py', '')), os.path.join(pkg_root, 'surface', 'ml_engine', mod)) loader.RegisterPreRunHook( IssueMlWarning, include_commands=r'gcloud\.beta\.ml\..*', exclude_commands=(r'gcloud\.beta\.ml\.vision\..*' r'|gcloud\.beta\.ml\.language\..*' r'|gcloud\.beta\.ml$')) # TODO(b/35758009): Remove cloned beta.test commands and PreRunHook after a # suitable deprecation period. # Clone 'firebase test' surface into 'beta test' for backward compatibility. loader.AddModule('beta.test', os.path.join(pkg_root, 'surface', 'firebase', 'test')) # The above call to AddModule() hides the `beta test android devices` group, # so add it back. loader.AddModule( 'beta.test.android.devices', os.path.join(pkg_root, 'surface', 'test', 'android', 'devices')) loader.RegisterPreRunHook(_IssueTestWarning, include_commands=r'gcloud\.beta\.test\..*') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') generated_cli = loader.Generate() return generated_cli
def GetCLI(self, name): loader = calliope.CLILoader(name='gcloud', command_root_directory=os.path.join( os.path.dirname(__file__), name)) return loader.Generate()
def CreateCLI(): """Generates the gcloud CLI.""" pkg_root = config.GoogleCloudSDKPackageRoot() loader = cli.CLILoader(name='gcloud', command_root_directory=os.path.join( pkg_root, 'gcloud', 'sdktools', 'root'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'gcloud', 'sdktools', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'gcloud', 'sdktools', 'beta'), component='beta') loader.AddModule('auth', os.path.join(pkg_root, 'gcloud', 'sdktools', 'auth')) loader.AddModule('bigquery', os.path.join(pkg_root, 'bigquery', 'commands')) loader.AddModule('bigtable', os.path.join(pkg_root, 'bigtable', 'commands')) loader.AddModule( 'components', os.path.join(pkg_root, 'gcloud', 'sdktools', 'components')) loader.AddModule('compute', os.path.join(pkg_root, 'compute', 'subcommands'), component='compute') loader.AddModule('config', os.path.join(pkg_root, 'gcloud', 'sdktools', 'config')) loader.AddModule('container', os.path.join(pkg_root, 'container', 'commands'), component='gcloud') loader.AddModule('dataflow', os.path.join(pkg_root, 'dataflow', 'commands')) loader.AddModule('deployment_manager', os.path.join(pkg_root, 'deployment_manager', 'commands')) loader.AddModule('dns', os.path.join(pkg_root, 'dns', 'commands'), component='dns') loader.AddModule('endpoints', os.path.join(pkg_root, 'endpoints', 'commands')) loader.AddModule('internal', os.path.join(pkg_root, 'gcloud', 'sdktools', 'internal')) loader.AddModule('meta', os.path.join(pkg_root, 'gcloud', 'sdktools', 'meta')) loader.AddModule('preview', os.path.join(pkg_root, 'preview', 'commands'), component='preview') # Put app and datastore under preview for now. loader.AddModule('preview.analysis', os.path.join(pkg_root, 'analysis', 'commands')) loader.AddModule('preview.app', os.path.join(pkg_root, 'appengine', 'app_commands'), component='app') loader.AddModule('preview.datastore', os.path.join(pkg_root, 'appengine', 'datastore_commands'), component='app') loader.AddModule('genomics', os.path.join(pkg_root, 'genomics', 'commands')) # TODO(user): Put logging in preview for now. loader.AddModule('preview.logging', os.path.join(pkg_root, 'logging', 'commands')) loader.AddModule( 'preview.rolling_updates', os.path.join(pkg_root, 'updater', 'commands', 'rolling_updates')) loader.AddModule('preview.test', os.path.join(pkg_root, 'test', 'commands')) loader.AddModule('projects', os.path.join(pkg_root, 'projects', 'commands'), component='gcloud') loader.AddModule( 'services', os.path.join(pkg_root, 'service_management', 'subcommands')) loader.AddModule('source', os.path.join(pkg_root, 'source', 'commands')) loader.AddModule('sql', os.path.join(pkg_root, 'sql', 'tools'), component='sql') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') return loader.Generate()
def CreateCLI(): """Generates the gcloud CLI.""" pkg_root = os.path.dirname(googlecloudsdk.__file__) loader = cli.CLILoader( name='gcloud', command_root_directory=os.path.join(pkg_root, 'surface'), allow_non_existing_modules=True, version_func=VersionFunc) loader.AddReleaseTrack(base.ReleaseTrack.ALPHA, os.path.join(pkg_root, 'surface', 'alpha'), component='alpha') loader.AddReleaseTrack(base.ReleaseTrack.BETA, os.path.join(pkg_root, 'surface', 'beta'), component='beta') loader.AddModule('bigquery', os.path.join(pkg_root, 'bigquery', 'commands'), component='gcloud') loader.AddModule('compute', os.path.join(pkg_root, 'compute', 'subcommands'), component='gcloud') loader.AddModule('container', os.path.join(pkg_root, 'container', 'commands'), component='gcloud') loader.AddModule('dataflow', os.path.join(pkg_root, 'dataflow', 'commands'), component='gcloud') loader.AddModule('dataproc', os.path.join(pkg_root, 'dataproc', 'commands'), component='gcloud') loader.AddModule('deployment_manager', os.path.join(pkg_root, 'deployment_manager', 'commands'), component='gcloud') loader.AddModule('dns', os.path.join(pkg_root, 'dns', 'commands'), component='gcloud') loader.AddModule('emulators', os.path.join(pkg_root, 'emulators', 'commands'), component='gcloud') loader.AddModule('endpoints', os.path.join(pkg_root, 'endpoints', 'commands'), component='gcloud') loader.AddModule('functions', os.path.join(pkg_root, 'functions', 'commands'), component='gcloud') loader.AddModule('internal', os.path.join(pkg_root, 'internal', 'commands'), component=None) loader.AddModule('preview', os.path.join(pkg_root, 'appengine', 'preview'), component='app') loader.AddModule('preview.app', os.path.join(pkg_root, 'appengine', 'app_commands'), component='app') loader.AddModule('preview.datastore', os.path.join(pkg_root, 'appengine', 'datastore_commands'), component='app') loader.AddModule('genomics', os.path.join(pkg_root, 'genomics', 'commands'), component='gcloud') loader.AddModule('logging', os.path.join(pkg_root, 'logging', 'commands'), component='gcloud') loader.AddModule('projects', os.path.join(pkg_root, 'projects', 'commands'), component='gcloud') loader.AddModule('pubsub', os.path.join(pkg_root, 'pubsub', 'commands'), component='gcloud') loader.AddModule('services', os.path.join(pkg_root, 'service_management', 'subcommands'), component=None) loader.AddModule('source', os.path.join(pkg_root, 'source', 'commands'), component='gcloud') loader.AddModule('sql', os.path.join(pkg_root, 'sql', 'tools'), component='gcloud') loader.AddModule('test', os.path.join(pkg_root, 'test', 'commands'), component='gcloud') # Check for updates on shutdown but not for any of the updater commands. loader.RegisterPostRunHook(UpdateCheck, exclude_commands=r'gcloud\.components\..*') return loader.Generate()