Package: clicol
CLI colorizerThis project is to colorize output of command line interface for devices where CLI is not colored by default. Goal is to ease troubleshooting and make output more pretty.INSTALLYou will need python 2.6+/3 and pexpecttelnet and/or ssh should be installedI recommend installingvirtualenvand installclicolinto that virtual environment:pip install virtualenvvirtualenv ~/mypythonsource ~/mypython/bin/activatepip install clicolOR (after pulling git source)pip install clicol-xxxx.zipTo get clicol source:git clone https://github.com/realvitya/clicol ~/clicolcd ~/clicolCopyclicol.cfgto your $HOME directory and modify to your needsUSAGERun the scriptclicol-telnetorclicol-sshand specify arguments as for the telnet/ssh.Run the scriptclicol-cmdand any command with arguments to pimp up any non-colored cli command.Available command line option for clicol:clicol-{telnet|ssh} [--c {colormap}] [--cfgdir {dir}] [--caption {caption}] [args]clicol-file         [--c {colormap}] [--cfgdir {dir}] {inputfile}clicol-cmd          [--c {colormap}] [--cfgdir {dir}] {command} [args]clicol-test         [--c {colormap}] [--cfgdir {dir}] [--plugins] {colormap regex (.*, common.*, etc)}Explanation for arguments:--c {colormap}: use only specified colormap (all,common,cisco,juniper) Defaulted toall--cfgdir {dir}: use specified config directory. Defaulted to~/.clicol--caption {caption}: use this caption template (you can use%(host)sfor connected device and%(hostname)sfor actual host name) Defaulted to%(host)s--plugins: run also plugin testsclicol can be run on Windows incygwin. If you want to useSecureCRT, you must enable sshd incygwinand connect to localhost. It is not necessary to be administrator on the desktop for this to work. You must bind to localhost and use port number >1024.By default clicol will colorize with all colorsets and this behaviour can be tuned in config file. The config file can be saved in user directory and it will take preference over defaults.Default break key is CTRL-\After hitting the break key you have some options:p - pausing coloringg - toggle pasteguardq - quit from sessionh - print helpT - highlight regex (set regex in runtime to highligh something important)F1-F12 keys are shortcuts for various commands. Examples are in example config file or try help 'h' key. Shortcuts for SHIFT+F1-F8 are only working if your terminal supports this. ForSecureCRTyou may setup mapped keys for these to work. (forPuttyI don't know yet how to implement this)Note: If you installed into virtualenv then you must first activate it:source ~/mypython/bin/activateConsider using aliases. A basic template can be found indocfolder.Your terminal software should support ANSI colors.Putty/SecureCRTare tested. I am developing with default colorsets. If you are using other software, colors can differ somewhat.FEATURESA bit more detail on the builtin features. All features are available in the session when pressing CTRL-\ break keysequence.Pause coloringThis feature turns off all modifications and features on the output. The only available feature which continues working is the break key CTRL-\ .
You can toggle it by hitting the command.PasteguardThis feature tries to prevent you from pasting configuration with errors. It will stop pasting when device return errors.
You can also stop pasting by hitting CTRL-C.Note: error detection is through matchers which provides paste_error effect. You can add your own!HighlightThis feature allows you to search for a given text snippet by specifying a regex. The specified text will be highlighted
in the output. Useful if you are searching for something in a large output. It will catch your eyes!TESTINGYou can list all supported matchers and see them in action. This is good to create a list of matcher and filter on those only. This way one can select the preferred matchers if finds all of them disturbing. Run the scriptclicol-test {regex}Use case examples:List all matcher:clicol-test ".*"List only BGP matchers:clicol-test ".*bgp.*"List only certain matchers:clicol-test ".*ipv4|cisco_if_stats|juniper_if"Then the desired regex can be specified in the clicol.cfg in your $HOME and only these matchers will be used.Output can be tested by runningclicol-file {filename}script. This will colorize the textfile and dump it. Good for testing.Plugins can be tested by calling with--pluginsargument:clicol-test --pluginsCUSTOMIZINGYou can override or extend the colors and regexes so you can modify default behaviour and view. This can be done by creating the customized files in the format below. You may find examples in default ini files herels -l $VIRTUAL_ENV/lib/python2*/site-packages/clicol/iniDefault configuration directory is$HOME/.clicol. All configuration or plugin file should be in that directory! Configuration files in the user directory will override the .clicol directory files!Custom colorsclicol_customcolors.iniThis file is for overriding extending current colorset. Example:[colors]
c_blue     :\033[94mCustom colortableclicol_customct.iniThis file is for overriding or extending keywords for colors. Example:[colortable]
#add blinking to high alert color:
highalert              = %(c_blink)s%(c_u_lred)sCustom colormapclicol_customcmap.iniThis file is for overriding or extending rules for recoloring/matching.
Example:#disable ipv6 coloring
[common_ipv6]
disabled=1

#alter coloring for 'shutdown'
[common_shut]
#replacement=%(alert)s\1%(default)s
replacement=%(lowalert)s\1%(default)sYou can test your changes:clicol-test common_shutPLUGINSIt is possible to extend CLICOL's capabilities with plugins. The main idea is that plugins can have external dependencies and can do external calls to manipulate output. Currently two functions are called from CLICOL to a plugin:preprocessandpostprocess. These are to be called before CLICOL colorization and after so a plugin can have a chance to see the text and manipulate it at these points.For example implementation you may check the builtin plugin in thebuiltinpluginsfolder or external projects like the followings:AS path resolverExtra pluginsInstalling pluginAfter installing the plugin with pip, it must be activated in$HOME/.clicol/plugins.cfgconfiguration file. If that file did not exist or the section does not exist for the plugin, it won't be loaded.Section name must be the plugin name in lower case!Exampleplugins.cfg:[humannumbers]
  # Disable HumanNumbers by default:
  active=noCLICOL reserved attribute isactive. Any other can be used by the plugins. Ifactiveis not present or has positive value, then the plugin will be loaded. If the section isnotexisting for a given plugin, it is considered as disabled.Develop pluginsThere is a documentation about how to develop plugins for CLICOL atwiki pageLicense and Copyrightclicolis licensedGPLv3Copyright Viktor Kertesz, 2017-2020Authorclicolwas written by Viktor Kertesz
(vkertesz2 [at] gmail [/dot] com).