summaryrefslogtreecommitdiff
path: root/src/buildstream/_frontend/cli.py
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-07-26 16:06:03 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-07-29 10:42:02 +0100
commitb632e471f1ca4764c15534006294f7dc0b842b69 (patch)
tree0b7a1782b8e7054ba2bfb05aeeedb6f0c1e26dd6 /src/buildstream/_frontend/cli.py
parent0f074dd37524047cb53214be5c0f10436d3abb1d (diff)
downloadbuildstream-b632e471f1ca4764c15534006294f7dc0b842b69.tar.gz
context: Move scheduler actions to an Enum
Also add helpers for the cli to be able to represent 'FastEnum' directly
Diffstat (limited to 'src/buildstream/_frontend/cli.py')
-rw-r--r--src/buildstream/_frontend/cli.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 12b9439cf..5de02918f 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -10,10 +10,25 @@ from .. import _yaml
from .._exceptions import BstError, LoadError, AppError
from .._versions import BST_FORMAT_VERSION
from .complete import main_bashcomplete, complete_path, CompleteUnhandled
+from ..types import _SchedulerErrorAction
from ..utils import _get_compression, UtilError
##################################################################
+# Helper classes and methods for Click #
+##################################################################
+
+class FastEnumType(click.Choice):
+
+ def __init__(self, enum):
+ self._enum = enum
+ super().__init__(enum.values())
+
+ def convert(self, value, param, ctx):
+ return self._enum(super().convert(value, param, ctx))
+
+
+##################################################################
# Override of click's main entry point #
##################################################################
@@ -234,7 +249,7 @@ def print_version(ctx, param, value):
type=click.Path(file_okay=False, readable=True),
help="Project directory (default: current directory)")
@click.option('--on-error', default=None,
- type=click.Choice(['continue', 'quit', 'terminate']),
+ type=FastEnumType(_SchedulerErrorAction),
help="What to do when an error is encountered")
@click.option('--fetchers', type=click.INT, default=None,
help="Maximum simultaneous download tasks")