diff --git a/pipcompilemulti/features/controller.py b/pipcompilemulti/features/controller.py index c842561..fe52100 100644 --- a/pipcompilemulti/features/controller.py +++ b/pipcompilemulti/features/controller.py @@ -20,6 +20,7 @@ from .live_output import LiveOutput from .extra_index_url import ExtraIndexUrl from .build_isolation import BuildIsolation +from .emit_trusted_host import EmitTrustedHost class FeaturesController: @@ -46,6 +47,7 @@ def __init__(self): self.live_output = LiveOutput() self.extra_index_url = ExtraIndexUrl() self.build_isolation = BuildIsolation() + self.emit_trusted_host = EmitTrustedHost() self._features = [ self.annotate_index, self.use_cache, @@ -66,6 +68,7 @@ def __init__(self): self.live_output, self.extra_index_url, self.build_isolation, + self.emit_trusted_host ] def bind(self, command): @@ -92,6 +95,7 @@ def pin_options(self, in_path): options.extend(self.annotate_index.pin_options()) options.extend(self.extra_index_url.pin_options()) options.extend(self.build_isolation.pin_options()) + options.extend(self.emit_trusted_host.pin_options()) return options def compose_input_file_path(self, basename): diff --git a/pipcompilemulti/features/emit_trusted_host.py b/pipcompilemulti/features/emit_trusted_host.py new file mode 100644 index 0000000..dd042db --- /dev/null +++ b/pipcompilemulti/features/emit_trusted_host.py @@ -0,0 +1,31 @@ +""" +Add trusted host annotation +======================== + +This flag provides the ability to annotate the trusted host mimicking the logic of +the ``pip-compile`` ``--emit-trusted-host`` and ``--no-emit-trusted-host`` flag +by opting to add or not add the ``pip`` trusted host to the generated files. + +.. code-block:: text + + --emit-trusted-host / --no-emit-trusted-host Add trusted host to generated files (default true) + +Note the default behavior is to add the trusted host, i.e., ``--emit-trusted-host``. +""" + +from .base import ClickOption +from .forward import ForwardOption + + +class EmitTrustedHost(ForwardOption): + """Optionally add the trusted host to the generated files.""" + + OPTION_NAME = 'emit_trusted_host' + CLICK_OPTION = ClickOption( + long_option='--emit-trusted-host/--no-emit-trusted-host', + is_flag=True, + default=True, + help_text="Add trusted host option to generated file" + ) + enabled_pin_options = ['--emit-trusted-host'] + disabled_pin_options = ['--no-emit-trusted-host']