Skip to content

Commit 58e41e1

Browse files
committed
[app] Add --env-help command line option
Add a new CLI option to print the available Meshroom environment variables and their descriptions.
1 parent 2bdf753 commit 58e41e1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

meshroom/env.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
__all__ = [
66
"EnvVar",
7+
"EnvVarHelpAction",
78
]
89

10+
import argparse
911
import os
1012
from dataclasses import dataclass
1113
from enum import Enum
@@ -51,3 +53,18 @@ def _cast(value: str, valueType: Type) -> Any:
5153
return value.lower() in {"true", "1", "on"}
5254
return valueType(value)
5355

56+
@classmethod
57+
def help(cls) -> str:
58+
"""Return a formatted string with the details of each environment variables."""
59+
return "\n".join([f"{var.name}: {var.value}" for var in cls])
60+
61+
62+
class EnvVarHelpAction(argparse.Action):
63+
"""Argparse action for printing Meshroom environment variables help and exit."""
64+
65+
DEFAULT_HELP = "Print Meshroom environment variables help and exit."
66+
67+
def __call__(self, parser, namespace, value, option_string=None):
68+
print("Meshroom environment variables:")
69+
print(EnvVar.help())
70+
sys.exit(0)

meshroom/ui/app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from meshroom.core.taskManager import TaskManager
1818
from meshroom.common import Property, Variant, Signal, Slot
1919

20-
from meshroom.env import EnvVar
20+
from meshroom.env import EnvVar, EnvVarHelpAction
2121

2222
from meshroom.ui import components
2323
from meshroom.ui.components.clipboard import ClipboardHelper
@@ -185,6 +185,14 @@ def createMeshroomParser(args):
185185
+ '\n'.join([' - ' + p for p in meshroom.core.pipelineTemplates]),
186186
)
187187

188+
advanced_group = parser.add_argument_group("Advanced Options")
189+
advanced_group.add_argument(
190+
"--env-help",
191+
action=EnvVarHelpAction,
192+
nargs=0,
193+
help=EnvVarHelpAction.DEFAULT_HELP,
194+
)
195+
188196
return parser.parse_args(args[1:])
189197

190198

0 commit comments

Comments
 (0)