Skip to content

Commit

Permalink
[app] Add --env-help command line option
Browse files Browse the repository at this point in the history
Add a new CLI option to print the available Meshroom environment
variables and their descriptions.
  • Loading branch information
yann-lty committed Dec 20, 2024
1 parent b268b8e commit 9ef0003
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions meshroom/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

__all__ = [
"EnvVar",
"EnvVarHelpAction",
]

import argparse
import os
from dataclasses import dataclass
from enum import Enum
Expand Down Expand Up @@ -51,3 +53,18 @@ def _cast(value: str, valueType: Type) -> Any:
return value.lower() in {"true", "1", "yes"}
return valueType(value)

@classmethod
def help(cls) -> str:
"""Return a formatted string with the details of each environment variables."""
return "\n".join([f"{var.name}: {var.value}" for var in cls])


class EnvVarHelpAction(argparse.Action):
"""Argparse action for printing Meshroom environment variables help and exit."""

DEFAULT_HELP = "Print Meshroom environment variables help and exit."

def __call__(self, parser, namespace, value, option_string=None):
print("Meshroom environment variables:")
print(EnvVar.help())
sys.exit(0)
10 changes: 9 additions & 1 deletion meshroom/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from meshroom.core.taskManager import TaskManager
from meshroom.common import Property, Variant, Signal, Slot

from meshroom.env import EnvVar
from meshroom.env import EnvVar, EnvVarHelpAction

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

advanced_group = parser.add_argument_group("Advanced Options")
advanced_group.add_argument(
"--env-help",
action=EnvVarHelpAction,
nargs=0,
help=EnvVarHelpAction.DEFAULT_HELP,
)

return parser.parse_args(args[1:])


Expand Down

0 comments on commit 9ef0003

Please sign in to comment.