]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/dev/archery/archery/utils/cli.py
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
22 from .source
import ArrowSources
, InvalidArrowSource
25 class ArrowBool(click
.types
.BoolParamType
):
27 ArrowBool supports the 'ON' and 'OFF' values on top of the values
28 supported by BoolParamType. This is convenient to port script which exports
29 CMake options variables.
33 def convert(self
, value
, param
, ctx
):
34 if isinstance(value
, str):
35 lowered
= value
.lower()
38 elif lowered
== "off":
41 return super().convert(value
, param
, ctx
)
44 def validate_arrow_sources(ctx
, param
, src
):
46 Ensure a directory contains Arrow cpp sources.
49 return ArrowSources
.find(src
)
50 except InvalidArrowSource
as e
:
51 raise click
.BadParameter(str(e
))
54 def add_optional_command(name
, module
, function
, parent
):
56 module
= importlib
.import_module(module
, package
="archery")
57 command
= getattr(module
, function
)
58 except ImportError as exc
:
59 error_message
= exc
.name
64 "allow_extra_args": True,
65 "ignore_unknown_options": True,
69 raise click
.ClickException(
70 f
"Couldn't import command `{name}` due to {error_message}"
73 parent
.add_command(command
)