From 01f0cd38509ded169d72fa8500954f170807b7dc Mon Sep 17 00:00:00 2001 From: konsthol Date: Mon, 27 Mar 2023 21:32:55 +0300 Subject: [PATCH] I don't believe it --- README.md | 13 +++++++------ assets/pages/usage/usage.md | 24 ++++++++++++++++++++++++ secdep.py | 2 ++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05e4090..7dd9413 100644 --- a/README.md +++ b/README.md @@ -60,15 +60,16 @@ For AWS you firstly need an [account](https://aws.amazon.com/account/) and then # Dependencies 📦 -We would have 3 external dependecies but due to missing functionality in libcloud when it comes to Azure management we need 6. +We would have 4 external dependecies but due to missing functionality in libcloud when it comes to Azure management we need 7. -1. [libcloud](https://github.com/apache/libcloud) -2. [python-dotenv](https://github.com/theskumar/python-dotenv) +1. [libcloud](https://github.com/apache/libcloud) which is the main dependency to connect to the cloud providers +2. [python-dotenv](https://github.com/theskumar/python-dotenv) which is used to read the `.env` file 3. [paramiko](https://github.com/paramiko/paramiko) which is actually needed for the deployment of libcloud 4. [azure-sdk-for-python](https://github.com/Azure/azure-sdk-for-python) from which we need - 1. [azure-identity](https://pypi.org/project/azure-identity/) - 2. [azure-mgmt-resource](https://pypi.org/project/azure-mgmt-resource/) - 3. [azure-mgmt-network](https://pypi.org/project/azure-mgmt-network/) + 1. [azure-identity](https://pypi.org/project/azure-identity/) to authenticate with Azure + 2. [azure-mgmt-resource](https://pypi.org/project/azure-mgmt-resource/) to manage Azure resources + 3. [azure-mgmt-network](https://pypi.org/project/azure-mgmt-network/) to manage Azure networks +5. [shtab](https://github.com/iterative/shtab) which is used to generate bash and zsh completion scripts # Installation 🛠️ diff --git a/assets/pages/usage/usage.md b/assets/pages/usage/usage.md index 83ead8b..6d0c732 100644 --- a/assets/pages/usage/usage.md +++ b/assets/pages/usage/usage.md @@ -190,3 +190,27 @@ To do that you can simply run `python3 secdep.py -P aws --awsregion -a If you can, prefer a better ssh client. To SSH into a virtual machine you get the choice from `python3 secdep.py -ssh` or `python3 secdep.py -P gce -ssh` to only choose from the gce instances. + +# Generating shell completion scripts 🐚 + +To generate shell completion scripts you can run + +`python3 secdep.py --print-completion zsh` + +or + +`python3 secdep.py --print-completion bash` + +according to your shell of choice. + +To use the completion scripts you need to put them in the right place for each shell after we save the output to a file. + +For example, if you are using zsh and you aliased the command to `secdep` you can run + +`secdep --print-completion zsh > _secdep && sudo mv _secdep /usr/share/zsh/site-functions` + +Then when you reload your shell you can use the completion scripts. + +For bash the command would be `secdep --print-completion bash > secdep && sudo mv secdep /etc/bash_completion.d` + +Then make sure in your `.bashrc` or `.bash_profile` you have `source /etc/bash_completion.d/secdep` and reload your shell diff --git a/secdep.py b/secdep.py index fdaba37..546e866 100755 --- a/secdep.py +++ b/secdep.py @@ -21,6 +21,7 @@ import os import sys import argparse +import shtab import time import paramiko import socket @@ -54,6 +55,7 @@ parser = argparse.ArgumentParser( prog='secdep.py', description='Manage cloud instances', ) +shtab.add_argument_to(parser, ["-comp", "--print-completion"]) parser.add_argument('-l', '--list', help='List all instances or with -P PROVIDER list a provider\'s instances', action='store_true') parser.add_argument('-e', '--edit', help='Change credential values', action='store_true') parser.add_argument('-v', '--version', help='Show secdep\'s version', action='store_true')