diff --git a/abst/__version__.py b/abst/__version__.py index bbb75ae..b67c320 100644 --- a/abst/__version__.py +++ b/abst/__version__.py @@ -10,7 +10,7 @@ "CLI Command making OCI Bastion and kubernetes usage simple and fast" ) -__version__ = "2.1.9" +__version__ = "2.2.0" __author__ = "Jiri Otoupal" __author_email__ = "jiri-otoupal@ips-database.eu" __license__ = "MIT" diff --git a/abst/bastion_support/oci_bastion.py b/abst/bastion_support/oci_bastion.py index fef9d57..b0f4922 100644 --- a/abst/bastion_support/oci_bastion.py +++ b/abst/bastion_support/oci_bastion.py @@ -11,6 +11,7 @@ import oci import rich +from bext import title from oci.exceptions import ServiceError from abst.config import default_creds_path, \ @@ -170,6 +171,8 @@ def create_forward_loop(self, shell: bool = False): Bastion.shell = shell print(f"Loading Credentials for {self.get_print_name()}") creds = self.load_self_creds() + title(f'abst to {creds["default-name"]} port {creds["local-port"]}') + self.current_status = "creating bastion session" try: diff --git a/abst/cli_commands/context/commands.py b/abst/cli_commands/context/commands.py index 8b0950e..802bc32 100644 --- a/abst/cli_commands/context/commands.py +++ b/abst/cli_commands/context/commands.py @@ -5,7 +5,9 @@ import pyperclip import rich +from abst.bastion_support.oci_bastion import Bastion from abst.config import default_contexts_location, share_excluded_keys +from abst.tools import get_context_path from abst.utils.misc_funcs import get_context_data, setup_calls @@ -47,5 +49,19 @@ def share(name, debug=False): data.pop(key) data["default-name"] = "!YOUR NAME!" rich.print_json(data=data) - logging.info("Data transmitted into clipboard") + logging.debug("Data transmitted into clipboard") pyperclip.copy(str(data)) + + +@context.command(help="Will paste context from clipboard into provided context name") +@click.option("--debug", is_flag=True, default=False) +@click.argument("name") +def paste(name, debug=False): + setup_calls(debug) + + data = pyperclip.paste() + path = get_context_path(name) + if data is None: + return + Bastion.write_creds_json(data, path) + rich.print(f"Wrote config into ~/.abst/contexts/{name}.json") diff --git a/requirements.txt b/requirements.txt index c743fa5..5de21a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ oci~=2.90.0 setuptools~=60.2.0 semantic-version~=2.10.0 eventlet~=0.33.2 -pyperclip~=1.8.2 \ No newline at end of file +pyperclip~=1.8.2 +bext~=0.0.8 \ No newline at end of file diff --git a/setup.py b/setup.py index 5270cff..d0cbd85 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,8 @@ packages=find_packages(), include_package_data=True, python_requires=">=3.7,<4", - install_requires=["click", "rich", "inquirerpy", "oci", "lastversion", "semantic_version", "eventlet", "pyperclip"], + install_requires=["click", "rich", "inquirerpy", "oci", "lastversion", "semantic_version", "eventlet", "pyperclip", + "bext"], extras_require={ "dev": ["black==22.*"], },