From 0ec4efb9eb2cfd8008daf3909deb8ad0c57bfe4f Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 29 Jan 2026 15:59:19 +0100 Subject: [PATCH 1/5] update README for 'eessi shell' --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e0b585..0236669 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ To see which commands this would evaluate, just run `eessi init`. Create subshell in which EESSI is available and initialised -*(to be implemented)* +```shell +eessi shell +``` ## Design goals From 759bbfdfde660f2c415fc8057dad6ba9f7aeae27 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 29 Jan 2026 16:28:39 +0100 Subject: [PATCH 2/5] require that EESSI version to use is specified in 'eessi shell' via --eessi-version option --- eessi/cli/shell.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/eessi/cli/shell.py b/eessi/cli/shell.py index 6c9bd70..b6e6e2e 100644 --- a/eessi/cli/shell.py +++ b/eessi/cli/shell.py @@ -7,20 +7,35 @@ import tempfile import typer from rich import print as rich_print +from typing import Annotated app = typer.Typer() +def report_error(msg, exit_code:int=1): + """ + Report error and exit with specified non-zero exit code + """ + if exit_code <= 0: + raise ValueError("Exit code should be positive non-zero integer") + rich_print(f"[bold red]{msg}", file=sys.stderr) + sys.exit(exit_code) + + @app.command() -def shell(): +def shell( + eessi_version: Annotated[str, typer.Option(help="EESSI version")] = '', +): """ Create subshell in which EESSI is available and initialised """ + if not eessi_version: + report_error("EESSI version to use is not specified, which is required!") + init_file = tempfile.mkstemp()[1] with open(init_file, 'w') as fp: - fp.write("set -e; source /cvmfs/software.eessi.io/versions/2023.06/init/bash") + fp.write(f"set -e; source /cvmfs/software.eessi.io/versions/{eessi_version}/init/bash") res = subprocess.run(['/bin/bash', '--init-file', init_file]) if res.returncode != 0: - rich_print("[bold red]ERROR: Non-zero exit code detected for interactive shell!", file=sys.stderr) - sys.exit(res.returncode) + report_error("ERROR: Non-zero exit code detected for interactive shell!", exit_code=res.returncode) From 3d5b31f16a32cf3881122e07e8ccf93da43629cc Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 29 Jan 2026 16:30:27 +0100 Subject: [PATCH 3/5] document that EESSI version to use must be specified in 'eessi shell' --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0236669..2168ccb 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,11 @@ To see which commands this would evaluate, just run `eessi init`. Create subshell in which EESSI is available and initialised ```shell -eessi shell +eessi shell --eessi-version 2025.06 ``` +You *must* specify the EESSI version to use, there is no default value for this. + ## Design goals * Easy to install and use. From c36fbf46677d90f4e599efcc323757fe80f9aeb4 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 29 Jan 2026 16:42:55 +0100 Subject: [PATCH 4/5] only complain about exit code value *after* printing error message --- src/eessi/cli/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eessi/cli/shell.py b/src/eessi/cli/shell.py index b6e6e2e..f3a65be 100644 --- a/src/eessi/cli/shell.py +++ b/src/eessi/cli/shell.py @@ -16,9 +16,9 @@ def report_error(msg, exit_code:int=1): """ Report error and exit with specified non-zero exit code """ - if exit_code <= 0: - raise ValueError("Exit code should be positive non-zero integer") rich_print(f"[bold red]{msg}", file=sys.stderr) + if exit_code <= 0: + raise ValueError(f"Exit code should be positive non-zero integer, got {exit_code}") sys.exit(exit_code) From 675ebab3dd1ff2cfa423828134c489592322531e Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 29 Jan 2026 16:44:10 +0100 Subject: [PATCH 5/5] fix weird code style rules for typed function arguments --- src/eessi/cli/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eessi/cli/shell.py b/src/eessi/cli/shell.py index f3a65be..50f1a4e 100644 --- a/src/eessi/cli/shell.py +++ b/src/eessi/cli/shell.py @@ -12,7 +12,7 @@ app = typer.Typer() -def report_error(msg, exit_code:int=1): +def report_error(msg, exit_code: int = 1): """ Report error and exit with specified non-zero exit code """