Impl --yes flag
This commit is contained in:
@@ -347,6 +347,10 @@ def ensureUnmuxOutputDirectory(context, outputDirectory):
|
||||
if context.get('dry_run', False):
|
||||
return False
|
||||
|
||||
if context.get('yes', False):
|
||||
os.makedirs(resolvedOutputDirectory, exist_ok=True)
|
||||
return True
|
||||
|
||||
if not confirmUnmuxOutputDirectoryCreation(resolvedOutputDirectory):
|
||||
raise click.ClickException("Unmux output directory creation aborted by user.")
|
||||
|
||||
@@ -876,6 +880,12 @@ def getUnmuxSequence(trackDescriptor: TrackDescriptor, sourcePath, targetPrefix,
|
||||
@click.option('-l', '--label', type=str, default='', help='Label to be used as filename prefix')
|
||||
@click.option("-o", "--output-directory", type=str, default='', help=UNMUX_OUTPUT_DIRECTORY_OPTION_HELP)
|
||||
@click.option("-s", "--subtitles-only", is_flag=True, default=False)
|
||||
@click.option(
|
||||
"--yes",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Create a missing unmux output directory without prompting.",
|
||||
)
|
||||
@click.option(
|
||||
'--nice',
|
||||
type=int,
|
||||
@@ -897,6 +907,7 @@ def unmux(ctx,
|
||||
label,
|
||||
output_directory,
|
||||
subtitles_only,
|
||||
yes,
|
||||
nice,
|
||||
cpu):
|
||||
from ffx.file_properties import FileProperties
|
||||
@@ -912,6 +923,7 @@ def unmux(ctx,
|
||||
ctx.obj['resource_limits']['niceness'] = nice
|
||||
ctx.obj['resource_limits']['cpu_limit'] = cpu
|
||||
ctx.obj['resource_limits']['cpu_percent'] = cpu
|
||||
ctx.obj['yes'] = bool(yes)
|
||||
|
||||
output_directory, requires_output_directory = resolveUnmuxOutputDirectory(
|
||||
ctx.obj,
|
||||
|
||||
@@ -174,10 +174,10 @@ class UnmuxCliTests(unittest.TestCase):
|
||||
self.home_dir,
|
||||
self.database_path,
|
||||
"--subtitles-only",
|
||||
"--yes",
|
||||
"--label",
|
||||
"dball",
|
||||
str(source_path),
|
||||
input_text="y\n",
|
||||
)
|
||||
self.assertCompleted(completed)
|
||||
|
||||
|
||||
@@ -122,6 +122,20 @@ class UnmuxOutputDirectoryTests(unittest.TestCase):
|
||||
mocked_getchar.assert_called_once()
|
||||
mocked_confirm.assert_not_called()
|
||||
|
||||
def test_yes_creates_missing_output_directory_without_prompt(self):
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
output_directory = Path(tempdir) / "missing" / "parents" / "manual"
|
||||
|
||||
with patch("ffx.cli.click.confirm") as mocked_confirm:
|
||||
created = cli.ensureUnmuxOutputDirectory(
|
||||
{"dry_run": False, "yes": True},
|
||||
str(output_directory),
|
||||
)
|
||||
|
||||
self.assertTrue(created)
|
||||
self.assertTrue(output_directory.is_dir())
|
||||
mocked_confirm.assert_not_called()
|
||||
|
||||
def test_missing_output_directory_can_be_rejected(self):
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
output_directory = Path(tempdir) / "missing" / "manual"
|
||||
|
||||
Reference in New Issue
Block a user