Package: btecli
Table of Contentsgenerated withDocTocOverviewDesignFeaturesPlugin ArchitectureCreating PluginsInstalling PluginsUsage examplesUsage examples - Utilizing Windows Credentials ManagerInstallationPrerequisitesecliAppendixSub-Command naming logicOverviewAs systems engineers, we spend much of our time on our command-line terminals
interacting with a myriad of systems in support of the overarching infrastructure.Our daily tasks can often be repetitive,
which is why we often find ourselves utilizing
or creating automation to lessen our keystrokes.This brings us to a question:What do you get when each member of a team of engineers has an affinity
for creating their own little scripts to make their lives easier?Hint: It's something messy.Theecliapp aims to clean up this proclivity for command-line mess in the team setting
by unifying disparate pieces of automation into a single entrypoint, thus
creating a homogenous command-line experience.This is accomplished by a modular design that can accomodate just about any executable
piece of code.The following sections go over this in detail.DesignTheecliapp is made up of two major components:A base command module written in pythonPlugins that extend the base command moduleThe plugin system essentially allows contributers to
define namespaces of commands, along with their corresponding
subcommands.FeaturesCommands are executables organized by subfolders in a given plugin directory(See the Appendix for list of supported executable types)Subfolders are interpreted as the namespace name forthe given scripts/executables contained thereinSubcommands follow a dot-notation style of reference, e.g.pluginfolder.namespace.command1InstallationPrerequisitesYou'll need python3 & pip for the pip distribution.To install,For Windows:chocoStart an elevated powershell prompt and run the following commands:Set-Variable -Name "ChocolateyInstall" -Value "$(Join-Path -Path $Env:LocalAppData -ChildPath chocolatey)"New-Item $ChocolateyInstall -Type Directory -Force[Environment]::SetEnvironmentVariable("ChocolateyInstall", $ChocolateyInstall)Set-ExecutionPolicy Bypass -Scope Process iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))Microsoft C++ Build Tools:choco install visualstudio2017buildtoolsOr Install the latest from the Microsoft Website:https://visualstudio.microsoft.com/visual-cpp-build-tools/python 3.7.x:choco install python --version=3.7.4For Linux, just install python3 via your distro's package manager.For OSX, if not already present, I recommend you install
python3 via thebrewpackage managerBack to TopInstalling ecliThere are two distributions of theeclipython package: Installed viapip3 install btecliThe Windows bundled executable, available viaReleasesNote that the bundled executable can be slow to initialize.This is because python itself is bundled into the ecli binaryThe python package runs much faster, as thereis no need unpacking resources.Also, it has a much slower release cadence.If you are behind a corporate proxy, and get SSL errors
when installing, try your installation command with
the--trusted-hostflags, as with:pip3install\--trusted-host=pypi.org\--trusted-host=github.com\--trusted-host=files.pythonhosted.org\btecliThe next section will cover Plugins.Back to TopPlugin ArchitectureAs mentioned before, the ecli plugins extend the base command module.
That is, for every plugin detected, a new ecli subcommand is made available.Creating PluginsPlugins are really easy to create, as they are simply executable
files neatly organized into folders bearing the name of
the plugin's namespace.You need only enough proficiency to write a script in either bash,python, powershell, or ruby to get started.
I will eventually add binaries (e.g. golang, Windows .exe's)
and rust to the mix.Installing PluginsInvoke theplugins.installbuilt-in subcommand to install a
given plugin repo. The syntax isecli plugins.install -S -r <gitrepo>.You can install my plugin repo to start:ecli plugins.install -S -r https://github.com/berttejeda/bert.ecli.plugins.git -a ecli.pluginsOnce you've installed a plugin repo, runeclito get
the list of newly available subcommandsThe usage examples in the following sections
assume you've installed the plugin repository above.Back to TopUsage examplesUsage examples - Utilizing Windows Credentials ManagerWe'll be demonstrating ecli's integration with
Windows Credential Manager.The first step is to create Windows Generic Credentials
a given subcommand.You can do that by launching credential
manager via ecli:ecli system.launcher -n cred-mgrOnce the Windows Credential manager is in view,Click Windows CredentialsThen click Add generic credentialInternet or network address: {{ name_of_subcommand }}User name: {{ username }}Password: {{ password }}With these populated, ecli should be able to read
from the Windows credential store when you
call the given subcommand with the--use-cred-mgr flag.Doing so will populate variables$usernameand$passwordduring command runtime.Back to TopAppendixSub-Command naming logicAs mentioned in the previous sections, commands follow a dot-notation style of reference,e.g.pluginfolder.namespace.command.Of note is that thepluginfolderprefix only takes effect forplugin folders not bearing a name similar toecli.pluginse.g. a plugin foldernamedfoowill yield plugins conforming tofoo.namespace.command.However, if a plugin folder name matches the regular expressionecli.plugins[\W]+?|ecli.plugins,its effective name will be stripped of that pattern, i.e. the following plugin folders:ecli.pluginsecli.plugins-forkecli.plugins01ecli.plugins-02ecli.plugins.newwill yield sub-commands with the following dot-notation (respectively):namespace.commandfork.namespace.command01.namespace.command02.namespace.commandnew.namespace.command