o .&ßaã@sôddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZe e¡ZeƒZdd„Zdd„Zdd„Zdd„Zdd„ZGdd„de ƒZ dS)éN)Úget_global_history_recorder)ÚProfileNotFound)Úsqlite3)Ú BasicCommand)ÚHISTORY_FILENAME_ENV_VAR)ÚDEFAULT_HISTORY_FILENAME)ÚDatabaseConnection)ÚDatabaseRecordWriter)Ú RecordBuilder)ÚDatabaseHistoryHandler)Ú ShowCommand)Ú ListCommandcCó| dt¡dS)Nzsession-initialized)ÚregisterÚattach_history_handler©Úevent_handlers©rúH/usr/lib/python3/dist-packages/awscli/customizations/history/__init__.pyÚregister_history_mode$óÿrcCr)Nzbuilding-command-table.main)rÚadd_history_commandsrrrrÚregister_history_commands)rrcKs‚t||ƒr?t d¡tj tt¡}tj  tj  |¡¡s$t  tj  |¡¡t |ƒ}t |ƒ}tƒ}t||ƒ}t |¡t ¡dSdS)NzEnabling CLI history)Ú_should_enable_cli_historyÚLOGÚdebugÚosÚenvironÚgetrrÚpathÚisdirÚdirnameÚmakedirsrr r r ÚHISTORY_RECORDERÚ add_handlerÚenable)ÚsessionÚ parsed_argsÚkwargsÚhistory_filenameÚ connectionÚwriterÚrecord_builderÚ db_handlerrrrr.s  ÿ   òrcCsb|jdkrdSz| ¡}Wn tyYdSw| d¡dk}|r/tdur/|r-tj d¡dS|S)NÚhistoryFÚ cli_historyÚenabledzRcli_history is enabled but sqlite3 is unavailable. Unable to collect CLI history. )ÚcommandÚget_scoped_configrrrÚsysÚstderrÚwrite)r&r'Ú scoped_configÚhas_history_enabledrrrr@s   û ÿrcKst|ƒ|d<dS)Nr.)ÚHistoryCommand)Ú command_tabler&r(rrrrVsrc@s0eZdZdZdZdedœdedœgZdd„ZdS) r8r.zþCommands to interact with the history of AWS CLI commands ran over time. To record the history of AWS CLI commands set ``cli_history`` to ``enabled`` in the ``~/.aws/config`` file. This can be done by running: ``$ aws configure set cli_history enabled``Úshow)ÚnameÚ command_classÚlistcCs|jdur tdƒ‚dS)NzVusage: aws [options] [parameters] aws: error: too few arguments)Ú subcommandÚ ValueError)Úselfr'Úparsed_globalsrrrÚ _run_mainhs ÿzHistoryCommand._run_mainN) Ú__name__Ú __module__Ú __qualname__ÚNAMEÚ DESCRIPTIONr r Ú SUBCOMMANDSrBrrrrr8Zsÿþ r8)!rr3ÚloggingÚbotocore.historyrÚbotocore.exceptionsrÚ awscli.compatrÚawscli.customizations.commandsrÚ'awscli.customizations.history.constantsrrÚ awscli.customizations.history.dbrr r r Ú"awscli.customizations.history.showr Ú"awscli.customizations.history.listr Ú getLoggerrCrr#rrrrrr8rrrrÚs.