⚡ L1L`XPL0IT
8.2.34 | Linux | www-data (uid:33)
✏️ Edit: interactive.py
📁 /snap/google-cloud-cli/current/lib/surface/interactive.py
# -*- coding: utf-8 -*- # # Copyright 2017 Google LLC. All Rights Reserved. # # Licensed 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. """Extensible interactive shell with auto completion and help.""" import io import os from googlecloudsdk.calliope import base from googlecloudsdk.calliope import cli_tree from googlecloudsdk.command_lib.interactive import config as configuration from googlecloudsdk.core import config as gcloud_config from googlecloudsdk.core import exceptions from googlecloudsdk.core import properties from googlecloudsdk.core.document_renderers import render_document from googlecloudsdk.core.util import encoding import six if six.PY3: # pylint: disable=g-import-not-at-top from googlecloudsdk.command_lib.interactive import application from googlecloudsdk.command_lib.interactive import bindings # pylint: enable=g-import-not-at-top _FEATURES = """ * auto-completion and active help for all commands * state preservation across commands: *cd*, local/environment variables """ _SPLASH = """ # Welcome to the gcloud interactive shell environment. Tips: * start by typing commands to get auto-suggestions and inline help * use `tab`, `up-arrow`, or `down-arrow` to navigate completion dropdowns * use `space` or `/` to accept the highlighted dropdown item * run gcloud <alpha|beta> interactive --help for more info Run *$ gcloud feedback* to report bugs or request new features. """ def _AppendMetricsEnvironment(tag): """Appends tag to the Cloud SDK metrics environment tag. The metrics/environment tag is sent via the useragent. This tag is visible in metrics for all gcloud commands executed by the calling command. Args: tag: The string to append to the metrics/environment tag. """ metrics_environment = properties.VALUES.metrics.environment.Get() or '' if metrics_environment: metrics_environment += '.' metrics_environment += tag encoding.SetEncodedValue(os.environ, 'CLOUDSDK_METRICS_ENVIRONMENT', metrics_environment) def _GetKeyBindingsHelp(): """Returns the function key bindings help markdown.""" if six.PY2: return '' lines = [] for key in bindings.KeyBindings().bindings: help_text = key.GetHelp(markdown=True) if help_text: lines.append('\n{}:::'.format(key.GetLabel(markdown=True))) lines.append(help_text) return '\n'.join(lines) def _GetPropertiesHelp(): """Returns the properties help markdown.""" lines = [] for prop in sorted(properties.VALUES.interactive, key=lambda p: p.name): if prop.help_text: lines.append('\n*{}*::'.format(prop.name)) lines.append(prop.help_text) default = prop.default if default is not None: if isinstance(default, six.string_types): default = '"{}"'.format(default) else: if default in (False, True): default = six.text_type(default).lower() default = '*{}*'.format(default) lines.append('The default value is {}.'.format(default)) return '\n'.join(lines) @base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA) class Interactive(base.Command): # pylint: disable=line-too-long """Start the gcloud interactive shell. *{command}* provides an enhanced *bash*(1) command line with features that include: {features} ### Display The *{command}* display window is divided into sections, described here from top to bottom. *Previous Output*:: Command output scrolls above the command input section as commands are executed. *Command Input*:: Commands are typed, completed, and edited in this section. The default prompt is "$ ". If a context has been set, then its tokens are prepopulated before the cursor. *Active Help*:: As you type, this section displays in-line help summaries for commands, flags, and arguments. You can toggle active help on and off via the *F2* key. Hit *F8* to display the help text in your browser. *Status Display*:: Current *gcloud* project and account information, and function key descriptions and settings are displayed in this section. Function keys toggle mode/state settings or run specific actions. {bindings} ### Auto and Tab Completion Command completions are displayed in a scrolling pop-up menu. Use `tab` and up/down keys to navigate the completions, and `space` or `/` to select the highlighted completion. Completions for _known_ commands, flags, and static flag values are displayed automatically. Positional and dynamic flag value completions for known commands are displayed after `tab` is entered. Known commands include `gcloud`, `bq`, `gsutil`, `kubectl`, and any command with a man page that has been executed at least once in any *interactive* session. `tab` completion for unknown commands defers to *bash*(1), while still using the *interactive* user interface. Absent specific command information, a file/path completer is used when `tab` is entered for unknown positionals (arguments that do not start with '-'). The default completer handles '~' path notation and embedded _$var_ references, but does not expand their values in completions. Configure bash completions as you normally would. *{command}* starts up bash in a mode that sources *~/.bashrc* with the environment variable *COSHELL_VERSION* set to a non-empty version value. Command completion resets with each simple command in the command line. Simple commands are separated by '|', ';', '&' and may appear after '$(', '(', '{', '!', *if*, *then*, *elif*, *while*, and _name_=_value_ per command exports. Use `tab` on an empty line to enable command executable search on PATH for the first token in each simple command. Currently simple and compound commands must be entered in a single line. Refer to [Using gcloud interactive](https://cloud.google.com/sdk/docs/interactive-gcloud) for more information and animated GIFs. ### Control Characters Control characters affect the currently running command or the current command line being entered at the prompt. *ctrl-c*:: If a command is currently running, then that command is interrupted. This terminates the command. Otherwise, if no command is running, ctrl-c clears the current command line. *ctrl-d*:: Exits when entered as the first character at the command prompt. You can also run the *exit* command at the prompt. *ctrl-w*:: If a command is not currently running, then the last word on the command line is deleted. This is handy for "walking back" partial completions. ### Command history *{command}* maintains persistent command history across sessions. #### emacs mode *^N*:: Move ahead one line in the history. *^P*:: Move back one line in the history. *^R*:: Search backwards in the history. #### vi mode /:: Search backwards in the history. *j*:: Move ahead one line in the history. *k*:: Move back one line in the history. *n*:: Search backwards for the next match. *N*:: Search forwards for the next match. #### history search mode *ENTER/RETURN*:: Retrieve the matched command line from the history. *^R*:: Search backwards for the next match. *^S*:: Search forwards for the next match. ### Layout Configuration Parts of the layout are configurable via *$ gcloud config set* interactive/_property_. These properties are only checked at startup. You must exit and restart to see the effects of new settings. {properties} ### CLI Trees *{command}* uses CLI tree data files for typeahead, command line completion, and help snippet generation. A few CLI trees are installed with their respective Google Cloud CLI components: *gcloud* (core component), *bq*, *gsutil*, and *kubectl*. Trees for commands that have man(1) pages are generated on the fly. See `$ gcloud topic cli-trees` for details. ## EXAMPLES To set the command context of *{command}* to "gcloud ", run: {command} --context="gcloud " ## NOTES On Windows, install *git*(1) for a *bash*(1) experience. *{command}* will then use the *git* (MinGW) *bash* instead of *cmd.exe*. Please run *$ gcloud feedback* to report bugs or request new features. """ detailed_help = { 'bindings': _GetKeyBindingsHelp, 'features': _FEATURES, 'properties': _GetPropertiesHelp, } @staticmethod def Args(parser): parser.add_argument( '--context', help=('Default command context. This is a string containing a ' 'command name, flags, and arguments. The context is prepopulated ' 'in each command line. You can inline edit any part of the ' 'context, or ctrl-c to eliminate it.')) parser.add_argument( '--debug', hidden=True, action='store_true', default=None, help='Enable debugging display.') parser.add_argument( '--hidden', hidden=True, action='store_true', default=None, help='Enable completion of hidden commands and flags.') parser.add_argument( '--prompt', hidden=True, help='The interactive shell prompt.') parser.add_argument( '--suggest', hidden=True, action='store_true', default=None, help=('Enable auto suggestion from history. The defaults are currently ' 'too rudimentary for prime time.')) def Run(self, args): if six.PY2: raise exceptions.Error('This command does not support Python 2. Please ' 'upgrade to Python 3.') sdk_root = gcloud_config.Paths().sdk_root if sdk_root: cli_tree.Load(cli=self._cli_do_not_use_directly, force=False, verbose=False) if not args.quiet: render_document.RenderDocument(fin=io.StringIO(_SPLASH)) config = configuration.Config( context=args.context, debug=args.debug, hidden=args.hidden, prompt=args.prompt, suggest=args.suggest, ) _AppendMetricsEnvironment('interactive_shell') application.main(args=args, config=config)
Cancel
💻 Terminal
📤 Upload
📂
Click or Drag & Drop
📁 /snap/google-cloud-cli/current/lib/surface
/
/
snap
/
google-cloud-cli
/
current
/
lib
/
surface
Name
Size
Perm
Modified
Actions
📁 __pycache__/
-
0775
2026-09-29 12:17
🗑 Delete
📁 access_approval/
-
0775
2026-09-29 12:17
🗑 Delete
📁 access_context_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 active_directory/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agent_identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agent_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agentic_applications/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ai/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ai_platform/
-
0775
2026-09-29 12:17
🗑 Delete
📁 alloydb/
-
0775
2026-09-29 12:17
🗑 Delete
📁 alpha/
-
0775
2026-09-29 12:17
🗑 Delete
📁 anthos/
-
0775
2026-09-29 12:17
🗑 Delete
📁 api_gateway/
-
0775
2026-09-29 12:17
🗑 Delete
📁 api_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apigee/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apihub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_lifecycle_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_optimize/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_topology/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apphub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 artifacts/
-
0775
2026-09-29 12:17
🗑 Delete
📁 asset/
-
0775
2026-09-29 12:17
🗑 Delete
📁 assured/
-
0775
2026-09-29 12:17
🗑 Delete
📁 audit_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 auth/
-
0775
2026-09-29 12:17
🗑 Delete
📁 authz_toolkit/
-
0775
2026-09-29 12:17
🗑 Delete
📁 backup_dr/
-
0775
2026-09-29 12:17
🗑 Delete
📁 batch/
-
0775
2026-09-29 12:17
🗑 Delete
📁 beta/
-
0775
2026-09-29 12:17
🗑 Delete
📁 beyondcorp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 biglake/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bigtable/
-
0775
2026-09-29 12:17
🗑 Delete
📁 billing/
-
0775
2026-09-29 12:17
🗑 Delete
📁 blockchain_node_engine/
-
0775
2026-09-29 12:17
🗑 Delete
📁 blockchain_validator/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bms/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bq/
-
0775
2026-09-29 12:17
🗑 Delete
📁 builds/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cbrs_spectrum_access/
-
0775
2026-09-29 12:17
🗑 Delete
📁 certificate_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cloud_shell/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cloudlocationfinder/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cluster_director/
-
0775
2026-09-29 12:17
🗑 Delete
📁 code/
-
0775
2026-09-29 12:17
🗑 Delete
📁 colab/
-
0775
2026-09-29 12:17
🗑 Delete
📁 commerce_procurement/
-
0775
2026-09-29 12:17
🗑 Delete
📁 compliance_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 components/
-
0775
2026-09-29 12:17
🗑 Delete
📁 composer/
-
0775
2026-09-29 12:17
🗑 Delete
📁 compute/
-
0775
2026-09-29 12:17
🗑 Delete
📁 config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 container/
-
0775
2026-09-29 12:17
🗑 Delete
📁 data_catalog/
-
0775
2026-09-29 12:17
🗑 Delete
📁 data_fusion/
-
0775
2026-09-29 12:17
🗑 Delete
📁 database_migration/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataflow/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datalineage/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datapipelines/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataplex/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataproc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataproc_gdc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datastore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datastream/
-
0775
2026-09-29 12:17
🗑 Delete
📁 deploy/
-
0775
2026-09-29 12:17
🗑 Delete
📁 deployment_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 design_center/
-
0775
2026-09-29 12:17
🗑 Delete
📁 developer_connect/
-
0775
2026-09-29 12:17
🗑 Delete
📁 developer_knowledge/
-
0775
2026-09-29 12:17
🗑 Delete
📁 device_run/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dialogflow/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dlp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dns/
-
0775
2026-09-29 12:17
🗑 Delete
📁 domains/
-
0775
2026-09-29 12:17
🗑 Delete
📁 edge_cache/
-
0775
2026-09-29 12:17
🗑 Delete
📁 edge_cloud/
-
0775
2026-09-29 12:17
🗑 Delete
📁 emulators/
-
0775
2026-09-29 12:17
🗑 Delete
📁 endpoints/
-
0775
2026-09-29 12:17
🗑 Delete
📁 error_reporting/
-
0775
2026-09-29 12:17
🗑 Delete
📁 essential_contacts/
-
0775
2026-09-29 12:17
🗑 Delete
📁 eventarc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 fault_testing/
-
0775
2026-09-29 12:17
🗑 Delete
📁 filestore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firebase/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firebase_data_connect/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firestore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 functions/
-
0775
2026-09-29 12:17
🗑 Delete
📁 gemini/
-
0775
2026-09-29 12:17
🗑 Delete
📁 genomics/
-
0775
2026-09-29 12:17
🗑 Delete
📁 healthcare/
-
0775
2026-09-29 12:17
🗑 Delete
📁 iam/
-
0775
2026-09-29 12:17
🗑 Delete
📁 iap/
-
0775
2026-09-29 12:17
🗑 Delete
📁 identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ids/
-
0775
2026-09-29 12:17
🗑 Delete
📁 immersive_stream/
-
0775
2026-09-29 12:17
🗑 Delete
📁 infra_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 kms/
-
0775
2026-09-29 12:17
🗑 Delete
📁 logging/
-
0775
2026-09-29 12:17
🗑 Delete
📁 looker/
-
0775
2026-09-29 12:17
🗑 Delete
📁 lustre/
-
0775
2026-09-29 12:17
🗑 Delete
📁 managed_flink/
-
0775
2026-09-29 12:17
🗑 Delete
📁 managed_kafka/
-
0775
2026-09-29 12:17
🗑 Delete
📁 media/
-
0775
2026-09-29 12:17
🗑 Delete
📁 memcache/
-
0775
2026-09-29 12:17
🗑 Delete
📁 memorystore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 meta/
-
0775
2026-09-29 12:17
🗑 Delete
📁 metastore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 microservices/
-
0775
2026-09-29 12:17
🗑 Delete
📁 migration/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ml/
-
0775
2026-09-29 12:17
🗑 Delete
📁 mldiagnostics/
-
0775
2026-09-29 12:17
🗑 Delete
📁 model_armor/
-
0775
2026-09-29 12:17
🗑 Delete
📁 monitoring/
-
0775
2026-09-29 12:17
🗑 Delete
📁 mps/
-
0775
2026-09-29 12:17
🗑 Delete
📁 netapp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_connectivity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_management/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_security/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_services/
-
0775
2026-09-29 12:17
🗑 Delete
📁 notebooks/
-
0775
2026-09-29 12:17
🗑 Delete
📁 number_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 observability/
-
0775
2026-09-29 12:17
🗑 Delete
📁 onboarding/
-
0775
2026-09-29 12:17
🗑 Delete
📁 oracle_database/
-
0775
2026-09-29 12:17
🗑 Delete
📁 orchestration_pipelines/
-
0775
2026-09-29 12:17
🗑 Delete
📁 org_policies/
-
0775
2026-09-29 12:17
🗑 Delete
📁 organizations/
-
0775
2026-09-29 12:17
🗑 Delete
📁 orglifecycle/
-
0775
2026-09-29 12:17
🗑 Delete
📁 pam/
-
0775
2026-09-29 12:17
🗑 Delete
📁 parallelstore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 parametermanager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 policy_intelligence/
-
0775
2026-09-29 12:17
🗑 Delete
📁 policy_troubleshoot/
-
0775
2026-09-29 12:17
🗑 Delete
📁 preview/
-
0775
2026-09-29 12:17
🗑 Delete
📁 privateca/
-
0775
2026-09-29 12:17
🗑 Delete
📁 projects/
-
0775
2026-09-29 12:17
🗑 Delete
📁 publicca/
-
0775
2026-09-29 12:17
🗑 Delete
📁 pubsub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 quotas/
-
0775
2026-09-29 12:17
🗑 Delete
📁 recaptcha/
-
0775
2026-09-29 12:17
🗑 Delete
📁 recommender/
-
0775
2026-09-29 12:17
🗑 Delete
📁 redis/
-
0775
2026-09-29 12:17
🗑 Delete
📁 remote_build_execution/
-
0775
2026-09-29 12:17
🗑 Delete
📁 resource_config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 resource_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 run/
-
0775
2026-09-29 12:17
🗑 Delete
📁 runtime_config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 scc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 scheduler/
-
0775
2026-09-29 12:17
🗑 Delete
📁 seclm/
-
0775
2026-09-29 12:17
🗑 Delete
📁 secrets/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_directory/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_extensions/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_health/
-
0775
2026-09-29 12:17
🗑 Delete
📁 services/
-
0775
2026-09-29 12:17
🗑 Delete
📁 software_delivery_trust/
-
0775
2026-09-29 12:17
🗑 Delete
📁 source/
-
0775
2026-09-29 12:17
🗑 Delete
📁 source_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 spanner/
-
0775
2026-09-29 12:17
🗑 Delete
📁 spectrum_access/
-
0775
2026-09-29 12:17
🗑 Delete
📁 sql/
-
0775
2026-09-29 12:17
🗑 Delete
📁 storage/
-
0775
2026-09-29 12:17
🗑 Delete
📁 support/
-
0775
2026-09-29 12:17
🗑 Delete
📁 tasks/
-
0775
2026-09-29 12:17
🗑 Delete
📁 telco_automation/
-
0775
2026-09-29 12:17
🗑 Delete
📁 terraform/
-
0775
2026-09-29 12:17
🗑 Delete
📁 topic/
-
0775
2026-09-29 12:17
🗑 Delete
📁 trace/
-
0775
2026-09-29 12:17
🗑 Delete
📁 transcoder/
-
0775
2026-09-29 12:17
🗑 Delete
📁 transfer/
-
0775
2026-09-29 12:17
🗑 Delete
📁 vector_search/
-
0775
2026-09-29 12:17
🗑 Delete
📁 vmware/
-
0775
2026-09-29 12:17
🗑 Delete
📁 web_security_scanner/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workbench/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workflows/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workload_identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workspace_add_ons/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workstations/
-
0775
2026-09-29 12:17
🗑 Delete
📁 zone_management/
-
0775
2026-09-29 12:17
🗑 Delete
__init__.py
7.5K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
cheat_sheet.py
5.9K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
docker.py
6.2K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
feedback.py
5.3K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
help.py
5K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
info.py
3.9K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
init.py
23.4K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
interactive.py
10.4K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
survey.py
3K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
unlock.py
2.1K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
version.py
2.1K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del