Skip to main content

Table of Contents generated with DocToc

Overview

As 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.

The ecli app 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.

Design

The ecli app is made up of two major components:

  • A base command module written in python
  • Plugins that extend the base command module

The plugin system essentially allows contributers to define namespaces of commands, along with their corresponding subcommands.

Features

  • Commands 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 for
    the given scripts/executables contained therein
  • Subcommands follow a dot-notation style of reference, e.g.
    pluginfolder.namespace.command 1

Installation

Prerequisites

You'll need python3 & pip for the pip distribution.

To install,

  • For Windows:
    • choco
      1. Start an elevated powershell prompt and run the following commands:
      2. Set-Variable -Name "ChocolateyInstall" -Value "$(Join-Path -Path $Env:LocalAppData -ChildPath chocolatey)"
      3. New-Item $ChocolateyInstall -Type Directory -Force
      4. [Environment]::SetEnvironmentVariable("ChocolateyInstall", $ChocolateyInstall)
      5. Set-ExecutionPolicy Bypass -Scope Process iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
    • Microsoft C++ Build Tools: choco install visualstudio2017buildtools
      Or 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.4
  • For Linux, just install python3 via your distro's package manager.
  • For OSX, if not already present, I recommend you install python3 via the brew package manager

Back to Top

Installing ecli

There are two distributions of the ecli

  1. python package: Installed via pip3 install btecli
  2. The Windows bundled executable, available via Releases
    Note that the bundled executable can be slow to initialize.
    This is because python itself is bundled into the ecli binary
    The python package runs much faster, as there
    is no need unpacking resources.
    Also, it has a much slower release cadence.
  3. If you are behind a corporate proxy, and get SSL errors when installing, try your installation command with the --trusted-host flags, as with:
pip3 install \
--trusted-host=pypi.org \
--trusted-host=github.com \
--trusted-host=files.pythonhosted.org \
btecli

The next section will cover Plugins.

Back to Top

Plugin Architecture

As mentioned before, the ecli plugins extend the base command module. That is, for every plugin detected, a new ecli subcommand is made available.

Creating Plugins

Plugins 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 Plugins

Invoke the plugins.install built-in subcommand to install a given plugin repo. The syntax is ecli 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.plugins

Once you've installed a plugin repo, run ecli to get the list of newly available subcommands

The usage examples in the following sections assume you've installed the plugin repository above.

Back to Top

Usage examples

Usage examples - Utilizing Windows Credentials Manager

We'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-mgr

Once the Windows Credential manager is in view,

  • Click Windows Credentials
  • Then click Add generic credential
    • Internet 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 $username and $password during command runtime.

Back to Top

Appendix

Sub-Command naming logic

As mentioned in the previous sections, commands follow a dot-notation style of reference,
e.g. pluginfolder.namespace.command.

Of note is that the pluginfolder prefix only takes effect for
plugin folders not bearing a name similar to ecli.plugins e.g. a plugin folder
named foo will yield plugins conforming to foo.namespace.command.

However, if a plugin folder name matches the regular expression ecli.plugins[\W]+?|ecli.plugins,
its effective name will be stripped of that pattern, i.e. the following plugin folders:

  • ecli.plugins
  • ecli.plugins-fork
  • ecli.plugins01
  • ecli.plugins-02
  • ecli.plugins.new

will yield sub-commands with the following dot-notation (respectively):

  • namespace.command
  • fork.namespace.command
  • 01.namespace.command
  • 02.namespace.command
  • new.namespace.command

Metadata

Release files for btecli 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for btecli 2.0.0
File Size Uploaded Provenance Actions
btecli-2.0.0.tar.gz 39.4 kB Without provenance Details for btecli-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for btecli 2.0.0
File Interpreter ABI Platform Actions
btecli-2.0.0-py3-none-any.whl Python 3 none any Details for btecli-2.0.0-py3-none-any.whl

Total release size: 61.8 kB

Release files / btecli-2.0.0.tar.gz

Download URL btecli-2.0.0.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2b6a7f08e0cbd4a3aeadcc0cdb016e8b16ca69c2ddaeb034953dca9edb76939b
BLAKE2b-256 checksum
How to use checksums
20ce5745e301ba1c2bcd98462393c704f3e8c6cc347b5a5164f4d61ee0dcb4f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / btecli-2.0.0-py3-none-any.whl

Download URL btecli-2.0.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b6c44b17a8440ec27f57ea8ca3eb1c717e074aad11199a4a4a707fca32702aa
BLAKE2b-256 checksum
How to use checksums
623c2c1056172ecc2e01e943a42072c10373594399d391ca82009ebd41f533cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for btecli 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page