Ijk0LdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZmZddlmZmZmZddlmZmZddlmZmZmZmZmZmZm Z m!Z!ddl"Z#ddl$m%Z%m&Z&dd l'm(Z(dd l)m*Z*dd l+m,Z,m-Z-dd l.m/Z/m0Z0dd l1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:ddl5m;Z<ddl5m=Z>ddl7m?Z?m@Z@mAZAmBZBddlCmDZDmEZEddlFmGZGmHZHddl8mIZImJZJmKZKmLZLddlMmNZNmOZOmPZPddlQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYddlZm[Z[m\Z\m]Z]ddl^m_Z_m`Z`maZambZbmcZcddl;mdZdmeZemfZfmgZgddlhmiZiejjek5ddllmmZmdddn #1swxYwYddlnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxddl:myZymzZzm{Z{m|Z|m}Z}eveoj~kr,efe j eweij!ndd"lnmZmZejZeveojkrejjjZnUeveojkrJddlZdd#lnmZejed$Ze!eej!eejjZGd%d&ZGd'd(Zed)gd*Zer#egejfZed+eHzgejfZneZeZGd,d-ZGd.d+ZdS)/acmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python. cmd2 is a tool for building interactive command line applications in Python. Its goal is to make it quick and easy for developers to build feature-rich and user-friendly interactive command line applications. It provides a simple API which is an extension of Python's built-in cmd module. cmd2 provides a wealth of features on top of cmd to make your life easier and eliminates much of the boilerplate code which would be necessary when using cmd. Extra features include: - Searchable command history (commands: "history") - Run commands from file, save to file, edit commands in file - Multi-line commands - Special-character shortcut commands (beyond cmd's "?" and "!") - Settable environment parameters - Parsing commands with `argparse` argument parsers (flags) - Redirection to file or paste buffer (clipboard) with > or >> - Easy transcript-based testing of applications (see examples/transcript_example.py) - Bash-style ``select`` available Note, if self.stdout is different than sys.stdout, then redirection with > and | will only work if `self.poutput()` is used in place of `print`. GitHub: https://github.com/python-cmd2/cmd2 Documentation: https://cmd2.readthedocs.io/ N)InteractiveConsole) OrderedDict namedtuple)CallableIterableMapping) FrameType ModuleType)IO TYPE_CHECKINGAnyClassVarTextIOTypeVarUnioncast)GroupRenderableType)ReprHighlighter)Rule)Style StyleType)ColumnTable)Text) Traceback)argparse_completerargparse_custom constantspluginutils) rich_utils) string_utils)ChoicesProviderFuncCmd2ArgumentParser CompleterFuncCompletionItem)get_paste_bufferwrite_to_paste_buffer) CommandFunc CommandSet) CLASS_ATTR_DEFAULT_HELP_CATEGORYCOMMAND_FUNC_PREFIXCOMPLETER_FUNC_PREFIXHELP_FUNC_PREFIX) CommandParentas_subcommand_towith_argparser)Cmd2ShlexErrorCommandSetRegistrationErrorCompletionErrorEmbeddedConsoleExitEmptyStatementPassThroughExceptionRedirectionErrorSkipPostcommandHooks)History HistoryItemsingle_line_format)MacroMacroArg StatementStatementParser shlex_split)Cmd2BaseConsoleCmd2ExceptionConsoleCmd2GeneralConsoleRichPrintKwargs) Cmd2Style start_ipython) RlTyperl_escape_promptrl_get_display_prompt rl_get_point rl_get_promptrl_in_search_mode rl_set_promptrl_type rl_warning vt100_support)Settableget_defining_class get_typesstrip_doc_annotationssuggest_similarfilestyle)readlinerl_force_redisplay) readline_librl_basic_quote_charactersceZdZdZddZdS)_SavedReadlineSettingszRreadline settings that are backed up when switching between readline environments.returnNc0d|_d|_d|_dS)N) completerdelims basic_quotesselfs a/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/cmd2/cmd2.py__init__z_SavedReadlineSettings.__init__s *.rdN__name__ __module__ __qualname____doc__rmrnrlrcrcs.\\//////rnrcceZdZdZddZdS) _SavedCmd2EnvzWcmd2 environment settings that are backed up when entering an interactive Python shell.rdNcHt|_d|_g|_dSN)rcreadline_settingsreadline_modulehistoryrjs rlrmz_SavedCmd2Env.__init__s#!7!9!926"$ rnrorprurnrlrwrws.aa%%%%%%rnrwDisabledCommandcommand_function help_functioncompleter_functionCmdczeZdZdZd dZededefdZdede fd Z dede j dzfd Z deddfd ZdS) _CommandParserszCreate and store all command method argument parsers for a given Cmd instance. Parser creation and retrieval are accomplished through the get() method. cmdrrdNc"||_i|_dSry)_cmd_parsers)rkrs rlrmz_CommandParsers.__init__s =? rncommand_methodcH |jd|jS#t$rYdSwxYw)zQReturn the fully qualified name of a method or None if a method wasn't passed in..rf)rrrsAttributeError)rs rl_fully_qualified_namez%_CommandParsers._fully_qualified_namesC $/OO.2MOO O   22 s  !!cJ||}t|S)zReturn whether a given method's parser is in self. If the parser does not yet exist, it will be created if applicable. This is basically for checking if a method is argarse-based. )getbool)rkrparsers rl __contains__z_CommandParsers.__contains__s! .))F||rnc||}|sdS||jvr|jtsdS|jt td}t |tjd}|dS|j |p|j }|j |||}|j |j rt|j |_ ||j|<|j|S)zReturn a given method's parser or None if the method is not argparse-based. If the parser does not yet exist, it will be created. N)rrrq startswithr.lengetattrr CMD_ATTR_ARGPARSERrfind_commandset_for_command _build_parser descriptionrtrXr)rkrfull_method_namecommandparser_builderparentrs rlrz_CommandParsers.gets   55nEE 4 4= 0 0!*556IJJ t$-c2E.F.F.H.HIG$^Y5QSWXXN%tY::7CCPtyFY,,V^WMMF!)n.D)%:>;Q%R%R".4DM* +}  !1222rncV||}||jvr |j|=dSdS)z,Remove a given method's parser if it exists.N)rr)rkrrs rlremovez_CommandParsers.removes<55nEE t} , , ./// - ,rn)rrrdN)rqrrrsrtrm staticmethodr+strrrrargparseArgumentParserrrrurnrlrrs ????kc\;43+3(2ID2P3333:0[0T000000rnrc,jeZdZUdZejZejZ ej Z gZ e eeed<dZ dQddddddd dd dddddd ddd d ed edzd edzdedededededededeedzdedeedzdeedzdeeefdzdeedzdededededdf*d Zdd!d"eed#edeefd$Zd%ededzfd&ZdRd'Zd(eddfd)Zd*ed+e j!e"ge j!fze#ze$zd,ede j!fd-Z%dSd.ed/e&d0eddfd1Z'd2ed3e(ddfd4Z)d2ed5e"d6ddfd7Z*d(eddfd8Z+d(eddfd9Z,d(e-edfddfd:Z.d(e-edfddfd;Z/e0defd<Z1e1j2d=eddfd>Z1e0de3ee4ffd?Z5d@e4ddfdAZ6dBeddfdCZ7dRdDZ8e0de9j:fdEZ;e;j2dFe9j:ddfdGZ;defdHZedNe?dOedPedQe@dzdRedSedTedUedVeAdzdWe?ddfdXZBdJdKdd dddddLdNe?dOedPedQe@dzdRedSedTedUedVeAdzdWe?ddfdYZCdJdKeDjEd dddddLdNe?dOedPedQe@dzdRedSedTedUedVeAdzdWe?ddfdZZFdJdKd ddddd[dNe?dOedPedRedSedTedUedVeAdzdWe?ddfd\ZGdJdKd ddddd[dNe?dOedPedRedSedTedUedVeAdzdWe?ddfd]ZHd^eIdWe?ddfd_ZJdJdKdd dddddLdNe?dOedPedQe@dzdRedSedTedUedVeAdzdWe?ddfd`ZKdJdKddd ddddda dNe?dOedPedQe@dzdbedRedSedTedUedVeAdzdWe?ddfdcZLdRddZMdeedfedgedeNeeeeffdhZOdiedeedfedgedjeedeef dkZPdiedeedfedgedjeedledeefdmZQddndiedeedfedgedoeeeee(zfdpdeeze(zdeefdqZRddndiedeedfedgedre3eeee(zfdpeee(zdzdeefdsZSddtdiedeedfedgedue"egefdzdeef dvZTddwdiedeedfedgedxedeef dyZUdiedeedfedgedze(deef d{ZVeWd|eedeNeeeffd}ZXd~edeededdfdZYdeeddfdZZeWde j!dee[j\fdZ] dTdiedeedfedgedej^dzddf dZ_dTdiededej^dzdedzfdZ`defdZadefdZbe0deeeffdZcdeefdZddeefdZedeefdZfdeegfdZhdeegfdZideegfdZjdeefdZkdeefdZldedemdzddfdZndedemdzddfdZodRdZpdeqezdeqfdZrdedeqezdefdZsdRdZtdRdZudeedeNeeeffdZvd dddddeedededededzdef dZwdedeqdzdefdZxd dddeeyeezdededefdZzdddeededzdeqfdZ{dddeededzdeqfdZ|deqdedzfdZ}deqdej~fdZdeqdej~ddfdZdede&dzfdZd ddeqezdedefdZdeqdedzfdZdeedeefdZdededzfdZdejjdddddddedeedzdejdedee?dzdedzde(dzde j!dzdefdÄZdedefdĄZdefdńZdeddfdDŽZdRdȄZeWdefdɄZeed ʦde jddfd̄Zedefd̈́ZeddedЬѦde jddfd҄ZedefdӄZeddedլѦde jddfdքZedefdׄZedded٬Ѧde jddfdڄZdiedeedfedgedeef dۄZeWdefd܄Zeed ʦde jddfd݄ZedefdބZeddedѦde jddfdZedefdZeddedѦde jddfdZedefdZeddedѦde jddfdZdiedeedfedgedeef dZdiedeedfedgedeeeefdeef dZdeNeeeefeeeeeeffdZedefdZeede jddfdZdedeedzdededdf dZdedeededdfdZdUdeedzdedefdZdUdeedzdeddfdZeWdefdZeede jddfdZeWdefdZeede jdedzfdZeWdefdZeede jdedzfdZdVdeeezeeNe?edzfzdede?fdZedefdZdiedeedfedgedeeeefdeef dZedefdZeed ʦde jddfdZedefdZeed ʦde jddfdZeWdRdZd edefd Zd eddfd Zdd dedzdedzfdZeWdefdZeede jdedzfdZedefdZeeæde jdedzfdZeWdefdZeeŦde jdedzfdZedefdZeeǦde jdedzfdZde jddfdZɐdeddfdZʐdRdZd ddeeyeezdededdfdZedefdZeeͦde jddfd ZΐdTd!edzddfd"Ze0dedzfd#Zedefd$Zedefd%ZeeҦde jdedzfd&Zedefd'ZeeԦde jdedzfd(ZՐd)eeddfd*Z֐dTd+ed,edzddfd-Zאd,eddfd.ZؐdRd/Zdefd0ZeWd1eddfd2Zdeddfd3Zܐd4eddfd5Zded6eddfd7Zސd4ed6eddfd8Zߐd9e?d6ed:e?ddfd;ZdSdedefd<ZdRd=Zed>e"d?e?fd@eddfdAZed>e"gdfddfdBZd>e"gdfddfdCZd>e"gdfddfdDZed>e"ejgejfddfdEZd>e"ejgejfddfdFZedGZed>e"egefdHeeddfdIZd>e"ejgejfddfdJZd>e"ejgejfddfdKZed>e"ejgejfddfdLZd>e"ejgejfddfdMZdNe"d?e?fdOe-eddfdedzfdPZdS(WraIAn easy but powerful framework for writing line-oriented command interpreters. Extends the Python Standard Library's cmd package by adding a lot of useful features to the out of the box configuration. Line-oriented command interpreters are often useful for test harnesses, internal tools, and rapid prototypes. testfilesz(Cmd) tabNrfiFT)persistent_history_filepersistent_history_lengthstartup_scriptsilence_startup_script include_py include_ipyallow_cli_argstranscript_filesallow_redirectionmultiline_commands terminators shortcuts command_setsauto_load_commandsallow_clipboardsuggest_similar_commandintro completekeystdinstdoutrrrrrrrrrrrrrrrrrrdc |st|dd| st|dd|tj|_||_d|_|||_ntj|_|||_ ntj |_ ||_ d|_ | |_ d|_ d|_d|_tj|_d|_d|_d|_d|_d|_i|_d|_t3|_i|_|d|_d|_dd g|_d |_ ||_!|"|dd g|_#i|_$g|_%d |_&i|_'d|_(tS|| | |_*d|_+g|_,t[j.|_/d|_0d|_1d|_2d |_3d|_4d |_5d|_6d|_7d|_8d|_9d|_:d|_;d |_<g|_=d|_>tj?@dsx|jAr_ ddlB}ddlC}|D|jE|_>n$#t|jG|jHf$r d|_>YnwxYw|rtjJKtjJL|}tjJM|rRdtjO|}|r|dtjQdtjRz }|j=S|d|_T| rotjV}|Wdddd|X\}}|jYr||_Tn&|r|j=Z|n | r| |_Ttj?@drdx|_[|_\nd|_[d |_\||_]d|_^tj`|_ai|_bi|_ctjd|_ed|_fd|_gd |_hd |_ig|_jg|_kd|_ld|_mt||_o|p||r|D]}|q||r|r|sD]6}|j*t|\}}|std!|d"|7||_vd#|_wd|_xdS)$aEasy but powerful framework for writing line-oriented command interpreters, extends Python's cmd package. :param completekey: readline name of a completion key, default to Tab :param stdin: alternate input file object, if not specified, sys.stdin is used :param stdout: alternate output file object, if not specified, sys.stdout is used :param persistent_history_file: file path to load a persistent cmd2 command history from :param persistent_history_length: max number of history items to write to the persistent history file :param startup_script: file path to a script to execute at startup :param silence_startup_script: if ``True``, then the startup script's output will be suppressed. Anything written to stderr will still display. :param include_py: should the "py" command be included for an embedded Python shell :param include_ipy: should the "ipy" command be included for an embedded IPython shell :param allow_cli_args: if ``True``, then [cmd2.Cmd.__init__][] will process command line arguments as either commands to be run or, if ``-t`` or ``--test`` are given, transcript files to run. This should be set to ``False`` if your application parses its own command line arguments. :param transcript_files: pass a list of transcript files to be run on initialization. This allows running transcript tests when ``allow_cli_args`` is ``False``. If ``allow_cli_args`` is ``True`` this parameter is ignored. :param allow_redirection: If ``False``, prevent output redirection and piping to shell commands. This parameter prevents redirection and piping, but does not alter parsing behavior. A user can still type redirection and piping tokens, and they will be parsed as such but they won't do anything. :param multiline_commands: list of commands allowed to accept multi-line input :param terminators: list of characters that terminate a command. These are mainly intended for terminating multiline commands, but will also terminate single-line commands. If not supplied, the default is a semicolon. If your app only contains single-line commands and you want terminators to be treated as literals by the parser, then set this to an empty list. :param shortcuts: dictionary containing shortcuts for commands. If not supplied, then defaults to constants.DEFAULT_SHORTCUTS. If you do not want any shortcuts, pass an empty dictionary. :param command_sets: Provide CommandSet instances to load during cmd2 initialization. This allows CommandSets with custom constructor parameters to be loaded. This also allows the a set of CommandSets to be provided when `auto_load_commands` is set to False :param auto_load_commands: If True, cmd2 will check for all subclasses of `CommandSet` that are currently loaded by Python and automatically instantiate and register all commands. If False, CommandSets must be manually installed with `register_command_set`. :param allow_clipboard: If False, cmd2 will disable clipboard interactions :param suggest_similar_command: If ``True``, ``cmd2`` will attempt to suggest the most similar command when the user types a command that does not exist. Default: ``False``. "param intro: Intro banner to print when starting the application. do_pyNdo_ipyTF2z> eof_relative_run_scriptrfr|app)rrru─zDocumented CommandszMiscellaneous Help TopicszUndocumented CommandszUncategorized Commandsz No help on {}z0{} is not a recognized command, alias, or macro.winrz run_script  -tz--test store_truez1Test against transcript(s) in FILE (wildcards OK)actionhelpmorez less -RXFz less -SRXFInvalid command name '': zDid you mean {}?)ysetattr_initialize_plugin_systemrDEFAULT_PROMPTpromptr use_rawinputrsysrrdefault_to_shellralways_show_hintdebugechoDEFAULT_EDITOReditorfeedback_to_outputquietscripts_add_to_historytimingmax_completion_items _settables_always_prefix_settablesset_installed_command_sets_cmd_to_command_setsbuild_settablescontinuation_prompt self_in_pyhidden_commandsr_persistent_history_length_initialize_historyexclude_from_historymacros _py_historypy_bridge_name py_locals_in_pyrBstatement_parser last_result _script_dirr" ContextFlagsigint_protection_cur_pipe_proc_reader _redirecting_at_continuation_prompt_multiline_in_progressruler doc_leader doc_header misc_header undoc_headerdefault_category help_error default_errorbroken_pipe_warning_startup_commands_initial_termios_settingsplatformrisattyiotermios tcgetattrfileno ImportErrorUnsupportedOperationerrorospathabspath expanduserexistssuquoter REDIRECTION_OUTPUTdevnullappend_transcript_filesrDEFAULT_ARGUMENT_PARSER add_argumentparse_known_argstestextendpager pager_chopr exit_code threadingRLock terminal_lockdisabled_commandsdisabled_categoriesALPHABETICAL_SORT_KEYdefault_sort_keyallow_appended_spaceallow_closing_quotecompletion_hintformatted_completionscompletion_matchesdisplay_matchesmatches_delimitedmatches_sortedr_command_parsers_register_subcommandsregister_command_set_autoload_commandsget_all_commandsis_valid_command ValueErrorrdefault_suggestion_messagecurrent_command)rkrrrrrrrrrrrrrrrrrrrrrr script_cmdrcalloptscallargs command_setcur_cmdvaliderrmsgs rlrmz Cmd.__init__:sBX ) D'4 ( ( ( * D(D ) ) ) &&((((     DJJDJ   DKK*DK'!&!2!&  ( "' &*# *,!02.3%9<$;=! )-  !&'=>(*$*C'   !8999&+I$6!)+ ')$*, 1@#8JV_2 2 2  !%')5:4E4G4G?C""(-$')# 074!9*P$& -/*.&|&&u-- 6$*2C2C2E2E 6 6 181B1B4:CTCTCVCV1W1W..!8'-H 6 6 615... 6  :W__RW-?-?-O-OPPNw~~n-- :E28N+C+CEE )R"Qi&B"Q"QRZ"Q"QQJ&--j99948  6$<>>F   h|J}  ~ ~ ~!'!8!8!:!: Hh} 8)1&& 8&--h777  6%5D " < " "5 ) ) ++1 1DJ%DJ*DO / '_..>@46 7:6O%)!$( %'+-".0+-"' %*2A1F1F ""4(((  7+ 7 7 ))+6666  &  # # % % %,,.. P PG 1BB7KKME6 P !N'!N!Nf!N!NOOO P(?$*<'26s/9J))K  K )subclass_matchcommandset_typer>c.fd|jDS)aFind all CommandSets that match the provided CommandSet type. By default, locates a CommandSet that is an exact type match but may optionally return all CommandSets that are sub-classes of the provided type :param commandset_type: CommandSet sub-class type to search for :param subclass_match: If True, return all sub-classes of provided type, otherwise only search for exact match :return: Matching CommandSets c^g|])}t|kst|'|*Sru)type isinstance).0cmdsetr?r>s rl z(Cmd.find_commandsets..sJ   F||..>.jQWYhFiFi. ...rn)r)rkr?r>s ``rlfind_commandsetszCmd.find_commandsetss7     6    rn command_namec6|j|S)zFind the CommandSet that registered the command name. :param command_name: command name to search :return: CommandSet that provided the command )rr)rkrHs rlrzCmd.find_commandset_for_commands (,,\:::rnctj}djDdtttddffd |dS)z!Load modular command definitions.c,g|]}t|SrurBrDr:s rlrFz*Cmd._autoload_commands.. $g$g$g;T+%6%6$g$g$grncommandset_typesrdNc|D]}|}|r |$tj|j}|vs@t |jdks(d|jvs|}|dS)Nrrk)__subclasses__inspect signaturermr parametersr0)rO cmdset_type subclassesinit_sigrEexisting_commandset_typesload_commandset_by_typerks rlrYz7Cmd._autoload_commands..load_commandset_by_types/ : : (7799  :++J7777&01EFFH#'@@@x233q88!)<<.rNrnz CommandSet z is already installedz,CommandSet settable prefix must not be emptyrDuplicate settable: zDuplicate settable z is already registered.ct|to.t|do|jt SNrqrCrhasattrrqrr.meths rlz*Cmd.register_command_set..AtX..Fj11F 001DEErn predicateNc$i|] \}}|u || Sruru)rDkeyvalrEs rl z,Cmd.register_command_set..1s+,},},}(#sknv|k|k|S#k|k|k|rn)-rrBr5rq settablesalways_prefix_settablessettable_prefixstrip on_registerrrZtuplerrr rR getmembersrr-rr._install_command_functionrr/_install_completer_functionr0_install_help_functionrrbr CMD_ATTR_HELP_CATEGORYr" categorizer#disable_commandaddr/ on_registered Exception on_unregisterdelattrrvaluesitemson_unregistered)rkrErX all_settablesrj prefixed_namemethodsrinstalled_attributes cmd_func_namerrcompleter_func_name cmd_completerhelp_func_namecmd_helpcommand_categorymessage_to_printattribs ` rlr0zCmd.register_command_sets? %h$g$Jf$g$g$g! <<4 4 4-md6ll>S.SVm.mnn n  ' i)//11 b12`aaa' T T#)#9 A AC A A  M1156RS6R6RSSS2 T ' i i-''56gC6g6g6ghhh( 4    sHS#X../ 0        #6+KTRR!+ 18 D D- ~',?(@(@(B(BC..}ndSYllNcddd$++M:::&;g&E# '0CT J J  ,44WmLLL(//0CDDD!1G!;"6>4@@'//BBB(//???5;)'2#GGNIDd,e,eG$^5EFFF$+>9;[]a#b#b #t'???'+'?@P'Q$((2BCCC  ( , ,V 4 4 4  & &v . . .  " " " " "     " " ". & &f%%%%555,33F;;;299;;;;,},},},}dF_FeFeFgFg,},},})  " " $ $ $  sF9L B1N=rrprogct|tr|}nt|tr||j}nht |r |}nNt|t jrtj |}ntdt|tj |||S)aBuild argument parser for a command/subcommand. :param parent: CommandParent object which owns the command using the parser. When parser_builder is a classmethod, this function passes parent's class to it. :param parser_builder: means used to build the parser :param prog: prog value to set in new parser :return: new parser :raises TypeError: if parser_builder is invalid type z!Invalid type for parser_builder: )rCr__func__ classmethod __class__callablerrcopydeepcopy TypeErrorrBrset_parser_prog)rkrrrrs rlrzCmd._build_parser5s& nl 3 3 X#,,..FF  4 4 X#,,V-=>>FF n % % X#^%%FF (? @ @ X]>22FFV^@T@TVVWW W'555 rncommand_func_namercontextc|tst|dtd|jtst|jdtd|t td}t ||rtd|d|d|j|\}}|std|d|||jvr!| d |d |j|=||j vr!| d |d |j |=t|||dS) aeInstall a new command function into the CLI. :param command_func_name: name of command function to add This points to the command method and may differ from the method's name if it's being used as a synonym. (e.g. do_exit = do_quit) :param command_method: the actual command method which runs when the command function is called :param context: optional info to provide in error message. (e.g. class this function belongs to) :raises CommandSetRegistrationError: if the command function fails to install z does not begin with ''NAttribute already exists: z ()rrzDeleting alias 'z/' because it shares its name with a new commandzDeleting macro ') rr.r5rqrrbrr3aliasespwarningrr)rkrrrrr<r=s rlrtzCmd._install_command_functionWs!++,?@@ r-1B.p.pZm.p.p.pqq q&112EFF x-1H.v.v`s.v.v.vww w#C(;$<$<$>$>? 4* + + l-.jK\.j.j`g.j.j.jkk k->>wGG v ]-.[w.[.[SY.[.[\\ \ dl " " MMeWeee f f f W% dk ! ! MMeWeee f f f G$'88888rncmd_namerct|z}t||rtd|t|||dSNr)r/rbr5r)rkrrrs rlruzCmd._install_completer_functionsR3h> 4, - - b-.`K^.`.`aa a)=99999rnr).Nct|z}t||rtd|t|||dSr)r0rbr5r)rkrrrs rlrvzCmd._install_help_functionsN)H4 4 ( ( ]-.[>.[.[\\ \nh/////rnc||jvrm|||||t j|d}|D]\}}|t td}||jvr| |||j vr|j |=||j kr|j |t|t|zrt!|t|zt|t"|zrt!|t"|zt!||||j |dSdS)zuUninstalls a CommandSet and unloads all associated commands. :param cmdset: CommandSet to uninstall ct|to.t|do|jt Sr`rarcs rlrez,Cmd.unregister_command_set..rfrnrgN)r_check_uninstallabler}_unregister_subcommandsrRrsrr.r"enable_commandrrqr.rrbr/r~r0r)rkrErrrrs rlunregister_command_setzCmd.unregister_command_sets T1 1 1  % %f - - -  " " "  ( ( 0 0 0D"2W"<===m,,,,  " " $ $ $  ( / / 7 7 7 7 7M 2 1rncdtjddffd tjd}|D]7\}}||jkr'|j|}| |8dS)Nrrdc&t}|jD]x}t|tjr\|jD]?}t|tj d}|||krtd|@dSydS)NzACannot uninstall CommandSet when another CommandSet depends on it) id_actionsrCr_SubParsersActionchoicesrrr PARSER_ATTR_COMMANDSET_IDr5)r cmdset_idr subparserattached_cmdset_idcheck_parser_uninstallablerEs rlrz.check_parser_uninstallables6 I /  fh&@AA%+^%:%:%<%<>> -4Y @cei-j-j*-9>PT]>]>]"= c##329====EE  rnct|to.t|do|jt Sr`rarcs rlrez*Cmd._check_uninstallable..sA4**BD*--BM,,-@AArnrg)rrrRrsrqr.r)rkrErrrcommand_parserrs ` @rlrzCmd._check_uninstallables x/F 4       9@8J 9 9 9 .5 ? ? )M> 777!%!6!:!:>!J!J!-..~>>>  ? ?rncD||us||jvstdtj|d}|D]g\}}t |t j}t |t j}t |t j}|j |d\}} |std|d| | } | d} | d d } | |j vr|j | j } n|| } | td | d ||j| }|td | d |dt"jdt&t(dt"jffd || }|||| d|}|j |jrt1|j|_t j|i}|jdi|t7|t jt;||jD]t}t?|t"j rXt |t j!i}|j"|fi|||j#|<|dgD] }||j#|< nuid S)zRegister subcommands with their base command. :param cmdset: CommandSet or cmd2.Cmd subclass containing subcommands z;Cannot register subcommands with an unregistered CommandSetct|toMt|tjo3t|tjot|tjSryrCrrbr SUBCMD_ATTR_NAMESUBCMD_ATTR_COMMANDrrcs rlrez+Cmd._register_subcommands..X4**@D)"<==@D)"?@@@D)">?? rnrgT) is_subcommandz Subcommand z is not valid: rrNCould not find command '' needed by subcommand: &Could not find argparser for command 'r subcmd_namesrdc|s|S|d}|jD]S}t|tjr7|jD]\}}||kr||ccSnTtd|d)NrzCould not find subcommand 'r)poprrCrrrrr5)rr cur_subcmd sub_action choice_namechoicefind_subcommands rlrz2Cmd._register_subcommands..find_subcommand s#"!M)--a00 "(/J!*h.HII3=3E3K3K3M3MMM/K*j88'6v|'L'L L L L L L 9  22YPV2Y2Y2YZZZrnrrru)$rr5rRrsrr rrrrr3splitr"rcmd_funcr.rrrrZrrrrtrXNS_ATTR_SUBCMD_HANDLER set_defaultsrrrrrCrSUBCMD_ATTR_ADD_PARSER_KWARGS add_parser_name_parser_map)rkrEr _method_namemethodsubcommand_namefull_command_namesubcmd_parser_buildersubcommand_validr=command_tokensrHsubcommand_names command_funcr target_parser subcmd_parserdefaultsradd_parser_kwargsaliasrs @rlr/zCmd._register_subcommandssV $&D,H"H"H-.kll l$    %,E E  L&#*693M#N#NO%,VY5R%S%S $+FI4P$Q$Q !'+'<'M'Momq'M'r'r $ f# j12h2h2h`f2h2hiii.4466N)!,L-abb1 t555#5lCT #}}\:: #12{\2{2{sy2{2{|||!266|DDN%1k\kkcikk [(? [tTWy []e]t [ [ [ [ [ [,ON.@rrnrgNrrr)rr5rRrsrr rrr"rrr.rrrCrr remove_parser) rkrErrrrrHrrrs rlrzCmd._unregister_subcommands5sz $&D,H"H"H-.mnn n$    %,   L&%fi.HIIO"69+HIILt555#5lCT #}}\:: #22{\2{2{sy2{2{|||!266|DDN%2k\kkcikk)1  fh&@AA((999E/  rnc|jS)zFlags whether CommandSet settable values should always be prefixed. :return: True if CommandSet settable values will always be prefixed. False if not. )rrjs rlrnzCmd.always_prefix_settablesds ,,rn new_valuec|js0|r.|jD]&}|jstd|jjd'||_dS)aSet whether CommandSet settable values should always be prefixed. :param new_value: True if CommandSet settable values should always be prefixed. False if not. :raises ValueError: If a registered CommandSet does not have a defined prefix z+Cannot force settable prefixes. CommandSet z) does not have a settable prefix defined.N)rrror4rrq)rkrcmd_sets rlrnzCmd.always_prefix_settableslsv,  7  .$?gFWF`??? )2%%%rnct|j}|jD]?}|j}|D]!\}}|jr|||jd|<|||<"@|S)zGet all available user-settable attributes. This includes settables defined in installed CommandSets. :return: Mapping from attribute-name to Settable of all user-settable attributes from r)dictrrrmrrnro)rkrrcmdset_settables settable_namesettables rlrmz Cmd.settables|s T_-- 3 < .get_allow_style_choices..s$>>>CHNN$$>>>rn)ru AllowStyle)rs rlget_allow_style_choicesz4Cmd.build_settables..get_allow_style_choicess>> >>> >rnvaluec  tj|S#t$rL}t dtjjdtjjdtjjd|d}~wwxYw)z-Convert a string value into an ru.AllowStyle.zmust be , z, or z (case-insensitive)N)rrupperrr4ALWAYSNEVERTERMINAL)rexs rlallow_style_typez-Cmd.build_settables..allow_style_types }U[[]]33    |r}3||r}7J||QSQ^Qg||| s#& A<AA77A< allow_stylez9Allow ANSI text style sequences in output (valid values: rr)choices_providerrzBDisplay tab completion hint even when completion suggestions printrz Show full traceback on exceptionrzEcho command issued into outputrzProgram used by 'edit'rz,Include nonessentials in '|' and '>' resultsrzBMaximum number of CompletionItems to display during tab completionrz!Don't print nonessential feedbackrz-Scripts and pyscripts add commands to historyrzReport execution timesN)rrZrrrrrUrrrrr%rint)rkrrs rlrzCmd.build_settabless8 ?s ?tCy ? ? ? ? C BM       \='\\+-=+>\\BD-BX\\\!%&9;R!S!S       '/suy z z    (7D2TVZ[[\\\ (641RTXYYZZZ (8S2JDQQRRR (#7?mosttuuu  +S2vx| } }    (7D2UW[\\]]] (#;TCrtxyyzzz (8T3KTRRSSSSSrnctjS)zFRead-only property needed to support do_set when it reads allow_style.r ALLOW_STYLErjs rlrzCmd.allow_styles ~rnnew_valc|t_dS)zESetter property needed to support do_set when it updates allow_style.Nr)rkr s rlrzCmd.allow_styles!rncb|jo(t|jottjkS)z+Return whether tab completion is supported.)rrrrRrKNONErjs rl_completion_supportedzCmd._completion_supporteds' VT$*:%;%;V6;@VVrnc4tj|jS)a Read-only property to get the visible prompt with any ANSI style sequences stripped. Used by transcript testing to make it easier and more reliable when users are doing things like coloring the prompt. :return: the stripped prompt )r strip_stylerrjs rlvisible_promptzCmd.visible_prompts~dk***rnr sependr] soft_wrapemojimarkup highlightrich_print_kwargsr[objectsrrr]rrrrrkwargsc  t|j| |||||||d| | nidS#t$rS|jrE|tjkr8t tj|jYdSYdSYdSwxYw)a Print objects to a given file stream. This method is configured for general-purpose printing. By default, it enables soft wrap and disables Rich's automatic detection for markup, emoji, and highlighting. These defaults can be overridden by passing explicit keyword arguments. :param file: file stream being written to :param objects: objects to print :param sep: string to write between printed text. Defaults to " ". :param end: string to write at end of printed text. Defaults to a newline. :param style: optional style to apply to output :param soft_wrap: Enable soft wrap mode. Defaults to True. If True, text that doesn't fit will run on to the following line, just like with print(). This is useful for raw text and logs. If False, Rich wraps text to fit the terminal width. Set this to False when printing structured Renderables like Tables, Panels, or Columns to ensure they render as expected. For example, when soft_wrap is True Panels truncate text which is wider than the terminal. :param emoji: If True, Rich will replace emoji codes (e.g., :smiley:) with their corresponding Unicode characters. Defaults to False. :param markup: If True, Rich will interpret strings with tags (e.g., [bold]hello[/bold]) as styled output. Defaults to False. :param highlight: If True, Rich will automatically apply highlighting to elements within strings, such as common Python data types like numbers, booleans, or None. This is particularly useful when pretty printing objects like lists and dictionaries to display them in color. Defaults to False. :param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print(). :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this method and still call `super()` without encountering unexpected keyword argument errors. These arguments are not passed to Rich's Console.print(). See the Rich documentation for more details on emoji codes, markup tags, and highlighting. rZrrr]rrrrN)rDprintBrokenPipeErrorrrstderrrF) rkr[rrr]rrrrrrrs rlprint_toz Cmd.print_tos` T ,O & & & ,##  ):(E$$2      T T T ' TDCJ,>,>" 33399$:RSSSSSS T T T,>,>,>  Ts'+ABBc @|j|jg| R||||||||ddS)z|Print objects to self.stdout. For details on the parameters, refer to the `print_to` method documentation. rN)r!r rkrrr]rrrrrrrs rlpoutputz Cmd.poutput)sZ"  K  / rnc J|jtjg| R||||||||ddS)zPrint objects to sys.stderr. :param style: optional style to apply to output. Defaults to Cmd2Style.ERROR. For details on the other parameters, refer to the `print_to` method documentation. rN)r!rr r#s rlperrorz Cmd.perrorGsZ&  J  / rn)rrrrrrrc B|j|||tj|||||ddS)zWrap poutput, but apply Cmd2Style.SUCCESS. For details on the parameters, refer to the `print_to` method documentation. rN)r$rHSUCCESS rkrrrrrrrrrs rlpsuccessz Cmd.psuccessgsG  #/ rnc B|j|||tj|||||ddS)zWrap perror, but apply Cmd2Style.WARNING. For details on the parameters, refer to the `print_to` method documentation. rN)r&rHWARNINGr)s rlrz Cmd.pwarningsG  #/ rn exceptionc ttj}|jrVtjdkr?t ddddd}|||dSt|}|rDt}tj t|j ddf||}n$tt|j d }|jsLd |j vrCtj d d tjfd tjf}|||||dS)aPrint an exception to sys.stderr. If `debug` is true, a full traceback is also printed, if one exists. :param exception: the exception to be printed. :param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this method and still call `super()` without encountering unexpected keyword argument errors. rZ)NNNNTr)width code_width show_locals max_frames word_wrap: ztraceback.exc_typer\r z5To enable full traceback, run the following command: zset debug true)rErr rexc_inforrrrrassemblerBrqrmrHr, COMMAND_LINEr) rkr-rconsole traceback exception_str highlighter final_msghelp_msgs rlpexceptz Cmd.pexceptst'CJ777 : #,..,>>>!  I MM) $ $ $ MMOOO FI  X)++K OO,0002FG M**II Y 8:BVWWWIz 'g77}H)J[\!9#9:H   X & & & i    rnc z|js3|jr|j| ||||||||ddS|j| ||||||||ddSdS)aPrint nonessential feedback. The output can be silenced with the `quiet` setting and its inclusion in redirected output is controlled by the `feedback_to_output` setting. For details on the parameters, refer to the `print_to` method documentation. rN)rrr$r&r#s rl pfeedbackz Cmd.pfeedbacks(z &  '!'&7       '!'&7        rn) rrr]choprrrrrrBc ^|joX|jo?tjdp t jddu} |j p'| p| } | r| r|rd}t|j}| 5}|j| |||||||d| | nidddn #1swxYwY|dd}|j5d dl}||r|jn|jd|j|j }||ddddS#1swxYwYdS|j| |||||||| d dS) aPrint output using a pager. A pager is used when the terminal is interactive and may exit immediately if the output fits on the screen. A pager is not used inside a script (Python or text) or when output is redirected or piped, and in these cases, output is sent to `poutput`. :param chop: True -> causes lines longer than the screen width to be chopped (truncated) rather than wrapped - truncated text is still accessible by scrolling with the right & left arrow keys - chopping is ideal for displaying wide tabular data as is done in utilities like pgcli False -> causes lines longer than the screen width to wrap to the next line - wrapping is ideal when you want to keep users from having to use horizontal scrolling WARNING: On Windows, the text always wraps regardless of what the chop argument is set to :param soft_wrap: Enable soft wrap mode. If True, lines of text will not be word-wrapped or cropped to fit the terminal width. Defaults to True. Note: If chop is True and a pager is used, soft_wrap is automatically set to True to prevent wrapping and allow for horizontal scrolling. For details on the other parameters, refer to the `print_to` method documentation. rTERMNTrZrutf-8replacer)shellrrr)rrrrrrr environrr in_pyscript in_scriptrDcapturerencoder subprocessPopenrrPIPE communicater$)rkrrr]rBrrrrrrrfunctional_terminal can_blockr9rK output_bytesrM pipe_procs rlppagedz Cmd.ppagedsJ J     W ""$$ W((//U2:>>&3I3IQU3U *Td.>.>.@.@TDNNDTDTU  - 9-  ! &4;777G"" g '!'  ->,I((r                  #;;==//CCL' 4 4!!!!&,,'+;DOO$/; - %%l333 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 DL##"3      s%C::C>C>4A F  FFc:d|_d|_d|_d|_g|_g|_d|_d|_ttj krtj |j dSttjkr|jtjj_dSdS)zkReset tab completion settings. Needs to be called each time readline runs tab completion. TrfFN)r&r'r(r)r*r+r,r-rRrKGNUr^#set_completion_display_matches_hook_display_matches_gnu_readline PYREADLINE_display_matches_pyreadlinerlmode_display_completionsrjs rl_reset_completion_defaultszCmd._reset_completion_defaultsbs %)!#' !%'""$!!&# fj  89[ \ \ \ \ \ ) ) )484THK  1 1 1* )rnlinebegidxendidxcd}gtj}|d|}|} t|d|}|s||kr|dn]#t$rO} t | dkr)|r'|d}|dd}|d|}||z }|dz}n ggfcYd} ~ SYd} ~ nd} ~ wwxYw|j|} d| D} |r| ddd| d<| | fS) aeGet all tokens through the one being completed, used by tab completion functions. :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :return: A 2 item tuple where the items are **On Success** - tokens: list of unquoted tokens - this is generally the list needed for tab completion functions - raw_tokens: list of tokens with any quotes preserved = this can be used to know if a token was quoted or is missing a closing quote Both lists are guaranteed to have at least 1 item. The last item in both lists is the token being tab completed **On Failure** - Two empty lists rfNTzNo closing quotationrrc6g|]}tj|Sru)r strip_quotes)rD cur_tokens rlrFz-Cmd.tokens_for_completion..s"III"/),,IIIrn)r QUOTESrCrr4rrsplit_on_punctuation) rkr`rarbunclosed_quote quotes_to_trytmp_line tmp_endidxinitial_tokensr raw_tokenstokenss rltokens_for_completionzCmd.tokens_for_completionuse +)*+ =  " "!,Xkzk-B!C!C&.&J*>*>"))"--- " " "r774444%21%5N$1!""$5M#GVG}H.H!'!JJr6MMMMMM JJJJ " "4*??OO JIjIII  1'^CRC0JrNz!!s4A B-?B(B-(B-text match_againstc fd|DS)atTab completion function that matches against a list of strings without considering line contents or cursor position. The args required by this function are defined in the header of Python's cmd.py. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param match_against: the strings being matched against :return: a list of possible tab completions c>g|]}||Sru)r)rD cur_matchrrs rlrFz&Cmd.basic_complete..s-WWWiI~. 3 3 5 566#N$9$9$;$;<<rn)all_else flag_dictrc0||||\}}|sgSg} |} t|dkr|d} | |vr|| } t| tr|||||| } nt | r| ||||} | S)a Tab completes based on a particular flag preceding the token being completed. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param flag_dict: dictionary whose structure is the following: `keys` - flags (ex: -c, --create) that result in tab completion for the next argument in the command line `values` - there are two types of values: 1. iterable list of strings to match against (dictionaries, lists, etc.) 2. function that performs tab completion (ex: path_complete) :param all_else: an optional parameter for tab completing any token that isn't preceded by a flag in flag_dict :return: a list of possible tab completions r)rqrrCrrwr) rkrrr`rarbrrrp_completions_matchesrsflags rlflag_based_completezCmd.flag_based_completes4..tVVDD  I   v;;??":Dy  )$  mX . . L"&"5"5dD&&R_"`"`  m $ $ L"/-dFF"K"K ""rn index_dictc.||||\}}|sgSg} t|dz } || |} t| tr|||||| } nt | r| ||||} | S)aTab completes based on a fixed position in the input string. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param index_dict: dictionary whose structure is the following: `keys` - 0-based token indexes into command line that determine which tokens perform tab completion `values` - there are two types of values: 1. iterable list of strings to match against (dictionaries, lists, etc.) 2. function that performs tab completion (ex: path_complete) :param all_else: an optional parameter for tab completing any token that isn't at an index in index_dict :return: a list of possible tab completions r)rqrrrCrrwr) rkrrr`rarbrrrprr}indexrss rlindex_based_completezCmd.index_based_completeKs4..tVVDD  IF a#uh77  mX . . @))$ffmTTGGm $ $ @#mD$??Grn path_filterrcdttffd }d|t|ks.|t|kr||tjjkrdtj}d}dds4tjtjd} d}nddg} | D] } | vrgcS dz} dr~ tjjd } | d kr |Stj | } d | tj nRtj s3tjtj| } d}tj | } fd | D} | rkd_ t| d kr3tj| d rd_d_| jd_t)| D]\}}jtj|tj|rErC| |xxtjjz cc<j|xxtjjz cc<|r9|tjjkr|n|tjjzfd| D} rfd| D} | S)aPerform completion of local file system paths. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param path_filter: optional filter function that determines if a path belongs in the results this function takes a path as its argument and returns True if the path should be kept in the results :return: a list of possible tab completions rdcTg}tjdrltj}tj|r-}r|tjjz }||nddl }| D]p}tj|j rJd|j z}|r+r|tjjz }||q|rd_ d_|S)Nrr~F)rrrr r risdirrrpwdgetpwallpw_dirpw_namer&r') users expanded_pathuserrcur_pwcur_useradd_trailing_sep_if_dirrkrrs rlcomplete_usersz)Cmd.path_complete..complete_userssE |&&u-- 3 " 2 24 8 8 7==//'D., +LL&&& "llnn33Fw}}V]333#&#7#..t44368 (BGK 7!LL222 1-2)+0(LrnFTrf*?rrrgNc*g|]}| |Sruru)rDcrs rlrFz%Cmd.path_complete..s&<<g|]}|ddSrfrrF)rDcur_path to_replaces rlrFz%Cmd.path_complete..s+WWW88++JA>>WWWrnc>g|]}|dS)rr)rDrexpanded_tilde_pathorig_tilde_paths rlrFz%Cmd.path_complete.. s.mmmYa8++,?RSTTmmmrn)rZrrr r rgetcwdr{rfindrdirnameglobr,rr&r'sortr%r- enumerater+rbasename)rkrrr`rarbrrcwd cwd_added search_str wildcardswildcard sep_indexr}rrvrrrrs`` ` @@@@rl path_completezCmd.path_complete|sw,! S ! ! ! ! ! ! ! ! H#( SYY  6CII#5#5$v,"'+:U:U&* #ikk   !bikk377JIIc I%  t##III$Js## ! IIbgk155 ??)>+++ W// ;; #'z z"2&(g&8&8&I&I##W__T** !W\\")++zBB  )J''  "<<<<'<<%> ,1)+0( LLT2L 3 3 3"&D %.g$6$6 ? ? y$++BG,<,/// X$'27;$6$6SSC"'+."s,tATATApXZXabfhjhoXpXprnr)rr r rr"get_exes_in_pathr)rkrrr`rarbrs rlshell_cmd_completezCmd.shell_cmd_complete s{ d Is## 0 4(?(?)$// /!! $4p4p"   rncompfuncc2||||\}}|sgSt|dkrd}d} d} d} d} d} |D]}|tjvrDd}|tjkr| tjkrgcSd} d} nU| tjvs| rgcSd} d} n<|jr5d} d} | tjkrd} n| s| tjtjfvrd} |} | r|||||S| r| ||||S|rgS|||||S)aFirst tab completion function for all commands, called by complete(). It determines if it should tab complete for redirection (|, >, >>) or use the completer function for the current command. :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param compfunc: the completer function for the current command this will be called if we aren't completing for redirection :return: a list of possible tab completions rFNT) rqrr REDIRECTION_TOKENSREDIRECTION_PIPErrREDIRECTION_APPENDrr)rkrrr`rarbrrrohas_redirectionin_pipe in_file_redirdo_shell_completiondo_path_completion prior_tokenrfs rl_redirect_completezCmd._redirect_complete%s 224HH : I z??Q  #OG!M"' !& K'! (! (  <<<&*O!I$>>>&)*DDD#%III"&(- ')*FFF-F#%III"'(, +2*/').&"i&@@@.2++ 2KI4PR[Rn3o$o$o-1*' " K..tT66JJJ! F))$ffEEE  xdFF333rnmatches_to_displaycttjkrdnttjkrdn|dfSfd|Dt fS)a}Add padding to the matches being displayed as tab completion suggestions. The default padding of readline/pyreadine is small and not visually appealing especially if matches have spaces. It appears very squished together. :param matches_to_display: the matches being padded :return: the padded matches and length of padding that was added  z rcg|]}|zSruru)rDrvpaddings rlrFz/Cmd._pad_matches_to_display..sHHH G#HHHrn)rRrKrWrZr)rrs @rl_pad_matches_to_displayzCmd._pad_matches_to_displayvsa fj GG ) ) )GG&q( (HHHH5GHHH#g,,VVrn substitutionr}longest_match_lengthc Rttjkrd}|jr0|jr)d}t jd|jz|jrL|st jdt jd|jzdzn|j r3|j }d}|D]&}tj |}t||}'n|}| |\}}||z }t|d} d|D} tt tdzt#jd t'| zd zz} | | d<| | d d <d| d <t)j| t'| |t-dSdS) aPrint a match list using GNU readline's rl_display_match_list(). :param substitution: the substitution written to the command line :param matches: the tab completion matches to display :param longest_match_length: longest printed length of the matches FTrrrEencodingc0g|]}t|dS)rEr)bytes)rDrvs rlrFz5Cmd._display_matches_gnu_readline..s%"j"j"j)5W#E#E#E"j"j"jrnNrrg)rRrKrWrr(rrwriter)r+r str_widthmaxrrrrZctypesc_char_prr`rl_display_match_listr_) rkrr}r hint_printedrrv cur_lengthpadding_lengthencoded_substitutionencoded_matches strings_arrays rlrYz!Cmd._display_matches_gnu_readlines fj  L$ >)= >#    ()= >#    (E $*$@$@$B$B  !/DNrncustom_settingsc6 d}||j|}|j}|sdS|j}|dds9t |t |z } |d| zz }t |t |kr)t |t |z } || z }|| z }|}||||\} } | sdS|9||jvr |j } nw|| vrt|tj |zd}||} n=||}|dn|j|}||t|tj}||}||}|||}t)j|j|r | ddn | dd|} n|j} n}|jr|t3j|vr|j} nX|j} nP||j}||j|}t)j|j|jr| n| d} d| d}d|rV|dtjvrB|d|d|| d}||kr||||z}|}| ||||| |_!|j!rt3j"|j!|_!t3j"|j#|_#|j#sddl$}|j$|j!|_#sd}tJj&'|j!}|j(rKtJj&'|j#}d|vs |r tSd |j#Drd }n"|r tSd |j!Drd }|r:tSd |j!Drd ndfd|j!D|_!nrfd|j!D|_!t |j!dkr"|j*rr|j!dxxz cc<dSdSdSdSdS)aPerform the actual completion, helper function for complete(). :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :param custom_settings: optional prepopulated completion settings rfNrgrr)rprrFc3K|]}d|vV dSrNrurDmatchs rl z*Cmd._perform_completion.. s'FvFvX]se|FvFvFvFvFvFvrnTc3K|]}d|vV dSrrurs rlrz*Cmd._perform_completion.. s&*]*]E3%<*]*]*]*]*]*]rnc3K|]}d|vV dS)"Nrurs rlrz*Cmd._perform_completion.. s&7j7ju 7j7j7j7j7j7jrnrrcg|]}|zSruru)rDrcompletion_token_quotes rlrFz+Cmd._perform_completion.. s .s.s.sRW/E/M.s.s.srnc>g|]}|ddSrr)rDrtext_to_removes rlrFz+Cmd._perform_completion.. s**u*u*uTY5==Q+O+O*u*u*urn)+rparse_command_onlyrcommand_and_argsisspacerrstriprqrmacro_arg_completer2rr r/rr.rCMD_ATTR_PRESERVE_QUOTESrr functoolspartialcompletecompletedefaultrr"rrrpreserve_quotesrhrfindrr*remove_duplicatesr+rr r rzr,anyr')rkrrr`rarbrr statement expanded_line rstripped_lendiffrprocompleter_func func_attrfunc argparserr rrrgraw_completion_token actual_begidxr add_quoter~display_prefixrrs @@rl_perform_completionzCmd._perform_completions  "-@@FFI'G %6M %--// 5 !$D C ,>,> > }!44 =!!SYY..=))CII5$$!D"77ffMM   F  "$+%%!%!8D113333#D)*IG*SUYZZ (%.NN ==11D(, $:O:S:STX:Y:YI'I,A*1$ 8Z*[*["&"B"B7"K"K*.)J)J9)U)U$2N9d$C$C )2):%.7hz!""~~^defegeg^hry****.)=& 67e6LW6U6U+U+U!%!3!%!5 ">>?UVVN&'=tDDI&."9X+d::^dnrN  *"~"$  '$8$;y?O$O$O&:!%< "!&M//r ;;M&&!%mF&:!;&,&#'"9"9$ffVd"e"e  "- E&+&=d>U&V&VD ##(#:4;O#P#PD ' J '0ty1H'I'I$* v! !# 4 4T5L M M ) %%'W%9%9$:N%O%ONm+++3FvFvaeauFvFvFvCvCv+$( #%s*]*]TE\*]*]*]']']% $It477j7jRVRi7j7j7j4j4j-sSSps*.s.s.s.s[_[r.s.s.sD+  v*u*u*u*u]a]t*u*u*u'4*++q00T5M0Rh0'***.DD*****[- E- EX100000rnstatec  |dkr||jrv|j}|t jz}t |t jz}t |t jz}nt j}|}t |t |z } tt j| z d}tt j| z d}d|dkr||j j D]G\} } | | r-| |t d}|t z }nUHtjd} | ddd| t#j| }||||||rfd |jD|_t |jd kr/|t |kr|jr|jdxxd z cc<|jsG|j|j |j|j d|_ |j|S#t4$rYdSwxYw#t6$rr} t9| }|rV|t<jtAj!d|| j"r tFj$ndftKYd} ~ dSd} ~ wtL$rB} |'|(| tKYd} ~ dSd} ~ wwxYw)uHOverride of cmd's complete method which returns the next possible completion for 'text'. This completer function is called by readline as complete(text, state), for state in 0, 1, 2, …, until it returns a non-string value. It should return the next possible completion starting with text. Since readline suppresses any exception raised in completer functions, they can be difficult to debug. Therefore, this function wraps the actual tab completion logic and prints to stderr any exception that occurs before returning control to readline. :param text: the current word that user is typing :param state: non-negative integer :param custom_settings: used when not tab completing the main command line :return: the next possible completion for text or None rrfNFadd_helprCOMMANDzcommand, alias, or macro name)metavarrrcg|]}|zSruru)rDrshortcut_to_restores rlrFz Cmd.complete.. s.p.p.pu/BU/J.p.p.prnrrrTr))r_rrlstripr^get_line_bufferr get_begidx get_endidxrrrrrrr/_get_commands_aliases_and_macros_for_completionr"CustomCompletionSettingsrr*r&r-rr%r+ IndexErrorr6rr!rrrr7 apply_stylerHERRORr_r|r&r?)rkrrrrlstripped_previousr`rarb orig_line num_strippedshortcutrrrerr_strr$s @rlr z Cmd.complete sY zz//111/J)-)D)K)K)M)M&-0H0J0JJD!!344x7J7L7LLF !344x7J7L7LLFF!) 8 : :I$++--D#&y>>CII#=L!!4!6!6!EqIIF !4!6!6!EqIIF ')#Q;;?#:'+'<'FQQ !??844"2:/$(,?(@(@(B(B#CD"c*=&>&>>F!E""1!HRW!X!X!X++%$-!@$($X$X$Z$Z , +0*H*P*P((tVV_UUU'q.p.p.p.pX\Xo.p.p.pD+t.//1443t999L9LQUQj9L+A...#5...*/+00T5J0KKK(--$2G-HHH*.D' .u55   tt    "ggG % JM R^"K)//L#$$$44444    KKMMM LL     44444  sCJ K$ J11 J?;K>J??K N A'L99 N7NNc|jduS)z(Return whether a text script is running.N)_current_script_dirrjs rlrJz Cmd.in_script s't33rnc|jS)z9Return whether running inside a Python shell or pyscript.)rrjs rlrIzCmd.in_pyscript s {rnc|jjS)zGRead-only property to access the aliases stored in the StatementParser.)rrrjs rlrz Cmd.aliases s$,,rnc t|S)zZReturn an alphabetized list of names comprising the attributes of the cmd2 class instance.)dirrjs rl get_namesz Cmd.get_names" s4yyrncDfdDS)zReturn a list of all commands.cg|]_}|tj!tt |>|t tjd`Sry)rr r.rrrrDrrks rlrFz(Cmd.get_all_commands..( st   y<== CK7SWY]K^K^B_B_ Y23355 6   rnr9rjs`rlr2zCmd.get_all_commands& s8    ((    rncDfdDS)z@Return a list of commands that have not been hidden or disabled.c8g|]}|jv |jv|Srurr")rDrrks rlrFz,Cmd.get_visible_commands..0 s>   d222wdF\7\7\ 7\7\7\rn)r2rjs`rlget_visible_commandszCmd.get_visible_commands. s:    0022    rncg}|jD]+\}}|g}|t||,|S)z9Return list of alias names and values as CompletionItems.)rrrr()rkresultsrrdescriptive_datas rl_get_alias_completion_itemszCmd._get_alias_completion_items6 sW(*<--// C CKD% %w  NN>$0@AA B B B Brncg}|jD]0\}}|jg}|t ||1|S)z9Return list of macro names and values as CompletionItems.)rrrrr()rkrCrmacrorDs rl_get_macro_completion_itemszCmd._get_macro_completion_items@ sY(*;,,.. C CKD% % }  NN>$0@AA B B B Brncg}|jD]C\}}t|j|jg}|t ||D|S)zKReturn list of Settable names, values, and descriptions as CompletionItems.)rmrrrrrr()rkrCrrrDs rl_get_settable_completion_itemsz"Cmd._get_settable_completion_itemsJ sl(*"n2244 C CND(HN##$   NN>$0@AA B B B Brnct|}t|j}t|j}t ||z|zS)zJReturn a list of visible commands, aliases, and macros for tab completion.)rrArrrZ)rkvisible_commands alias_names macro_namess rlr)z3Cmd._get_commands_aliases_and_macros_for_completionW sSt88::;;$,'' $+&& ${2[@AAArnc`fdD}fd|DS)zReturn a list of help topics.cg|]_}|tj!tt |>|t tjd`Sry)rr r0rrrr<s rlrFz'Cmd.get_help_topics..` st   y9:: @HPTVZH[H[?\?\ Y/0022 3   rnc8g|]}|jv |jv|Srur@)rDtopicrks rlrFz'Cmd.get_help_topics..g s5{{{%d>R1R1RW\dhdzWzWzWzWzWzrnr=)rk all_topicss` rlget_help_topicszCmd.get_help_topics^ sR    ((   |{{{:{{{{rnsignumframec|j|j|jsWd}|j6||jj}|| }|r|dSdSdS)zSignal handler for SIGINTs which typically come from Ctrl-C events. If you need custom SIGINT behavior, then override this method. :param signum: signal number :param frame: the current stack frame or None NT)r send_sigintrr6rrsigint_handler_raise_keyboard_interrupt)rkrUrVraise_interruptr:s rlrYzCmd.sigint_handleri s  % 1  & 2 2 4 4 4% 1"O#/">>t?S?[\\ **5*D*D*F*F&FO 1..00000 1 1  1 1rnrc4tjd|zdS)a#Signal handler for SIGHUP and SIGTERM. Only runs on Linux and Mac. SIGHUP - received when terminal window is closed SIGTERM - received when this app has been requested to terminate The basic purpose of this method is to call sys.exit() so our exit handler will run and save the persistent history file. If you need more complex behavior like killing threads and performing cleanup, then override this method. :param signum: signal number :param _: the current stack frame or None N)rexit)rkrUrs rltermination_signal_handlerzCmd.termination_signal_handler s vrnc td)zRaise a KeyboardInterrupt.zGot a keyboard interrupt)KeyboardInterruptrjs rlrZzCmd._raise_keyboard_interrupt s :;;;rnrcNt|tst|n|S)aRan just before the command is executed by [cmd2.Cmd.onecmd][] and after adding it to history (cmd Hook method). :param statement: subclass of str which also contains the parsed input :return: a potentially modified version of the input Statement object See [cmd2.Cmd.register_postparsing_hook][] and [cmd2.Cmd.register_precmd_hook][] for more robust ways to run hooks before the command is executed. See [Hooks](../features/hooks.md) for more information. )rCrA)rkrs rlprecmdz Cmd.precmd s',6i+K+KZy###QZZrnstopc|S)aRan just after a command is executed by [cmd2.Cmd.onecmd][] (cmd inherited Hook method). :param stop: return `True` to request the command loop terminate :param statement: subclass of str which also contains the parsed input See [cmd2.Cmd.register_postcmd_hook][] and [cmd2.Cmd.register_cmdfinalization_hook][] for more robust ways to run hooks after the command is executed. See [Hooks](../features/hooks.md) for more information. ru)rkrdrs rlpostcmdz Cmd.postcmd s  rncdS)akRan once when the [cmd2.Cmd.cmdloop][] method is called (cmd inherited Hook method). This method is a stub that does nothing and exists to be overridden by subclasses. See [cmd2.Cmd.register_preloop_hook][] for a more robust wayto run hooks before the command loop begins. See [Hooks](../features/hooks.md) for more information. Nrurjs rlpreloopz Cmd.preloop rncdS)axRan once when the [cmd2.Cmd.cmdloop][] method is about to return (cmd inherited Hook Method). This method is a stub that does nothing and exists to be overridden by subclasses. See [cmd2.Cmd.register_postloop_hook][] for a more robust way to run hooks after the command loop completes. See [Hooks](../features/hooks.md) for more information. Nrurjs rlpostloopz Cmd.postloop rirnc^|j|}|j|j|jfS)zParse the line into a command name and a string containing the arguments. :param line: line read by readline :return: tuple containing (command, args, line) )rrrargsr)rkr`rs rl parselinez Cmd.parseline s/ )<|d|j |j j| z |j5| ||| |r d|j _ dddn #1swxYwYnJ#|j5| ||| |r d|j _ dddw#1swxYwYwxYwn#t2tf$rYnt4$r"}|d |Yd}~nd}~wt8$r}||Yd}~nd}~wt:$r|r|sYnzt<$r2}t?|j tBr |j |_"d}Yd}~nDd}~wtF$r }|j$dd}~wtJ$r}|&|Yd}~nd}~wwxYw |'||}n5#t:$r |r|sYn#t<$r2}t?|j tBr |j |_"d}Yd}~nd}~wtF$r }|j$dd}~wtJ$r}|&|Yd}~nd}~wwxYw# |'||}w#t:$r |r|sYwYwt<$r2}t?|j tBr |j |_"d}Yd}~wd}~wtF$r }|j$dd}~wtJ$r}|&|Yd}~wd}~wwxYwxYw|S) aTop-level function called by cmdloop() to handle parsing a line and running the command and all of its hooks. :param line: command line to run :param add_to_history: If True, then add this command to history. Defaults to True. :param raise_keyboard_interrupt: if True, then KeyboardInterrupt exceptions will be raised if stop isn't already True. This is used when running commands in a loop to be able to stop the whole loop and not just the current command. Defaults to False. :param py_bridge_call: This should only ever be set to True by PyBridge to signify the beginning of an app() call from Python. It is used to enable/disable the storage of the command's stdout. :param orig_rl_history_length: Optional length of the readline history before the current command was typed. This is used to assist in combining multiline readline history entries and is only populated by cmd2. Defaults to None. :return: True if running of commands should stop rNFrr)tzroz Elapsed: TzInvalid syntax: )(datetime_input_line_to_statementr!PostparsingData_postparsing_hooksrdrr8rr pause_storage_redirect_outputnowtimezoneutcPrecommandData _precmd_hooksrconecmdPostcommandData_postcmd_hooksrfrrA_restore_outputr;r4r&r:ra SystemExitrCcoderrr9 wrapped_exr|r?_run_cmdfinalization_hooks)rkr`rorprqrrrwrdrpostparsing_datapostparsing_funcredir_saved_state timestart precmd_data precmd_func postcmd_data postcmd_funcrs rlonecmd_plus_hookszCmd.onecmd_plus_hooks s0  a !55dSi5jjI &5eYGG $($;   #3#34D#E#E #(E)2I#(D %%$DH , 9+II%:49 1(,(=(=i(H(H% IIIIIIIIIIIIIII%-11X5F5J1KK %3I>> #'#5;;K"-+k":":KK'1 !KK 22 {{9^{LL &5dIFF $($7>>L#/< #=#=LL$(||D)44;nNN#lx/@/D/DHYH]/D/^/^aj/j#l#lmmm+99(4,,Y8IJJJ%948 1 999999999999999T+99(4,,Y8IJJJ%948 1 9999999999999999%n5    D 1 1 1 KK/2// 0 0 0 0 0 0 0 0    KKOOOOOOOO    '     "'3'' )!#DDDDDD# * * *-T )    LL          !66tYGG$   +D   bgs++-%'WDN' . . .m- ! ! ! R         ! !66tYGG$   +D   bgs++-%'WDN' . . .m- ! ! ! R         ! sA#I.H5$B% H%B))H,B)-DH=I'G7+ I7G;;I>G;?II  'H>2 I >I I I I  I O!L9O!! L9*JO! L9J.)O!.L9O! L9 (K83O!8 L9L  L9L4/O!4L99O!=MO' O0(N O*N22 O?OO!R#O:9R:R R R(Q>R RQ R%Q?:R?RRc|j|jrddl}ddl}|j5t j|j|j 5| |j |j |jdddn #1swxYwYdddn #1swxYwYtj||}|jD] }||}|jS)z#Run the command finalization hooks.Nr)rrrrrr contextlibsuppressr r  tcsetattrrTCSANOWr!CommandFinalizationData_cmdfinalization_hooksrd)rkrdrrrdatars rlrzCmd._run_cmdfinalization_hooksJ s  ) 5$*:K:K:M:M 5 III NNN' h h)>/  D4::DDys5 B,9B B,B B,B B,,B03B0rostop_on_keyboard_interruptcmdsrc2|D]}t|tr|j}|jr||j| ||||rdS`#t$r'}|r||Yd}~n Yd}~d}~wwxYwdS)aRun commands in an automated fashion from sources like text scripts or history replays. The prompt and command line for each command will be printed if echo is True. :param cmds: commands to run :param add_to_history: If True, then add these commands to history. Defaults to True. :param stop_on_keyboard_interrupt: if True, then stop running contents of cmds if Ctrl-C is pressed instead of moving to the next command in the list. This is used when the commands are part of a group, like a text script, which should stop upon Ctrl-C. Defaults to False. :return: True if running of commands should stop rorpTNF) rCr=rawrr$rrrar&)rkrrorr`rs rlruncmds_plus_hookszCmd.runcmds_plus_hooks] s$  D$ ,, xy 5  3T33444 ))Rl*  44 %   -KKOOOEEEEE  usA## B-BBrtcdtddffd } |j|}|jr |jrn|jsnn2#t $r%|j|}|jsYnwxYw d|_|dz|_| |j }|dkrd}| ||d|z }|r%|j|}||nF#t$r9| d|jd }Yd |_nwxYwd |_n #d |_wxYw<|j st|||S) aKeep accepting lines of input until the command is complete. There is some pretty hacky code here to handle some quirks of self._read_command_line(). It returns a literal 'eof' if the input pipe runs out. We can't refactor it because we need to retain backwards compatibility with the standard library version of cmd. :param line: the line being parsed :param orig_rl_history_length: Optional length of the readline history before the current command was typed. This is used to assist in combining multiline readline history entries and is only populated by cmd2. Defaults to None. :return: the completed Statement :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation) :raises EmptyStatement: when the resulting Statement is blank rrdNcP|jsdStjkr?tjtjdz tjk?t |}dks|tjkrtj|dSdS)zNCombine all lines of a multiline command into a single readline history entry.Nrr)multiline_commandr^get_current_history_lengthremove_history_itemr>get_history_item add_history)rformatted_commandrrs rlcombine_rl_historyz3Cmd._complete_statement..combine_rl_history s%-Y5P-577:PPP,X-P-R-RUV-VWWW577:PPP!39 = = &**.?8C\]sCtCt.t.t$%677777/u.trnTrr^CrfF)rArparser terminatorr4rrr_read_command_linerr$rarr8)rkr`rrrrnextlines ` rl_complete_statementzCmd._complete_statement s" 8) 8 8 8 8 8 8 81 5  177== .93G 2"   !1DDTJJ  2   5/3,/3Tk+ 2243KLLu$$ $HLL***X'2 $ 5 H H N NI&&y111$    T""" 177;; /4,,   05,,u,4444c1 5f  ! 9%%%sA(AA,A65A6:A7C21E29D5+E4D55E E c g}d} |||}| |j}d}|j|jvrD|j|vr;||j||}|t |}nnv||jkrFt|j||j|j |j |j |j |j |j|j }|S)aParse the user's input line and convert it to a Statement, ensuring that all macros are also resolved. :param line: the line being parsed :param orig_rl_history_length: Optional length of the readline history before the current command was typed. This is used to assist in combining multiline readline history entries and is only populated by cmd2. Defaults to None. :return: parsed command line as a Statement :raises Cmd2ShlexError: if a shlex error occurs (e.g. No closing quotation) :raises EmptyStatement: when the resulting Statement is blank NTrt) rrarg_listrrsuffixpipe_tooutput output_to)rrrrr_resolve_macror8rArmrrrrrrr)rkr`rr used_macrosr/rresolve_results rlrxzCmd._input_line_to_statement s    00Nd0eeI %M )-& DK//I4E[4X4X""9#4555!%!4!4Y!?!?!)((%% *  % %"!)"+"+"=$/ '!) '#-   Irnc|j|jvrt|jd|j|j}t|j|jkr9|jdkrdnd}|d|jd|jd|dS|j}t|jd d }|D]{}|j rd |j zd z}d|j zdz}n,d|j zdz}|j t|j }| |d} | d|z| dz}||j|jdD] } |d| zz } ||jzS)zResolve a macro and return the resulting string. :param statement: the parsed statement from the command line :return: the resolved macro or None on error z is not a macrorrfsz The macro 'z' expects at least z argumentNc|jSry) start_index)mas rlrez$Cmd._resolve_macro..% srnT)rjreversez{{z}}{})maxsplitrr)rrrrrminimum_arg_countr&rsorted is_escaped number_strargvrrsplit post_command) rkrrGpluralresolvedreverse_arg_list macro_argr replacementpartsstmt_args rlrzCmd._resolve_macro s  DK / /i/@@@AA A I-. y! " "U%< < < 2a77RRSF KKvi&7vvELcvvntvv w w w4;!%.6O6OY]^^^) 9 9I# H!I$884? !I$883>  9#77#= 'nS1E-F-FG OOJO;;EQx+-a8HH"*5+B+D+DE ' 'H h &HH)000rnc Hddl}|jtjk}tj|j||j|j}d}|jsnD|jrtj \}}t|}ttt|d} i} tjdkr |j| d<n+d| d<tjd} | r| | d <|j|jf|t'|jtjr|jn|jt'tjtjr|jn tjdd | } t/j|j5| d dddn #1swxYwY| j@|| t;d | jd d|_tj| |jtj}| |_|r|jt_n_|j rW|j!r|j tDj#krdnd} ttttIj%|j!| d} n"#tL$r}t;d|d}~wwxYwd|_| |_|r|jt_n|j'st;dtQ}tttSj*d} d|_| |_|r|jt_|j tDj#kr3|j+||j,||_|j|_|S)a*Set up a command's output redirection for >, >>, and |. :param statement: a parsed statement from the user :return: A bool telling if an error occurred and a utils.RedirectionSavedState object :raises RedirectionError: if an error occurs trying to pipe or redirect rNwwin32 creationflagsTstart_new_sessionSHELL executable)rrr rGg?zPipe process exited with code z before command could runar)r] bufferingzFailed to redirect outputzClipboard access not allowedzw+)r])-rMrrr"RedirectionSavedStaterrrrr pipeopenrrrCREATE_NEW_PROCESS_GROUPrHrrNrCStdSimrOr rrTimeoutExpiredwait returncodecloser: redirecting ProcReaderrrr rrreOSErrorrr)tempfile TemporaryFilerflush)rkrrM stdouts_matchrcmd_pipe_proc_readerread_fdwrite_fd subproc_stdin new_stdoutrrGprocr]rcurrent_paste_buffers rlr|zCmd._redirect_output9 s  sz1 "7 K(BDDU   9=%_ (   [ ( " GX!MMM!%fd8S.A.A!B!BJ &(F|w&&*4*M''.2*+ w//1+0F<($:#!#*4T[%,*O*O`zUYU`*4SZ*N*N^zTWT^   D$Z%>??   #               *##%%%  """&'r'r'r'rsss,0  )#(#3D$+sz#R#R $DK )![  ( ("' ((.)2NNNssTWP!%fd2?9CV3W3W^bno.p.p.p!q!qJJPPP*+FGGROP15!-(  -!%CJ +K*+IJJJ(8'9'9$!&(*@d*K*K*KLL 04!-(  -!%CJ#y'CCCK%%&:;;;K%%'''&:"-9  s*4FFF>  ' X$B_B_`i`qBrBr-r-> X WD;BBCTUUWW WG G4 (((trn_ignoredcgS)zCall to complete an input line when no command-specific complete_*() method is available. This method is only called for non-argparse-based commands. By default, it returns an empty list. ru)rkrs rlr zCmd.completedefault s  rncFt||Sry)rYrA)rkrs rlrzCmd._suggest_similar_command sw(A(A(C(CDDDrn)r|completion_moder rrrgrrr|rr rrrgc  d ddd  f d } d fd } jrtjr t |} j5| dddn #1swxYwYt | } j5| dddn #1swxYwYn+#j5| dddw#1swxYwYwxYwt } jr$tj || dnÉjr_ |dj j } t| d krd } nKj } t| r!jr || nd } | d S) aRead input from appropriate stdin value. Also supports tab completion and up-arrow history while input is being entered. :param prompt: prompt to display to user :param history: optional list of strings to use for up-arrow history. If completion_mode is CompletionMode.COMMANDS and this is None, then cmd2's command list history will be used. The passed in history will not be edited. It is the caller's responsibility to add the returned input to history if desired. Defaults to None. :param completion_mode: tells what type of tab completion to support. Tab completion only works when self.use_rawinput is True and sys.stdin is a terminal. Defaults to CompletionMode.NONE. The following optional settings apply when completion_mode is CompletionMode.CUSTOM: :param preserve_quotes: if True, then quoted tokens will keep their quotes when processed by ArgparseCompleter. This is helpful in cases when you're tab completing flag-like tokens (e.g. -o, --option) and you don't want them to be treated as argparse flags when quoted. Set this to True if you plan on passing the string to argparse with the tokens still quoted. A maximum of one of these should be provided: :param choices: iterable of accepted values for single argument :param choices_provider: function that provides choices for single argument :param completer: tab completion function that provides choices for single argument :param parser: an argument parser which supports the tab completion of multiple arguments :return: the line read from stdin with all trailing new lines removed :raises Exception: any exceptions raised by input() and stdin.readline() FNrdcD sttjkrdSrt j t jjkrdtdtdtdzfd}|}nt jj krj }nb /tj d dd  t j }t!jj | }t j|t jj ks ~gt'd t jd zD])}t j|*t j  D]}t j|d dS)z.Configure readline tab completion and history.NrrrrdcdSryru)rrrs rl complete_nonezACmd.read_input..configure_readline..complete_noneb s#trnFrargT)suppress_tab_hintrrrgr )rr)rRrKr r r^ get_completerr"CompletionModerrCOMMANDSr rrrr*rr  set_completerrangerrr clear_historyr)r  complete_funcriitemrrrgrr|rr readline_configuredsaved_completer saved_historyrks rlconfigure_readlinez*Cmd.read_input..configure_readlineQ s# g&<&<))++ 6"*"8":":#e&:&???$C$$d $$$$%2MM%(<(EEE$(MMM~!0!HRW!X!X!X++!.2$+-=&/ ,',&DV]l&m&m&mO$-$5dmUd$e$e$eM&}555%"6"???7CV " q("E"G"G!"KLLGGA!(()B1)E)EFFFF&(((& '33 ,T2222"&   rncrttjkrdSrt j,t jD]}t j|ddS)z,Restore readline tab completion and history.NF)rRrKr r r^rrr)rrrrrks rlrestore_readlinez(Cmd.read_input..restore_readline s' 'V[*@*@))++ 8&777(&((()//D(...."'   rnrrf)rrrz ro)rrrrrLrinputrrrr$rr^rr)rkrr|rr rrrgrrrescaped_promptr`rrrs` ``````` @@@rl read_inputzCmd.read_input" s6V$04*. 6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 '6 'p ( ( ( ( ( ( ( ( ("  # y!! : +%5f%=%=N/--**,,,--------------- 00D/++((***+++++++++++++++/++((***++++++++++++++++ww9:J$$%8%8%8%8999Z     LLRL ( ( ( K     :&&((D4yyA~~ :&&((D4yy 94LLF!2D!2!2333{{6"""sfC' A>2 C>BCBC B66B:=B:C. C" C."C& &C.)C& *C.c tjt5|jdddn #1swxYwY||t jj|j S#t$rY|j dSwxYw#|j wxYw)aRead command line from appropriate stdin. :param prompt: prompt to display to user :return: command line text of 'eof' if an EOFError was caught :raises Exception: whatever exceptions are raised by input() except for EOFError N)rr) rr RuntimeErrorr!releaserr"rracquireEOFError)rkrs rlrzCmd._read_command_line s )$\22 - -"**,,, - - - - - - - - - - - - - - -??65;O;X?YY   & & ( ( ( (       & & ( ( ( ( (     & & ( ( ( (sEB A B AB A (B B2B51B22B55Cc$t}ttjkrt jd|rCttjkrMtttjttj j |_ dt_ t j|_t j|jd}|dt&jz }|dt&jz }|d|jjz }t j|_t j|t j|jdz|S)zSet up readline with cmd2-specific settings, called at beginning of command loop. :return: Class containing saved readline settings zset horizontal-scroll-mode offNz rfz : complete)rcrRrKrWr^parse_and_bindr rrrrac_void_prrir rgrr r{r rhREDIRECTION_CHARSrrget_completer_delimsrhset_completer_delimsr)rkrzcompleter_delimss rl_set_up_cmd2_readlinezCmd._set_up_cmd2_readline sH 344 fj   #$D E E E  % % ' ' E&*$$ 26eV[Ibdjds=t=t=z1{1{!.26)/*2*@*B*B  '  "4= 1 1 1 '   (8 9 9 9   (C D D D  (=(I J J J '/'D'F'F  $  )*: ; ; ;  #D$4|$C D D D  rnrzcr|rtj|jtj|jt tjkr'tj d|j t_ dSt tj krttjj_dSdSdS)zRestore saved readline settings, called at end of command loop. :param readline_settings: the readline settings to restore N)r r^rrgr)rhrRrKrWrXrirarrZrr\r]r^)rkrzs rl_restore_readlinezCmd._restore_readline s  % % ' ' P  "#4#> ? ? ?  )*;*B C C C&*$$K\]]] *<<     ##L4#HHHrnr rmcN|j}||dS)r3N cmd2_handlerrrkrmhandlers rldo_aliasz Cmd.do_aliasL)#'')) rncjd}tj|}tjdddtjfdd}|d||_|dd |d d |j |dtj d|j |S)NCreate or overwrite an alias.r4zaIf you want to use redirection, pipes, or terminators in the value of the alias, then quote them.r5z8 alias create save_results print_results ">" out.txt zSince aliases are resolved during parsing, tab completion will function as it would for the actual command the alias resolves to.Notesrzname of this aliasrrcommand, alias, or macro to runrr command_argsarguments to pass to commandnargsrrg) rrrr7rHr8r:r;rr)r REMAINDERr)clsalias_create_descriptionalias_create_parseralias_create_notess rl_build_alias_create_parserzCmd._build_alias_create_parserTs#B -ERjkkk"] o  JILb c @   &9%J%J7Tf%g%g" ((6J(KKK(( 2 P )   (( $/' )   #"rnrcreatezcreate or overwrite an aliasrJcd|_|j|j\}}|s|d|dS|j|vr|ddS|j|jvr|ddSgtj|jj }tj |j ||j }|j r |dd|j zz }|j|jvrdnd}|d |jd |||j|j<d |_dS) rHFzInvalid alias name: Nz,Alias cannot have the same name as a commandz*Alias cannot have the same name as a macror overwrittencreatedAlias '' T)rrr3rr&r2rr rrr"unquote_specific_tokensrMrr{rr$)rkrmr<r=tokens_to_unquoterresults rl _alias_createzCmd._alias_createvsi!->>tyII v  KK7v77 8 8 8 F 9--// / / KKF G G G F 9 # # KKD E E E F`i:_T=R=^_ %d&79JKKK    7 S388D$5666 6E#')t|";"; 4ty44F44555"' TYrncd}tj|}|dddd|dtjd |jd g |S) Nz9Delete specified aliases or all aliases if --all is used.r4-a--allrzdelete all aliasesrnameszalias(es) to deleteValuerPrrdescriptive_headers)rrrr ZERO_OR_MORErE)rRalias_delete_descriptionalias_delete_parsers rl_build_alias_delete_parserzCmd._build_alias_delete_parsersw#^ -ERjkkk((w|Rf(ggg(( '& 8!>!>!>????KK D( D D DEEEE  F Frnctjddd}tj|}|dt jd|jdg|S) NztList specified aliases in a reusable form that can be saved to a startup script to preserve aliases across sessions.r5z.Without arguments, all aliases will be listed.r4rdzalias(es) to listrerf)rr7rrrrrhrE)rRalias_list_descriptionalias_list_parsers rl_build_alias_list_parserzCmd._build_alias_list_parserst!%>  < " " ,CPfggg&& '$ K\]]] *<<     ##L4#HHHrncN|j}||dS)rNrArCs rldo_macroz Cmd.do_macrorFrncZtjdddddddddtjfddddtjfd t d fd tjf}t j| }tjdddddddtjfddddtjfddddtjfdd}|d||_| dd| dd|j | dtj d|j |S)!NCreate or overwrite a macro.r5rzdArguments are expressed when creating a macro using {#} notation where {1} means the first argument.zIThe following creates a macro called my_macro that expects two arguments:z= macro create my_macro make_dinner --meat {1} --veggie {2}zlWhen the macro is called, the provided arguments are resolved and the assembled command is run. For example:z my_macro beef broccoliu ───> Tboldz)make_dinner --meat beef --veggie broccolir4zITo use the literal string {1} in your command, escape it this way: {{1}}.zCExtra arguments passed to a macro are appended to resolved command.z|An argument number can be repeated in a macro. In the following example the first argument will populate both {1} instances.z3 macro create ft file_taxes -p {1} -q {2} -r {1}zGTo quote an argument in the resolved command, quote it during creation.z, macro create backup !cp "{1}" "{1}.orig"zaIf you want to use redirection, pipes, or terminators in the value of the macro, then quote them.z> macro create show_results print_results -type {1} "|" lesszSince macros don't resolve until after you press Enter, their arguments tab complete as paths. This default behavior changes if custom tab completion for macro arguments has been implemented.rIrzname of this macrorJrrKrLrMrNrO)rr7rHr8rrrr:r;rr)rrQr)rRmacro_create_descriptionmacro_create_parsermacro_create_notess rl_build_macro_create_parserzCmd._build_macro_create_parser&s#'= *  W  r  W  LiNd e  z  )9+A B U--- . 8):P Q$ $  ".ERjkkk"] W  Q C  BIDZ [  U  ?AW X  o  OQZQg h s+  2&9%J%J7Tf%g%g" ((6J(KKK(( 2 P )   (( $/' )   #"rnrGzcreate or overwrite a macrocd|_|j|j\}}|s|d|dS|j|vr|ddS|j|jvr|ddSgtj|jj }tj |j ||j }|j r |dd|j zz }g}tjt"j|}d}t'} |} tjt"j| d} t1| } | d kr|d dS| | t5|| }|t#| | d #t:$rYnwxYwt=| |kr|d |d dStjt"j|} | } tjt"j| d} |t#| | d #t:$rYnwxYw|j|j vrdnd}|!d|jd|tE|j||||j |j<d|_dS)rFzInvalid macro name: Nz,Macro cannot have the same name as a commandz+Macro cannot have the same name as an aliasrrTrz'Argument numbers must be greater than 0)rrrzNot all numbers between 1 and z) are present in the argument placeholdersrYrZMacro 'r\)rrrr)#rrr3rr&r2rr rrr"r]rMrr{refinditerr@macro_normal_arg_patternr__next__findall digit_patterngrouprrzrrstart StopIterationrmacro_escaped_arg_patternrr$r?)rkrmr<r=r^rrnormal_matches max_arg_numarg_numsrv cur_num_strcur_numescaped_matchesr_s rl _macro_createzCmd._macro_creategsp!->>tyII v  KK7v77 8 8 8 F 9--// / / KKF G G G F 9 $ $ KKE F F F F`i:_T=R=^_ %d&79JKKK    7 S388D$5666 6EX%FNN 55  s*3355 !j)?ARARSSTUV k**Q;;KK IJJJF W%%%!+w77 Y__5F5FS^kp q q qrrr s    D  x==K ' ' KKoooo p p p F+h&H%PP  r+4466 !j)?ARARSSTUV Y__5F5FS^ko p p pqqq  r    D #')t{":":  4ty44F44555!&DIUValt!u!u!u DIs-1A6H)AH HH$BK(( K54K5cd}tj|}|dddd|dtjd |jd g |S) Nz7Delete specified macros or all macros if --all is used.r4rbrcrzdelete all macrosrrdzmacro(s) to deletererf)rrrrrhrH)rRmacro_delete_descriptionmacro_delete_parsers rl_build_macro_delete_parserzCmd._build_macro_delete_parsersw#\ -ERjkkk((w|Re(fff(( '% 8!>!>!>????KK D( D D DEEEE  F Frnctjddd}tj|}|dt jd|jdg|S) NzrList specified macros in a reusable form that can be saved to a startup script to preserve macros across sessions.r5z-Without arguments, all macros will be listed.r4rdzmacro(s) to listrerf)rr7rrrrrhrH)rRmacro_list_descriptionmacro_list_parsers rl_build_macro_list_parserzCmd._build_macro_list_parserst!%6  ; " " ,CPfggg&& '# > + 'i.N O O$$Xr222(#**73333 + +* +((((!!'****(J ;;rnctjd}|dddd|dtjd |j |d tjd |j |S) NHList available commands or provide detailed help for a specific command.r4-v --verboserz6print a list of all commands with descriptions of eachrrzcommand to retrieve help forrOrz"subcommand(s) to retrieve help for)rrrrOPTIONALrrQr)rR help_parsers rl_build_help_parserzCmd._build_help_parserNs%=b       I !     #// !     $53 !   rnc^d|_|jr|jr|\}}}|jrG||t |jtj|t |j }fd|D}|r |||j <n |||j <d}|D]M\}} |r|||| |jt!| o|j}N|r|s|r|||j|dd||j|dddS||j} t+|t,j|jzd} | dn|j| } | 9| 7t5j| |} | |j|jdS| | dS| 0| j)|tAj!| dS|j"#|j}|$|dd|_dS) rTr\rc"i|] }|| Sruru)rDrrs rlrlzCmd.do_help..vs XXX()H"5XXXrnFPN)%rrverboserrr$rrH HELP_LEADERrr|r%rrr _print_documented_command_topicsr print_topicsrrrrr r0r.rrr print_helprrrtpydocgetdocrrr&)rkrmrrrsorted_categoriesall_cmdsprevious_table_printedrcommandsr help_funcrrgrrs @rldo_helpz Cmd.do_helpgs |7 )t|7 );?;S;S;U;U 8Ix[ Q  T$/9NOOOPPP LLNNN!'y~~'7'7T=R S S S XXXXFWXXXH 52:.//,4)&+ "&.nn&6&6 I I"()#LLNNN55h$,WWW)-h)HDL&&% ; *     d. R D D D   d/R D D D D D==..Di&@4<&OQUVVI $ $2G2K2KD2Q2QII$9.CItTT $$T%5t{CCCCC& !dl&> U\$//00000/00>> G4 000#(   rnheadercmdlenmaxcolc|sdS|rtj}|t|tj|t |jtj| |dt|tj dz }| ||| dS)anPrint groups of commands and topics in columns and an optional header. Override of cmd's print_topics() to use Rich. :param header: string to print above commands being printed :param cmds: list of topics to print :param cmdlen: unused, even by cmd's version :param maxcol: max number of display columns to fit into Nr\ charactersr]Frr)rgridadd_rowrrH HELP_HEADERrr TABLE_BORDERr$minr console_width columnize)rkrrrr header_grids rlrzCmd.print_topicss  F  7*,,K   V93H I I I J J J    )BX Y Y Y Z Z Z LLL 6 6 6VR-//0014 tV$$$ rnrc ddl}|sdS|s|||dddStj}|t |t j|t|j t j ttdd td d tj jd t j }|}|D]?}||x} ||vrt#|t$j|z} |} t+j| 5|j} t1t2| |_| |j5| |_dddn #1swxYwYn+#|j5| |_dddw#1swxYwYwxYwdddn #1swxYwY| } n| j} | rt;| nd}|||A||||d |dS)z\Print topics which are documented commands, switching between verbose or traditional output.rNrrr\rNameTno_wrap DescriptionfoldoverflowFbox show_edge border_stylerfr)rrrrrrrHrrrrrrichr SIMPLE_HEADrTrrr r0StringIOrredirect_stdoutrrrrgetvaluertrXr$)rkrrrr category_grid topics_tablerrrrr_ stdout_origdoccmd_descs rlrz$Cmd._print_documented_command_topicss8   F    fdB 3 3 3 F d61FGGGHHHddj @VWWWXXX 64 ( ( ( =6 2 2 2$"/    %%'' 4 4G MM'222; &  #D)*Dw*NOO  /77 6 6"&+K6&*66&:&: ! !366*5DK666666666666666T366*5DK6666666666666666 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6oo''&69@,S111bH  ( 3 3 3 3l+++ ]e 444 srG)'$F2 G)F& G)&F* *G)-F* .G)2G:G  GGGGGG))G- 0G- rstr_list display_widthc |sdSt|}|dkr|dSg}tdt|D]}||zdz |z}g}d}t|D]u} d} t|D]<} | || zz} | |krn+|| } t| tj| } =|| || dzz }||krnv||krn.t|}d}td|D}|g}t|D]} g}t|D]/} | || zz} | |krdn|| } || 0|r|ds |d=|r|d tt|D]'} tj|| || || <(|d |d |S) aRender a list of single-line strings as a compact set of columns. This method correctly handles strings containing ANSI style sequences and full-width characters (like those used in CJK languages). Each column is only as wide as necessary and columns are separated by two spaces. :param str_list: list of single-line strings to display :param display_width: max number of display columns to fit into :return: a string containing the columnized output rfrrrc3>K|]}tj|VdSry)rr)rDrs rlrz%Cmd.render_columns..)s*>>BLOO>>>>>>rnrg)r/rr)rrrrrr align_leftr{)rkrrsizerowsnrowsncols colwidthstotwidthcolcolwidthrowrx max_widthtextss rlrender_columnszCmd.render_columnssd 28}} 199A; 1c(mm,, $ $EE\A%%/EIHU||   <<>>Ceck)ADyy  A"8R\!__==HH  ***HqL(m++E,=(()MMEE>>X>>>>>I" I<< * *CEU||  %#+%t))BB! Q b  "I b  SZZ(( M M]5:Ys^LLLc KK %(( ) ) ) )yyrnc\|||}||dS)aDisplay a list of single-line strings as a compact set of columns. Override of cmd's columnize() that uses the render_columns() method. The method correctly handles strings with ANSI style sequences and full-width characters (like those used in CJK languages). :param str_list: list of single-line strings to display :param display_width: max number of display columns to fit into N)rr$)rkrrcolumnized_strss rlrz Cmd.columnize9s1--h FF _%%%%%rnc,tjdS)NList available shortcuts.r4rrrurnrl_build_shortcuts_parserzCmd._build_shortcuts_parserFs6C^____rnctjjfd}dd|D}d|d_dS)rc:|dS)Nr)r%)rrks rlrez"Cmd.do_shortcuts..NsQUQfQfghijgkQlQlrnrrc3<K|]}|dd|dVdS)rr4rNru)rDscs rlrz#Cmd.do_shortcuts..Os8JJ2be..r!u..JJJJJJrnzShortcuts for other commands: TN)rrrr{r$r)rkrsorted_shortcutsr_s` rl do_shortcutszCmd.do_shortcutsJsr"$"7"AGlGlGlGlmmmJJ9IJJJJJ ?v??@@@rncftjd}|dd|_|S)NzCalled when Ctrl-D is pressed.r4NotezXThis command is for internal use and is not intended to be called from the command line.)rrr:r;) eof_parsers rl_build_eof_parserzCmd._build_eof_parserSs<$ will be split into one-word options | a list of strings -> will be offered as options | a list of tuples -> interpreted as (value, text), so that the return value can differ from the text advertised to the user NF)strictrrz %2d. %sTrfrrz4' isn't a valid choice. Pick a number between 1 and :)rCrrrZrrr ziprrr+rr$rr#rarr4r) rkr,r local_opts fulloptionsoptidxrrrresponsers rlselectz Cmd.selectsso dC  d5cDj#9:DTZZ\\SWS]S]S_S_hmAnAnAn$*5    j$*jjjkkk z ,!)J%'_TZ%@%@HNLLDJ!_!_ !_!_X^!_!_```'+D$$ "EEEKK C C Cr C CDDDDDDDDE #'*GG4>..0011G 64 ( ( ( 7V , , , =6 2 2 2$"/    G)>??? 5 5E~e,H  " "HN##$    '/nD U # #  ^u 555 s)A(A-,A-8%C D C;;Dctjd}|dd|j|dtjd|j|S) N)Execute a command as if at the OS prompt.r4rzthe command to runrrgrMrNrO)rrrrrrQr)rR shell_parsers rl_build_shell_parserzCmd._build_shell_parser'sl&>Kvwww !!)2FRURh!iii!! ("4;Yehev "   rnc $ddl}ddl}i}tjdrd}n5|jjdz}tj d}|r||d<|j g|j }tj |d|}|j5|j|ft#|jtjr|jn|jt#tjtjr|jn tjd d |} tj| |jtj} | | j|_| j|kr|ddddS#1swxYwYdS) rJrNrl:rgrrrT)rr rG)signalrMrrrSIGINTrr rHrrrMr"expand_user_in_tokensr{rrNrCrrrOr rrrrrZ) rkrmrOrMrctrl_c_ret_coderGrpexpanded_commandr proc_readers rlrz Cmd.do_shell2s  !# < " "5 ) ) -(OO%m1B6OJNN7++E -',|$,3!23 #F+++88F++ # 1 1#:# *4T[%,*O*O`zUYU`*4SZ*N*N^zTWT^   D *4cjIIK       $D /11..000' 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s!CFF  F cgd}|D]@}tjt5tj|=dddn #1swxYwYAtjt_tjt_dS)aReset the dynamic objects in the sys module that the py and ipy consoles fight over. When a Python console starts it adopts certain display settings if they've already been set. If an ipy console has previously been run, then py uses its settings and ends up looking like an ipy console in terms of prompt and exception text. This method forces the Python console to create its own display settings since they won't exist. IPython does not have this problem since it always overwrites the display settings when it is run. Therefore, this method only needs to be called before creating a Python console. )ps1ps2ps3N) rrrr__dict____displayhook__ displayhook__excepthook__ excepthook) attributescur_attrs rl_reset_py_displayzCmd._reset_py_displayks+** " + +H$X.. + +L* + + + + + + + + + + + + + + +-+s<A A interpcVt}ttjkrpt dt jdzD].}|jt j |/t j |j D]}t j || rttjkrtt t#jt$t"jj|j_t.t$_dt0jvrDdt0jvrt0jd|_t0jdt0jd<t j|j_t jt<ttjkrt jdn0ttj krtBt j"j#_$t j%|j_&|'tQddd|'tQddd|'tQd dd|)|S) zsSet up interactive Python shell environment. :return: Class containing saved up cmd2 environment. r gnureadliner^Nz!from rlcompleter import Completerzexeczimport readlinez4readline.set_completer(Completer(locals()).complete))*rwrRrKr rr^rr|rrrrrr rWrrrrar&rrzriorig_rl_basic_quotesrmodulesr{r(rhr)orig_rl_delimsrXrZrr\r]r^r rgruncodecompiler`)rkracmd2_envrrs rl_set_up_py_shell_envzCmd._set_up_py_shell_envs. !?? fk ! !1hACCaGHH F F ''(A!(D(DEEEE  " $ $ $( + +$T****))++ sfj((>Bv{+DfoVV\??H.;7K-3$ 33&447:{:7NH425+m2L J/4<4Q4S4S*1-n===fj((@FFFF 1116P6]-3$ 33#3; # J 7 7 76>6NCK 3333 " ! O O )(43rnpyscriptroc d|_dd}ddlm}|r|jnd}|||}d}|r|d dS d|_d }|j}|||j <||d <||d <|j r||d <|Btj |} t| 5} | }dddn #1swxYwYnh#t $r[} |d| d| Yd} ~ |j5| |t$_ d|_ddddS#1swxYwYdSd} ~ wwxYwd|d<| |d<t't$j }t$j dtj tj | nd|d<d|_t/|} |r) | |n<#t2$rYn/wxYwd} d|j d}dt$jdt$jd| d|d }d} |j5|| }dddn #1swxYwY| |d n#t2$rYnwxYw|j5|||dddn #1swxYwY|dnP#|j5|||dddn #1swxYwY|dwxYw|j5| |t$_ d|_dddn #1swxYwYn9#|j5| |t$_ d|_dddw#1swxYwYwxYw|j S) aRun an interactive Python shell or execute a pyscript file. Called by do_py() and do_run_pyscript(). If pyscript is None, then this function runs an interactive Python shell. Otherwise, it runs the pyscript file. :param pyscript: optional path to a pyscript file to run. This is intended only to be used by do_run_pyscript() after it sets up sys.argv for the script. (Defaults to None) :return: True if running of commands should stop FrdNct)zUExit an interactive Python environment, callable from the interactive Python console.)r7rurnrlpy_quitz Cmd._run_python..py_quits% %rnrPyBridgeTrv=Recursively entering interactive Python shells is not allowedrfquitr^rkzError reading script file 'r__main__rq__file__r __console__)localszFType "help", "copyright", "credits" or "license" for more information.z]Use `Ctrl-D` (Unix) / `Ctrl-Z` (Windows), `quit()`, `exit()` to exit. Run CLI commands with: z("command ...")zPython z on rr5)bannerexitmsgzNow exiting Python shell...ro)!r py_bridgertrrIr&rrrrrr r rrrrrrrZinsertrrrrh BaseExceptionversionrrkinteractrmr$rd)rkrorrrtror}saved_sys_pathpy_code_to_run local_varsexpanded_filenamefrracprt instructionsr{saved_cmd2_envs rl _run_pythonzCmd._run_pythons! & & & &      9AJ44dHT.AAA        KKW X X X4T $DKN ,,..J.7Jt* +!(Jv !(Jv  *%) 6"#$&G$6$6x$@$@! /002A)*222222222222222   KK X>O X XTV X XYYY444n' $ $!--CH#  $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s *4 :&): :&"&ch27??27??CT3U3U#V#VWWWW*7 :& $D 'z:::F" @NN>2222$D `S.2.ASSS_3;^^CL^^D^^l^^^!%@/KK)-)B)B6)J)JKKKKKKKKKKKKKKK OO62O>>>>$D /CC)5 22>BBBCCCCCCCCCCCCCCCLL!>????/CC)5 22>BBBCCCCCCCCCCCCCCCLL!>????' $ $!--CH#  $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' $ $!--CH#  $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ~sjA$N=C9 C-! C9-C11C94C15C98N9 EEN)E  EEEBN>HN H#N"H##5NJ% J6 J%JJ% J J%$L% J2/L1J22L5N<K  N K$$N'K$(NM L-! M-L1 1M4L1 5MNM::M>M>N<N0$ N<0N4 4N<7N4 8N<c,tjdS)Nz Run an interactive Python shell.r4rrurnrl_build_py_parserzCmd._build_py_parserRs6Ceffffrnc*|S)zdRun an interactive Python shell. :return: True if running of commands should stop. )rr%s rlrz Cmd.do_pyVs!!!rnctjd}|dd|j|dtjd|j|S) Nz8Run Python script within this application's environment.r4 script_pathpath to the script filerKscript_argumentszarguments to pass to scriptrO)rrrrrrQ)rRrun_pyscript_parsers rl_build_run_pyscript_parserzCmd._build_run_pyscript_parser_su-ER    ((=Vbebs(ttt(( h&8?\hkhy )   #"rncd|_tj|j|_|jds<|d|jd|dd}|dkrdStj } |jg|j t_ | |j }|t_ n#|t_ wxYw|S) z{Run Python script within this application's environment. :return: True if running of commands should stop F.pyrz' does not have a .py extensionYes Noz.Continue to try to run it as a Python script? YesNrn) rr r rrendswithrr6rrrr)rkrm selection orig_args py_returns rldo_run_pyscriptzCmd.do_run_pyscriptks !7--d.>??((//  MMOd.OOO P P P H.^__IE!!tH  !(A4+@ACH(($2B(CCI!CHHyCH s 4CC#c,tjdS)Nz!Run an interactive IPython shell.r4rrurnrl_build_ipython_parserzCmd._build_ipython_parsers6Cfggggrncd|_ ddlmcm} |}n#t$r ddlm}YnwxYwddlm}ddl m }n&#t$r| dYdSwxYwdd l m}|r| d dSd |_ d |_||}|j} || |j<|jr|| d <|} d |jd| j_|| g| |d|||jd|_S#d|_wxYw)zdRun an interactive IPython shell. :return: True if running of commands should stop FrNrI)TerminalInteractiveShell)TerminalIPythonAppz IPython package is not installedrrsruTrkzVEntering an IPython shell. Type exit, quit, or Ctrl-D to exit. Run CLI commands with: z("command ...") )configruser_nszNow exiting IPython shell...)rtraitlets.config.loaderrloader NameErrorIPythonrJ!IPython.terminal.interactiveshellrIPython.terminal.ipapprr r&r}rtrIrrrrrConfigInteractiveShellbanner2r$clear_instancerd) rkrtraitlets_loaderrJ_dummyrrrtr}rrs rlrz Cmd.do_ipys5 !  > > > > > > > > > 2& 2 2 211111111 2                 KK: ; ; ;44              KKW X X X4 DK I ,,..J.7Jt* + *%) 6"&,,..FQ*.*=QQQ  # + Mb* E E E E LL7 8 8 8  - - / / / $ 3 3 5 5 5>DKK%DK    s4 99)9)9AAB;E E$cd}tj|tj}|}|dddd|dd dd |d d d d|j|dddd|j|dddd|d}|dddd|dddd|dd dd!|d"d#dd$d%}|d&tj|'|S)(Nzoutput commands in script format, i.e. without command numbersz-xz --expandedzIoutput fully parsed commands with shortcuts, aliases, and macros expandedrrzSdisplay history and include expanded commands if they differ from the typed commandrbrczEdisplay all commands, including ones persisted from previous sessionszempty all history items a one history item by number a..b, a:b, a:, ..b items by indices (inclusive) string items containing string /regex/ items matching regular expressionr )rPr) rrRawTextCmd2HelpFormatteradd_mutually_exclusive_grouprradd_argument_grouprr)rRhistory_descriptionhistory_parserhistory_action_grouphistory_format_grouphistory_arg_helps rl_build_history_parserzCmd._build_history_parsers\(@+_=e    .JJLL))$ So)ppp))$T~)))  ?' *    ))  %^' *    ))$ ,Uh)iii-@@|@TT))  Q *   ))  \ *   ))  f *   ))  X *    D  ##E1BIY#ZZZrnc  d|_|jrH|js*|js#|js|js|js|js|jr| ddS|js|jr:|js|js|js|js|jr| ddS|jrd|_|j |j re tj |j nJ#t$rYn>t$r2}|d|j d|d|_Yd}~dSd}~wwxYwt"t$jkrt)jdS||}|jrp|js,|d|d n>|t3|}d|_|S|jrt7jd d \}}tj|d 5}|D]I}|jjr| |jd ,| |j!d J dddn #1swxYwY |"||#tIj%|tj |S#tj |wxYw|jrDtj&'tj&(|j} tS| d 5}|D]I} | jjr| | jd ,| | j!d J dddn #1swxYwYtU|dkrdnd} |+tU|d| d| d|_n#t$r%}|d| d|Yd}~nd}~wwxYw|jr;|,t3||jn\|-D]@\} } | | .| |j|j|jA||_dS)zView, run, edit, save, or clear previously entered commands. :return: True if running of commands should stop Fz(-v cannot be used with any other optionsNz3-s and -x cannot be used with -c, -r, -e, -o, or -tTzError removing history file 'rz9Cowardly refusing to run all previously entered commands.zEIf this is what you want to do, specify '1:' as the range of history.z.txt)rrrrrrrfrz commandz saved to zError saving history file ')scriptexpandedr)/rrr/edit output_filerun transcriptrrr$r|rr rFileNotFoundErrorrr&rRrKr r^r _get_historyr rrZrrmkstempfdopenrrrr run_editor do_run_scriptrrr rrrrrA_generate_transcriptrpr)rkrmrr|rdfdfnamefobjr full_pathrrr4his rl do_historyzCmd.do_historys ! < z TY $*: dh $/ ]a]j nrny  GHHHt K 4= tz TY $JZ ^b^f jnjy  LLN O O O4 : #D  L   +  Id:;;;;(D   KK e@\ e eac e efff',D$44444 &+%%&(((4##D)) 8. '8  WXXX cdddd..tGNN4D4D/E/EFF#'  Y& ' (TBBBIB2s## 7t&~~//77G(:7 g&6#:#:#:;;;; gk#5#5#56666 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7  !&&&))"(5//:: %     %      '(:(:4;K(L(LMMI ()S))8T ' 0 088>;8 JJ$-';';';<<<< JJ$(7777 8888888888888888 #7||q00c#g,,UUUU)UUVVV#'   N N N L)LLLLMMMMMMMM N _ '  % %d7>>+;+;&<&j krc|jD]]} tC| j"} tGj$} | d ks| tGj%| krtGj&| \dSdS)aMInitialize history using history related attributes. :param hist_file: optional path to persistent history file. If specified, then history from previous sessions will be included. Additionally, all history will be written to this file when the application exits. NzPersistent history file 'z' is a directoryT)exist_okz2Error creating persistent history file directory 'rrbrnz%Cannot read persistent history file 'rrErz-Error decompressing persistent history data 'z@ The history file will be recreated when this application exits.z*Error processing persistent history data ')'r<r|rr r rrrr&rmakedirsrrrratexitregister_persist_historylzma LZMAErrorModuleNotFoundErrorbz2r4 decompressdecodejson from_jsonJSONDecodeErrorr start_sessionrRrKr r>rr^rrr)rkr hist_file_dirrrcompressed_bytesrdecompress_libdecompress_exceptions history_jsonrrrcur_history_lengths rlrzCmd._initialize_historysNyy  +4D ( FGOOBG$6$6y$A$ABB  7== # #  KKOIOOO P P P F 22   K  5 5 5 5 5    KKc]cc_acc d d d FFFFF   i&& /$#'99;;  / / / / / / / / / / / / / / /  # # #"       KKR RRbRR S S S FFFFF   '0$-...   F R ) ) ) )=K=U>>|++-- '001D1Dg1D1V1VWW hd2D99 -T +,,, - - - - - - - - - - - - - - - - - - h h h KKfA]ffbdff g g g g g g g g g hsH!!C B>1 C >CC CC D C;;Dtranscript_filecpd|_tjtj|}tj|}tj|rtj|tjs| d|ddSd} |j 5|j }|j }d|_ dddn #1swxYwYd} |D]} d} d} t| tr| j} | D]%} | r| |j| dz } d} | |j| dz } &| | z } t'j|j }t+t,||_ || |d }n.#t0$r!}| |d}Yd}~nd}~wwxYw|d z }| |d d z } |rn|j 5||_ ||_ dddn #1swxYwYn2#|j 5||_ ||_ dddw#1swxYwYwxYw|t7|kr|d |d t;|d5}|| dddn #1swxYwY|d krdnd}||d|d|dd|_dS#t@$r&}| d|d|Yd}~dSd}~wwxYw)z#H#H#H#HHg% dk22"6622  11$'5152DD )   KKOOODDDDDD ! foo//77UCCC E' + +& *  + + + + + + + + + + + + + + +' + +& *  + + + + + + + + + + + + + + + + #g,, & & MMj\jjj k k k $os++ 't :&&& ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 2>1B1B--HdF NNlbbVbbP_bbb c c c#D     S S S KKQQQRQQ R R R R R R R R R Ss?H8C( H8(C,,H8/C,0BH8 F&%H8& G0G H8 G9H8H,,H03H08I'I I'I I'"I #I'L'K = L K  LK L L5L00L5cd}tj|}|dtjddt jf|_|dtj d|j |S) N5Run a text editor and optionally open a file with it.r4r zTo set a new editor, run: zset editor file_pathz)optional path to a file to open in editorrO) rrr:rr7rHr8r;rrrr)rRedit_description edit_parsers rl_build_edit_parserzCmd._build_edit_parser[sR%=JZ[[[ (::  M,')?@       #<' !   rnc:||jdS)rN)rr )rkrms rldo_editz Cmd.do_editos '''''rnr c:|jstdtjtj|j}|r7|dtjtj|zz }||dS)zRun a text editor and optionally open a file with it. :param file_path: optional path of the file to edit. Defaults to None. :raises ValueError: if self.editor is not set zGPlease use 'set editor' to specify your text editing program of choice.rN)rr4rrr r rr)rkr rs rlrzCmd.run_editorus { hfgg g(27--dk::;;  E sRXbg&8&8&C&CDDD DG grnc.|jr |jdSdS)zMAccessor to get the current script directory from the _script_dir LIFO queue.rgN)rrjs rlr4zCmd._current_script_dirs"   (#B' 'trnctjddd}tj|}|dd|j|S)NzRun text script.r5zQScripts should contain one command per line, entered as you would in the console.r4rrrK)rr7rrrr)rRrun_script_descriptionrun_script_parsers rl_build_base_run_script_parserz!Cmd._build_base_run_script_parserse!%   _" "  ,CPfggg&& *' '   ! rncl|}|dddd|j|S)Nrrrz4record the output of the script as a transcript filer)rrr)rRrs rl_build_run_script_parserzCmd._build_run_script_parsersK==??&&  %G' '   ! rncLd|_tjtj|j}|dr7|d|d|dd}|dkrdS tj |d kr d |_dStj |s| d|d dSt|d 5}|}dddn #1swxYwYn3#t $r&}| d|d|Yd}~dSd}~wwxYwt#|j} |jtj||jr@||tj|j|jnv|||jd }d |_||j5|t#|jkr|jdddS#1swxYwYS |j5|t#|jkr|jdddn #1swxYwYnU#|j5|t#|jkr|jdddw#1swxYwYwxYwdS)zSRun text script. :return: True if running of commands should stop Frrz' appears to be a Python filerz,Continue to try to run it as a text script? rNrTz,' is not an ASCII or UTF-8 encoded text filerErzProblem accessing script from 'rrvr)rr r rrrrrr6getsizer" is_text_filer&rrrrrrrrrrrrrr) rkrmrrtargetscript_commandsrorig_script_dir_countrds rlrzCmd.do_run_scripts4 !(:(:4;K(L(LMM   ! !% ( (  MMJmJJJ K K K H.\]]IE!!t w}--22#' t%m44  [ [[[\\\tmg666 =&"(++--":":"<"< = = = = = = = = = = = = = = =    KKP-PPBPP Q Q Q44444 !$D$4 5 5 +   # #BGOOM$B$B C C C ))#G&&t77#'#>* ..##'#>/3/ $( ' + +(C0@,A,AAA$((*** + + + + + + + + + + + + + + + +' + +(C0@,A,AAA$((*** + + + + + + + + + + + + + + +' + +(C0@,A,AAA$((*** + + + + + + + + + + + + + + + +ts*E-E1E'D5) E5D99E<D9=E E1 E,,E1 B#K32I11I5 8I5 2KK KL!2L L!L L!L L!c|}ttt|jdd|_|dd|_|S)NrzIf this is called from within an already-running script, the filename will be interpreted relative to the already-running script's directory.r z>This command is intended to be used from within a text script.)rrrrr:r;)rRrelative_run_script_parsers rl!_build_relative_run_script_parserz%Cmd._build_relative_run_script_parsersm%(%F%F%H%H"27 2> ? ? R 2 2 ".-G,X,X  L- - ") *)rnc|j}tj|jpd|}|t j|S)zRun text script. This command is intended to be used from within a text script. :return: True if running of commands should stop rf)rr r r{r4rrr)rkrmr relative_paths rldo__relative_run_scriptzCmd.do__relative_run_scriptsI&  T%=%C[QQ !!"(="9"9:::rntranscript_pathsc ddl}ddl}ddl}ddlm}Gfdd|}t j|tj}|s dd_ dSd tttjdd }t!|} t!|dkrd nd } t%d jt)jt)ddtjd|d|jdt0dtjdtjdd| d| t)d|j_tjdgt_|} t;t<t jtj } |!| } |}| "| }||z }|#rs | $d d| d| d|dd}%t%|jt)jdS| $}|&d}||d&d }||z} ||dd_ dS)!a"Run transcript tests for provided file(s). This is called when either -t is provided on the command line or the transcript_files argument is provided during construction of the cmd2.Cmd instance. :param transcript_paths: list of transcript test file paths rNr) Cmd2TestCaseceZdZZdS)0Cmd._run_transcript_tests..TestMyAppCaseN)rqrrrscmdapprjsrl TestMyAppCaser'sFFFrnr))rz%No test files found - nothing to testrrfrzcmd2 transcript testrTrr\z platform z -- Python z, cmd2-z , readline-zcwd: z cmd2 app: z collected z transcript)stream)rr]z passed in z.3fz secondszAssertionError:zFile )'timeunittestcmd2rr%r"files_from_glob_patternsr R_OKr&rr{maprr version_inforr$rrrnullr __version__rRrrrrrrrr TextTestRunnerr wasSuccessfulrr*r)rkr#r,r-r.r%r)transcripts_expandedverinfonum_transcriptsrtestcaser+runner start_time test_resultsexecution_time finish_msg error_str end_of_trace file_offsetrs` rl_run_transcript_testszCmd._run_transcript_tests su                L    %=>NWYW^___#  KK? @ @ @DN F((3sC$4RaR$899::233/00A553 'DJejll S S ST"""     ppp'pp$JZppgnppqqq *RY[[**+++ /#(1+//000 F/FFfFFeY]N^N^N^ ___#7 HQK= =??fel3:6677(((77YY[[ zz(++ z1  % % ' '  KK 2TK : : :+gggg>ggggJ MM$zdj UUU V V V V V I$>>*;<)@)@ @ @VWW W $"3  F   % %u % 5 5( E$O '#r}'::: "y 9 9IT! "&%( '')) +"&dk*** %;;;;;; /%'%5%7%7022!133"...'        ...   """#$$$   & & ( ( ( ( (CDD Drnc2|d|dS)aUpdate the command line prompt while the user is still typing at it. This is good for alerting the user to system changes dynamically in between commands. For instance you could alter the color of the prompt to indicate a system status or increase a counter to report an event. If you do alter the actual text of the prompt, it is best to keep the prompt the same width as what's on screen. Otherwise the user's input text will be shifted and the update will not be seamless. If user is at a continuation prompt while entering a multiline command, the onscreen prompt will not change. However, self.prompt will still be updated and display immediately after the multiline line command completes. :param new_prompt: what to change the prompt to :raises RuntimeError: if called from the main thread. :raises RuntimeError: if called while another thread holds `terminal_lock` rfNrQ)rkrEs rlasync_update_promptzCmd.async_update_prompts " Z(((((rnc0|ddS)aRefresh the oncreen prompt to match self.prompt. One case where the onscreen prompt and self.prompt can get out of sync is when async_alert() is called while a user is in search mode (e.g. Ctrl-r). To prevent overwriting readline's onscreen search prompt, self.prompt is updated but readline's saved prompt isn't. Therefore when a user aborts a search, the old prompt is still on screen until they press Enter or this method is called. Call need_prompt_refresh() in an async print thread to know when a refresh is needed. :raises RuntimeError: if called from the main thread. :raises RuntimeError: if called while another thread holds `terminal_lock` rfNrSrjs rlasync_refresh_promptzCmd.async_refresh_prompts rnc~tr|jsdSt o|j o|jt kS)z\Check whether the onscreen prompt needs to be asynchronously refreshed to match self.prompt.F)rTrrPrrrOrjs rlrMzCmd.need_prompt_refreshsJ $"3 5%&&&nt/K+KnPTP[_l_n_nPnnrnrctsdSddlm} tj||tjdS#t$rYdSwxYw)zSSet the terminal window title. :param title: the new window title Nr) set_title_str)rTrNrYrrrrr)rrYs rlset_window_titlezCmd.set_window_titles   F111111  J  ]]511 2 2 2 J           DD sAA A'&A'c||jvrdStj|z}tj|z}tj|z}|j|}t |||j|jt||nt |||j|j t||nt |||j |j|=dS)zhEnable a command by restoring its functions. :param command: the command being enabled N) r"r r.r0r/rrrr~r)rkrrrrdcs rlrzCmd.enable_commands $0 0 0 F!5? "3g='=G #G ,mR%8999   # D. ) ) ) ) D."*: ; ; ;  ( D- . . . . D-r/D E E E  "7 + + +rnrc||jvrdSt|jD]H}|j|j}t |t jd|kr||I|j|=dS)z`Enable an entire category of commands. :param category: the category to enable N)r#rZr"rrr rwr)rkrrrs rlenable_categoryzCmd.enable_categorys 43 3 3 FT344 . .H)(3DDtY=tDDPP##H---  $X . . .rnrc ||jvrdS||}|td|dtj|z}tj|z}tj|z}t|t||dt||d|j|<tj |j | tj |}t|||t|||t||ddS)aDisable a command and overwrite its functions. :param command: the command being disabled :param message_to_print: what to print when this command is run or help is called on it while disabled The variable cmd2.COMMAND_NAME can be used as a placeholder for the name of the command being disabled. ex: message_to_print = f"{cmd2.COMMAND_NAME} is currently disabled" Nrz' does not refer to a commandr~)rcgSryru)_args_kwargss rlrez%Cmd.disable_command..%sRrn)r"rrr r.r0r/r}rrr _report_disabled_command_usagerF COMMAND_NAMEr)rkrrrrrrnew_funcs rlryzCmd.disable_commands/ d, , , F ==11  # !KW!K!K!KLL L!5? "3g='=G+:-!$==&t-@$GG+ + + w'$  /BRBZBZ[d[qszB{B{    mX...nh/// )+G+GHHHHHrnc||jvrdS|}|D]L}||}t|tjd|kr|||M||j|<dS)aDisable an entire category of commands. :param category: the category to disable :param message_to_print: what to print when anything in this category is run or help is called on it while disabled. The variable cmd2.COMMAND_NAME can be used as a placeholder for the name of the command being disabled. ex: message_to_print = f"{cmd2.COMMAND_NAME} is currently disabled" N)r#r2rrr rwry)rkrr all_commandsrrs rldisable_categoryzCmd.disable_category's t/ / / F,,.. $ A AH==**DtY=tDDPP$$X/?@@@-= ***rnrarbc4||ddS)zReport when a disabled command has been run or had help called on it. :param _args: not used :param message_to_print: the message reporting that the command is disabled :param _kwargs: not used Nr\)r&)rkrrarbs rlrcz"Cmd._report_disabled_command_usage=s! $D 11111rnctjtjurtdddl}||j}||j|jtj dst||j }||j |j ||j }||j |j |j|jD] }| ||j%|d|jDn>|r||_|jr||j||jD] }| ||j||j|tj ds6||j |||j ||jS)aDeal with extra features provided by cmd2, this is an outer wrapper around _cmdloop(). _cmdloop() provides the main loop. This provides the following extra features provided by cmd2: - transcript testing - intro banner - exit code :param intro: if provided this overrides self.intro and serves as the intro banner printed once at start z&cmdloop must be run in the main threadrNrcLg|]!}tj|"Sru)r r r)rDtfs rlrFzCmd.cmdloop..ls('`'`'`2(:(:2(>(>'`'`'`rn)rrKrLr rO getsignalrPrYrrrSIGHUPr_SIGTERMr!r"_preloop_hooksrhrrCrr$r1_postloop_hooksrkr!r)rkrrOoriginal_sigint_handleroriginal_sighup_handleroriginal_sigterm_handlerrs rlcmdloopz Cmd.cmdloopFsG  # % %Y-B-D-D D DGHH H  "("2"26="A"A fmT%8999|&&u-- K&,&6&6v}&E&E # MM&-)H I I I'-'7'7'G'G $ MM&.$*I J J J ""$$$'  D DFFFF   ! -  & &'`'`I_'`'`'` a a a a #" z ) TZ((( MMOOO(  D DFFFF  ""$$$  fm%<===|&&u-- D MM&-)@ A A A MM&.*B C C C~rncZg|_g|_g|_g|_g|_g|_dS)zInitialize the plugin system.N)rprqrzrrrrjs rlrzCmd._initialize_plugin_systems88:9;df]_`bxz###rnr.countc tj|}t|j}||kr)|dkrdnd}t |jd|d|d|dS)z5Ensure a function has the given number of parameters.rrfrz has z positional argument , expected N)rRrSrrTrrq)rRrrwrSnparamrs rl_validate_callable_param_countz"Cmd._validate_callable_param_countst%d++ Y)** U??!Q;;RRCFt}ii6iiviibgiijj j ?rnc||dt|\}}|t|jd|dS)z@Check parameter and return types for preloop and postloop hooks.rNz) must have a return type of 'None', got: )r{rWrrq)rRrrret_anns rl_validate_prepostloop_callablez"Cmd._validate_prepostloop_callablesV **4333t__ 7  t}``W^``aa a  rncd|||j|dS)zFRegister a function to be called at the beginning of the command loop.N)r~rprrkrs rlregister_preloop_hookzCmd.register_preloop_hooks3 ++D111 ""4(((((rncd|||j|dS)z@Register a function to be called at the end of the command loop.N)r~rqrrs rlregister_postloop_hookzCmd.register_postloop_hooks3 ++D111 ##D)))))rnc|ttdtf|dt |\}}|st |jdtt| }|tj krt |jd|tj krt |jddS)z7Check parameter and return types for postparsing hooks..rzJ parameter is missing a type hint, expected: 'cmd2.plugin.PostparsingData'zI must have one parameter declared with type 'cmd2.plugin.PostparsingData'zC must declare return a return type of 'cmd2.plugin.PostparsingData'N) r{rrr rWrrqnextiterrr!ry)rRr type_hintsr}par_anns rl_validate_postparsing_callablez"Cmd._validate_postparsing_callables **4c0BD+I+I1MMM'oo G zt}xxxyy ytJ--//0011 f, , ,t}wwwxx x f, , ,t}qqqrr r - ,rncd|||j|dS)zYRegister a function to be called after parsing user input but before running the command.N)rrzrrs rlregister_postparsing_hookzCmd.register_postparsing_hooks3 ++D111 &&t,,,,,rnCommandDataType data_typec|ttdtf|dt |\}}|st |jd|tt| \}}||krt d|jd|d||t |jd|||krt |jd |d|dS) z@Check parameter and return types for pre and post command hooks..r- parameter is missing a type hint, expected: zargument 1 of z has incompatible type ryNz0 does not have a declared return type, expected z has incompatible return type ) r{rrr rWrrqrrr)rRrrrr} _param_namers rl_validate_prepostcmd_hookzCmd._validate_prepostcmd_hooks **4c0BD+I+I1MMM'oo G ht}ff[dffgg g#D)9)9););$<$<== W i  rT]rrSZrrgprrss s ?t}ii^giijj j i  t}kkGkk`ikkll l rncz||tj|j|dS)z9Register a hook to be called before the command function.N)rr!rrrrs rlregister_precmd_hookzCmd.register_precmd_hooks8 &&tV-BCCC !!$'''''rncz||tj|j|dS)z8Register a hook to be called after the command function.N)rr!rrrrs rlregister_postcmd_hookzCmd.register_postcmd_hooks8 &&tV-CDDD ""4(((((rnc||dt|\}}|s#t|jdtjt t|\}}|tjkr&t|jdtjd||tjkr#t|jdtjdS)z@Check parameter and return types for command finalization hooks.rrz, must have one parameter declared with type z, got: z& must declare return a return type of N) r{rWrrqr!rrrr)rRrrr}rrs rl"_validate_cmdfinalization_callablez&Cmd._validate_cmdfinalization_callables **4333'oo G }t}{{[a[y{{|| |$z//112233 7 f4 4 4=~~fNl~~u|~~  f4 4 4t}ttTZTrttuu u 5 4rncd|||j|dS)zdRegister a hook to be called after a command is completed, whether it completes successfully or not.N)rrrrs rlregister_cmdfinalization_hookz!Cmd.register_cmdfinalization_hooks5 //555 #**400000rncmd_support_funccmd_selfcJt|}|t|tr|t||r|}ngd}g}|jD]>}t ||kr|}n&t||r||?|t|dkr|d}|S|S)a Attempt to resolve a candidate instance to pass as 'self'. Used for an unbound class method that was used when defining command's argparse object. Since we restrict registration to only a single CommandSet instance of each type, using type is a reasonably safe way to resolve the correct object instance. :param cmd_support_func: command support function. This could be a completer or namespace provider :param cmd_self: The `self` associated with the command or subcommand Nrr)rV issubclassr,rCrrBrr)rkrr func_class func_selfcandidate_setsinstalled_cmd_sets rl_resolve_func_selfzCmd._resolve_func_selfs (::J'K'K   !jZ&H&H !(J// 2$ ! 35)-)EAA%-..*<<$5 ""3Z@@A&--.?@@@$^)<)<)A)A .q 1I  rn)rNNro)rfry)r)r+)rqrrrsrtr" find_editorrr norm_foldr$ natural_keysNATURAL_SORT_KEYrrrZr__annotations__rrrrrrr,rrmrBrGrr1r0r1rrrStaticArgParseBuilderClassArgParseBuilderrr+rtr'rurvrrrr/rpropertyrnsetterrrUrmrrrrrrr rr r rrGr!r$rHr-r&r*rrr?rArUr_rrrqrwrrrrrrrrrYr[rrrr*rr rJrIrr9r2rAr(rErHrJr)rTr rYr_rZrArcrfrhrkrnrrr=rrrxrrr|rrrrr rrr r%rrrcr+r-r1r&r?r3 NamespacerErrVr2r`rkrsrwrrrrrrrrrrrrrrrrrrrrrr"r&r)r$r6r<r@rCrHrMrr`rrwrkrmrrrrrrrrrrrrrr rrr4rrrrr"rCrQrTrVrMrZrr^ryrhrcrurr{r~rrr!ryrrrrrrrrrrrrobjectrrurnrlrr&s)'U&((NL)&(IxS "'''N!# $ v6 (*)- ', !#-1"&/3(,+/48#( $(- "-v6v6v6v6}v6 v6 "% v6$'v6v6!%v6v6v6v6s)d*v6 v6!I,v6 #Y%!v6"S>D(#v6$z*T1%v6&!'v6()v6*"&+v6,-v6. /v6v6v6v6p ]b    Z0@  UY  fjkufv     ;; T@Q;;;;55550R:R$RRRRh  !/ 2x.. /0           D'9'93'9P['9fi'9sw'9'9'9'9R:C: :Z^::::0s0hy>Q0VZ0000+8Z+8D+8+8+8+8Z?:?$????>YE*e2C,DYYYYYv-eJ4E.F-4----^----X-# 2 2$ 2 2 2$# 2 73=1   X 2X2$2222 KC KD K K K K'T'T'T'TVR]X!2=!T!!!!WtWWWW++++X+"&48CTCTCTgCTCT CT  CT 4 CTCTCTCTCT+T1CTCT CTCTCTCTP"&48       4       +T1       B"+/48       4       +T1       F48             +T1       >48             +T1       84 44  4444r"&48,,,,, , 4 ,  ,,,,+T1,, ,,,,b"&48[[[[[ [ 4 [  [[[[[+T1[[ [[[[~UUUU&<"#<"s<"C<"ERVWZR[]abe]fRfLg<"<"<"<"|XXX X  X  } X cXXXX*P P P  P  P  } P P  cP P P P t:>/#/#/#/#/# /#  /# Xc]]::; /##&6/# c/#/#/#/#r:>///// /  / C#!>>? /3--/$6/ c////p59OOOOO O  OseTk*T1O cOOOOblq   s # s C dh uyz}u~    0O4sO4#O4sO4CO4[hO4mqrumvO4O4O4O4bWDIW%S SVBWWWW\W,;!;!*.s);!KN;! ;!;!;!;!z<49<<<<<@ X-D N`NrIs   \ x|pEpEpE"pE,/pE9<pEOTOmptOtpE pEpEpEpEdhhShhu?]`d?dhpsvzpzhhhhT444444T-c3h---X-49 $s)     d3i    T.-AT.-A ^0D    BcBBBB |c | | | |1141  11114T9Id <<<< [ C [I [ [ [ [ D Y_             McMeCcM&:MMMM $).$-1@@@@ @ #' @  @!$d @ @@@@Dt D@PUY. $+0 ###;$s)+# # %) #  ####JVZXXXXd X^gXXXXt[_333S3SSWZ3cl3333j&1 &1cDj&1&1&1&1Py!)y!8Sy!y!y!y!v@@uGb@gk@@@@:CC d(:CCCC"LP!3!3!3 C!3D!3TX!3!3!3!3Ftd{"ctCyEEd EEEE%)050D0I %(,7;*.15]#]#]#]#cT! ]# - ]#  ]##%]#.4]#!4']#'$.]# ]#]#]#]#~))))))&&!'=&!&!&!&!PP3IPdPPPP (D(D(D(D^ !3   \  ^'>>>X/D?>#+=###[#Bgx)CJhiii  ("4      ji  F #+= # # #[ #gx)CJZ[[[F("4FFFF\[F&!);!!![!*gv'?nUUU5 25t555VU5D>>> >  > c >>>>, !3   \  ^'>>>X/D?>>#+=>#>#>#[>#@gx)CJghhhK ("4K K K K ihK \ #+= # # #[ #gx)C/ZZZF("4FFFF[ZF&!);!!![!*gv'?mTTT5 25t555UT5<N#NSN#NsNW[\_W`NNNNii"i,/i9<iJNsTXY\T]~J^i ciiii %UX]a2>s>$s)>VZ>_c>>>>@99tCy4'799UX9999v & &$s)d"2 &3 &PT & & & &`%7```\`^+,, h0 T   -, 1\^%&& * td{   '& ] 2]]]\]^&''+t (' 1t1t3c?T%S4Z2H-II1tSV1tmp1t1t1t1tf'9[,NN"N,/N9<NJNsTXY\T]~J^N cNNNN> "4   [ ^%t<<<98-9$999=<9v$6[^'>>>61X/61D616161?>61p,,,\,*8+=8-8888tO-ODOOOOB59tttsTztTD[ttttlg0ggg\g^$%%"x)"dTk"""&%" #+= # # #[ #^.//H$64$;0/Bh#5hhh\h^)**E *E td{E E E +*E N<&8<<<[<|^)**Xx1XdTkXXX+*Xt!38W0[ ;4$; ; ; ;76 ;>d3i>D>>>>@CECESCEcDjCEDCECECECEJ)c)d))))&"oToooo\",c,d,,,,@////// &Is&Ic&Id&I&I&I&IP>>>>>>>,2S2C2\_2dh2222CC^CSCCCCT{{{{k(382DkSkUYkkk[kb(2t82Dbbbb[b)(2t8*<))))) *8BH+=*$****  s(F?mLPQ`Lam mmm[m((63H2I6K`2`)a(fj(((( )(F4J3KVMc3c*d)im)))) vV;\\]v vvv[v 1f<=v?]]^1 11112"38,2 E4/02 $ 222222rn)rtrrrrrrRr rrrrrrr collectionsrrcollections.abcrrrtypesr r typingr r r rrrrrrich.boxr rich.consolerrrich.highlighterr rich.ruler rich.stylerr rich.tablerr rich.textrrich.tracebackrrfrrr r!r"r#rr$rr%r&r'r( clipboardr)r*command_definitionr+r,r-r.r/r0 decoratorsr1r2r3 exceptionsr4r5r6r7r8r9r:r;r|r<r=r>parsingr?r@rArBrCrDrErFrGstylesrHrr rrJrl_utilsrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYr r rr,r^r_r(rgrZr\r]r^rrWrr`rin_dllrarr&rrercrwr}rrrrrrrrurnrlrs7:   ######                     -,,,,,''''''''$$$$$$                         Z%%&&%%%%%%&&&&&&&&&&&&&&&                         fkCJ'''--j @Q-RRRR 3X244N&###"*+"2"G FJ         %+O$:$: