
    k)                     z   S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	Jr
  SSK	Jr  SSK	Jr  SSKJr  SS	KJr  SSKr\R$                  (       a  SS
KJr  SSKJr  SrSrS rS rS r\R4                  " \R6                  R8                  \R6                  R:                  5       " S S\R<                  5      5       rg)z;Extensible interactive shell with auto completion and help.    N)base)cli_tree)config)
exceptions)
properties)render_document)encoding)application)bindingsz|
* auto-completion and active help for all commands
* state preservation across commands: *cd*, local/environment variables
a  
# 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.

c                     [         R                  R                  R                  R	                  5       =(       d    SnU(       a  US-  nX-  n[
        R                  " [        R                  SU5        g)a	  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.
 .CLOUDSDK_METRICS_ENVIRONMENTN)	r   VALUESmetricsenvironmentGetr	   SetEncodedValueosenviron)tagmetrics_environments     lib/surface/interactive.py_AppendMetricsEnvironmentr   <   s[     #))11==AACIr3
2::'E.0    c            	      L   [         R                  (       a  g/ n [        R                  " 5       R                   HY  nUR	                  SS9nU(       d  M  U R                  SR                  UR                  SS95      5        U R                  U5        M[     SR                  U 5      $ )z0Returns the function key bindings help markdown.r   T)markdownz
{}:::
)	sixPY2r   KeyBindingsGetHelpappendformatGetLabeljoin)lineskey	help_texts      r   _GetKeyBindingsHelpr*   M   s~    WW
%!!#,,cT*Iyll9##CLL$L$?@All9	 -
 
5	r   c                  f   / n [        [        R                  R                  S S9 H  nUR                  (       d  M  U R                  SR                  UR                  5      5        U R                  UR                  5        UR                  nUc  Ml  [        U[        R                  5      (       a  SR                  U5      nO;US;   a$  [        R                  " U5      R                  5       nSR                  U5      nU R                  SR                  U5      5        M     SR                  U 5      $ )	z%Returns the properties help markdown.c                     U R                   $ )N)name)ps    r   <lambda>$_GetPropertiesHelp.<locals>.<lambda>]   s    !&&r   )r(   z
*{}*::z"{}")FTz*{}*zThe default value is {}.r   )sortedr   r   interactiver)   r#   r$   r-   default
isinstancer   string_types	text_typelowerr&   )r'   propr3   s      r   _GetPropertiesHelpr9   Z   s    
%Z&&228HId~~~ll:$$TYY/0ll4>>"g		gs//00MM'*'%mmG,224GMM'*'/66w?@ J 
5	r   c                   :    \ rS rSrSr\\\S.r\	S 5       r
S rSrg)Interactivem   a  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.
)r   featuresr   c                     U R                  SSS9  U R                  SSSS SS9  U R                  S	SSS S
S9  U R                  SSSS9  U R                  SSSS SS9  g )Nz	--contextzDefault 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.)helpz--debugT
store_truezEnable debugging display.)hiddenactionr3   r?   z--hiddenz/Enable completion of hidden commands and flags.z--promptzThe interactive shell prompt.)rA   r?   z	--suggestz_Enable auto suggestion from history. The defaults are currently too rudimentary for prime time.)add_argument)parsers    r   ArgsInteractive.Args  s    
4  6 (  * >  @ ,  . 0  2r   c                 2   [         R                  (       a  [        R                  " S5      e[        R
                  " 5       R                  nU(       a   [        R                  " U R                  SSS9  UR                  (       d,  [        R                  " [        R                  " [        5      S9  [         R"                  " UR$                  UR&                  UR(                  UR*                  UR,                  S9n[/        S5        [0        R2                  " XS9  g )NzCThis command does not support Python 2. Please upgrade to Python 3.F)cliforceverbose)fin)contextdebugrA   promptsuggestinteractive_shell)argsr   )r   r    r   Errorgcloud_configPathssdk_rootr   Load_cli_do_not_use_directlyquietr   RenderDocumentioStringIO_SPLASHconfigurationConfigrL   rM   rA   rN   rO   r   r
   main)selfrQ   rU   r   s       r   RunInteractive.Run$  s    
ww 4 5 5 ""$--Hmm55UER::$$W)=>!!jj{{{{F 12$.r    N)__name__
__module____qualname____firstlineno____doc__r*   	_FEATURESr9   detailed_helpstaticmethodrE   ra   __static_attributes__rc   r   r   r;   r;   m   s4    L^ &&- 2 2>/r   r;   ) rh   rZ   r   googlecloudsdk.callioper   r   &googlecloudsdk.command_lib.interactiver   r]   googlecloudsdk.corerS   r   r   &googlecloudsdk.core.document_renderersr   googlecloudsdk.core.utilr	   r   PY3r
   r   ri   r\   r   r*   r9   ReleaseTracksReleaseTrackALPHABETACommandr;   rc   r   r   <module>rx      s     B 
 	 ( , J 7 * * B - 
 77@=	
0"
& D%%++T->->-C-CDI/$,, I/ EI/r   