Skip to main content

A CLI tool to manage SSH connections and VSCode projects

Project description

yocli

yocli is a command-line interface (CLI) tool designed to simplify your development workflow by managing SSH connections and opening VSCode projects. This documentation will guide you through installation, configuration, usage, and advanced features of yocli.

Table of Contents

Features

  • SSH Management: Establish and manage multiple SSH tunnels simultaneously, with local or remote access options.
  • VSCode Project Launcher: Launch your development projects in VSCode from a predefined list.
  • Interactive Menu: User-friendly CLI with an interactive interface for easy selection of SSH connections and VSCode projects.

Compatibility

yocli is supported on:

  • Linux
  • macOS
  • WSL (Windows Subsystem for Linux)

Note: yocli does not support Windows. If you are a Windows user, consider running yocli in a Linux-based virtual machine or WSL (Windows Subsystem for Linux).

Installation

To install yocli as a command-line tool, run the following command:

pip install yocli-tools

Configuration

yocli uses a configuration file (yocli.yml) to define SSH connections and VSCode projects. Below is an example configuration:

services:
  vscode:
    - name: App
      commands:
        - code /path/to/my-repo

    - name: App 2
      commands:
        - code --remote ssh-remote+home /path/to/my-repo

  ssh:
    - name: home
      host: myserver.com
      port: 3456
      host-local: 192.168.3.2
      port-local: 22
      user: me
      identity_file: ~/.ssh/id_rsa
      ports:
        - 3000:3000

    - name: home-2
      host: myserver2.com
      port: 3457
      host-local: 192.168.3.3
      port-local: 22
      user: me
      identity_file: ~/.ssh/id_rsa
      ports:
        - 8080:8080

Configuration Fields

  • vscode: List of VSCode projects with commands to open them.

  • ssh: List of SSH connections, each with:

    • name: The name of the SSH connection.
    • host and host-local: Remote and local addresses.
    • port and port-local: Remote and local ports.
    • user: The SSH user.
    • identity_file: The private key for authentication.
    • ports: List of port forwarding rules.

Command-Line Argument for Custom Configuration

yocli allows you to specify a custom configuration file using the --config command-line argument. If no configuration file is specified, yocli will search for a configuration file in the following default locations:

  1. User's config directory: ~/.config/yocli/yocli.yml
  2. Home Directory: ~/.yocli.yml
  3. Current Directory: yocli.yml

If no configuration file is found, yocli will raise an error prompting you to provide a valid configuration file.

Example Usage

To run yocli with a custom configuration file:

yocli --config /path/to/custom_config.yml

Usage

To run yocli, simply type the following command in your terminal:

yocli

You will be greeted with an interactive menu that allows you to:

  • Connect to SSH servers.
  • Disconnect from active SSH connections.
  • Launch VSCode projects.
  • Exit the tool.

Interactive Menu Example

When you run yocli, you'll see an interactive menu that looks like this:

Hi, welcome. Choose your action:

*SSH connections:*
> Connect to home
  Connect to home-2

*VSCode projects:*
  App
  App 2

  Exit

How to Use

  1. SSH Connections:
  • Select "Connect to [name]" to establish an SSH tunnel. If the connection is already active, selecting it again will disconnect it.
  • Multiple SSH connections can be active simultaneously, as long as their port configurations do not overlap.
  1. VSCode Projects:
  • Select a project from the list to open it in VSCode. The commands for each project are predefined in the configuration file.
  1. Exit:
  • Select "Exit" to close all active SSH connections and exit the tool.

Advanced Usage

Running Multiple SSH Connections

yocli allows you to manage multiple SSH connections at the same time, as long as the port forwarding configurations do not overlap. You can connect to one or more SSH servers by selecting them from the interactive menu.

Port Forwarding

Each SSH connection in the configuration file includes a list of port forwarding rules. These rules allow you to forward local ports to remote services running on the server, making it easy to access those services from your local environment.

Troubleshooting

  • SSH Connection Fails: Make sure that the host, user, and identity_file are correctly specified in the configuration. Check your network connectivity.
  • Ports Already in Use: If a port is already in use, modify the port forwarding rules in the configuration file to avoid conflicts.
  • VSCode Projects Not Opening: Ensure VSCode is installed and accessible from your command line (code command should work).

Local Development

To run yocli locally, clone the repository and install the dependencies:

# Clone the repository
git clone git@github.com:yoannes/yocli.git

# Change to the project directory
cd yocli

# Create a virtual environment
python3 -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install the dependencies
pip install -r requirements.txt

# Install yocli in editable mode
pip install -e .

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Contributing

Feel free to submit issues or pull requests to help improve yocli.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yocli_tools-0.1.3.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yocli_tools-0.1.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file yocli_tools-0.1.3.tar.gz.

File metadata

  • Download URL: yocli_tools-0.1.3.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for yocli_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 30045c6a3dfa761d4bf094ffca90ee00643dfac85602cb8bc45111a7996e5860
MD5 9154dcd9610757068b72f874644f67d0
BLAKE2b-256 ddb3460cc43f5db966e7383873beef5388fa460f8a2fd52d1198e55394bcfabf

See more details on using hashes here.

File details

Details for the file yocli_tools-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: yocli_tools-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for yocli_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16fe22f3cea13b9a79f34d88c0150cd9dcf446aeed12bfa85e3dc5fa720188ed
MD5 3e2902476c1d6bec2f2b37b5a7eca0ea
BLAKE2b-256 945fd23dd2ea24856522b77a7c662e792d419a7578406d2561ba15f602669759

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page