Repository: snek5000/snek5000 (language: python)

Issue:
Add command snek5000-info (similar to fluidinfo)
In all tutorials, we have a subsection "Versions used in this tutorial" with the same code. I think it would be better to have and use a command `snek5000-info` to print information about the current environment (versions of related packages).


Discussion / hints:

Fix patch:
diff --git a/docs/tuto_cbox.md b/docs/tuto_cbox.md
index 22a8bc34..ac0283f9 100644
--- a/docs/tuto_cbox.md
+++ b/docs/tuto_cbox.md
@@ -162,11 +162,5 @@ field.temperature.mean('x').plot();
 ## Versions used in this tutorial
 
 ```{code-cell}
-import snakemake
-snakemake.__version__
-```
-
-```{code-cell}
-import snek5000
-snek5000.__version__
+!snek5000-info
 ```
diff --git a/docs/tuto_phill.md b/docs/tuto_phill.md
index fe8d7ac7..5b3b52b8 100644
--- a/docs/tuto_phill.md
+++ b/docs/tuto_phill.md
@@ -156,16 +156,5 @@ are saved in directories "session_00", "session_01", etc.
 ## Versions used in this tutorial
 
 ```{code-cell}
-import snakemake
-snakemake.__version__
-```
-
-```{code-cell}
-import snek5000
-snek5000.__version__
-```
-
-```{code-cell}
-import phill
-phill.__version__
+!snek5000-info
 ```
diff --git a/docs/tuto_phill_setup.md b/docs/tuto_phill_setup.md
index 929f6a6b..b85db159 100644
--- a/docs/tuto_phill_setup.md
+++ b/docs/tuto_phill_setup.md
@@ -117,16 +117,5 @@ Let's check that the .par, .box and SIZE file are present:
 <!-- #endregion -->
 
 ```{code-cell}
-import snakemake
-snakemake.__version__
-```
-
-```{code-cell}
-import snek5000
-snek5000.__version__
-```
-
-```{code-cell}
-import phill
-phill.__version__
+!snek5000-info
 ```
diff --git a/docs/tuto_tgv.md b/docs/tuto_tgv.md
index 095402f9..b02aef30 100644
--- a/docs/tuto_tgv.md
+++ b/docs/tuto_tgv.md
@@ -160,3 +160,9 @@ ax.set(
     title=f"Taylor-Green vortex: evolution of K.E. and enstrophy. Re={-sim.params.nek.velocity.viscosity}"
 );
 ```
+
+## Versions used in this tutorial
+
+```{code-cell}
+!snek5000-info
+```
diff --git a/setup.cfg b/setup.cfg
index ece193fa..0f5d1d3c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -46,6 +46,7 @@ snek5000.solvers =
     kth = snek5000.solvers.kth
 console_scripts =
   snek5000-config-init = snek5000.config:ensure_config_file
+  snek5000-info = snek5000.util.console:print_versions
 
 [options.extras_require]
 docs =
diff --git a/src/snek5000/util/__init__.py b/src/snek5000/util/__init__.py
index 399bdac6..5415cc32 100644
--- a/src/snek5000/util/__init__.py
+++ b/src/snek5000/util/__init__.py
@@ -5,6 +5,7 @@
    :toctree:
 
    archive
+   console
    files
    restart
    smake
diff --git a/src/snek5000/util/console.py b/src/snek5000/util/console.py
new file mode 100644
index 00000000..57f45fc9
--- /dev/null
+++ b/src/snek5000/util/console.py
@@ -0,0 +1,26 @@
+"""Console script functions
+
+"""
+
+from snek5000.solvers import available_solvers
+
+
+def print_versions():
+
+    import snakemake
+    import pymech
+    import fluidsim_core
+    import fluiddyn
+    import snek5000
+
+    versions = {"Package": "Version", "-------": "-------"}
+
+    packages = [snek5000, fluiddyn, fluidsim_core, pymech, snakemake]
+    for package in packages:
+        versions[package.__name__] = package.__version__
+
+    for pkg_name, version in versions.items():
+        print(f"{pkg_name.ljust(15)} {version}")
+
+    names = sorted(set([entry_point.name for entry_point in available_solvers()]))
+    print("\nInstalled solvers: " + ", ".join(names))


Test patch:
diff --git a/tests/test_console.py b/tests/test_console.py
new file mode 100644
index 00000000..e3517362
--- /dev/null
+++ b/tests/test_console.py
@@ -0,0 +1,5 @@
+from snek5000.util.console import print_versions
+
+
+def test_info():
+    print_versions()