switch-lazy-cli is a command-line tool designed to simplify the process of searching work logs on Enfocus Switch. If you frequently switch between a GUI and the terminal while coding, you know how inconvenient it can be to check logs manually. This tool streamlines the process, allowing you to access logs quickly and efficiently.
switch-lazy-cli depends on a few common Linux/Unix utilities. Ensure that your system has the following tools installed:
-
Basic utilities:
vim
,emacs
(text editors),cat
(print files),mkdir
,touch
,mv
,rm
,echo
,printf
-
Additional libraries:
- JQ - A JSON processor
- JTBL - JSON to table converter
-
Most importantly:
- You must have Enfocus Switch with API support (from 2018).
First, clone this repository:
git clone https://github.com/yourusername/switch-lazy-cli.git
cd switch-lazy-cli
Navigate to the folder where swo.sh
is located and make it executable:
chmod +x swo.sh
Copy the script to /usr/local/bin
to make it accessible from anywhere:
sudo cp swo.sh /usr/local/bin/swo
-
Create a configuration file at:
$HOME/.config/switchOrchestrator/swo_config
Or run:
swo -c
-
Add the following information to the configuration file:
USER="joe" HASH_PASS="XXXXXXXXXXXXXXXX" SWITCH_IP="0.0.0.0"
To authenticate, you need to generate an encrypted password hash.
-
Create a
enfocuspublic_key.pem
file. -
Copy the PUBLIC KEY from the Enfocus Switch - Auth Documentation.
-
Run the following command to encrypt your password:
echo -n "REPLACEYOURPASSWORDHERE" | openssl rsautl -encrypt -pubin -inkey ./enfocuspublic_key.pem | base64
⚠ Warning:
If you are unfamiliar with RSA encryption, research before proceeding. Encryption operations should be performed at your own risk.
Check it
Authenticate and generate an authentication token:
swo -a
This command stores the token, which is necessary for making API calls.
Retrieve details about a specific job:
swo -j JOBNUMBER
Example Output:
^ type ^ flow ^ job ^ element ^ message ^ timestamp ^
| info | test-flow live | | New Job | Added unique name prefix, new name is '_J79O5_test-job swo.xml' | 2024-02-17T00:06:22.617Z |
| info | test-flow live | test-job swo.xml | XML action | Metadata was attached to asset '/Users/_J79O5_test-job swo.xml' | 2024-02-17T00:06:22.744Z |
| info | test-flow live | test-job swo.xml | XML action | File _J79O5_test-job swo.xml was renamed to file _J79O5_test-job swo.xml | 2024-02-17T00:06:22.750Z |
Retrieve the status, name, and groups of existing flows:
swo -f
Example Output:
^ status ^ name ^ groups ^
| running | Example A | INPUT |
| stopped | Example B | ACTION |
| running | Example C | ACTION |
| stopped | Example D | MACHINE |
Color-coding:
- ✅ Running flows → Green
- ❌ Stopped flows → Red
Option | Description |
---|---|
-a, --auth |
Authenticate and obtain a token |
-j <string>, --job <string> |
Search for a job |
-h, --help |
Display help information |
-i, --install |
Create configuration folders |
-f, --flows |
List flows and statuses |
I'm far from an expert, and I believe there are many ways to improve this project. If you have ideas, feel free to fork the repository and send a pull request!
This project was developed using insights from:
- Formatting JSON as a Table using JQ
- How to Write a Great README
- Enfocus Switch API Authentication
- Makefile Tutorial
- Authentication
- Search by Jobs
- Search using different parameters
- Refresh search results
- List workflows
- Start/Stop workflows
- Support for multiple Enfocus Switch instances
- Environment support?
- Synchronize multiple scripts between environments
- Migrate to Python?
📌 Note:
This project is NOT actively evolving, and any suggestions or improvements are highly welcome! 🚀