Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cdb0d97
Rework loop prevent off-by-one errors and potentially dropped errors
codeconscious Nov 13, 2026
a6e17c7
Prefer Result.iterError over simple 'match'
codeconscious Nov 13, 2026
1fd642d
Don't both print and return error message
codeconscious Nov 13, 2026
94892f6
Return NextAction from orchestrator for more accurate error codes
codeconscious Nov 13, 2026
cc42ca0
Prevent settings shadowing causing stale settings
codeconscious Nov 13, 2026
d83d1ca
Heavy Orchestrator refactor
codeconscious Nov 13, 2026
75c3d0f
Minor tweaks
codeconscious Nov 13, 2026
19fab23
Remove duplicated error message
codeconscious Nov 13, 2026
a6be704
Delete RegisterResult string overload
codeconscious Nov 13, 2026
755e8b7
Delete superfluous ResultTracker<BatchResults>
codeconscious Nov 13, 2026
c080b4d
RegisterResult() accepts any success type
codeconscious Nov 13, 2026
908fc6d
Rename variable
codeconscious Nov 14, 2026
c0c8227
Rename func to extractValueFromCommand
codeconscious Nov 14, 2026
73cf675
Tweak audio-quality block
codeconscious Nov 14, 2026
4237627
Use Result.map in update-quality block
codeconscious Nov 14, 2026
6d99072
Replace Result.map with monad CE
codeconscious Nov 14, 2026
d8d7d6a
Remove unneeded audio-quality error branch
codeconscious Nov 14, 2026
83c76f1
Remove superfluous empty-string check
codeconscious Nov 14, 2026
7edb2bb
Use monad CE in audio-format updating too
codeconscious Nov 14, 2026
dc6c9f5
Improve 'invalid audio format' error message
codeconscious Nov 14, 2026
dcd66e9
Rename currentSettings params to settings
codeconscious Nov 14, 2026
8818756
Minor code formatting
codeconscious Nov 14, 2026
b489ae5
Unify int casts
codeconscious Nov 14, 2026
1836383
Add and use Printer.Info() overload
codeconscious Nov 14, 2026
dc98df6
Shorten func name
codeconscious Nov 14, 2026
5895fef
Delete unused ResultTracker instance
codeconscious Nov 14, 2026
b1b4781
Only sleep between URL inputs
codeconscious Nov 14, 2026
ec1476c
Add and use Printer.Warning() overload
codeconscious Nov 14, 2026
cef343a
Update packages
codeconscious Nov 14, 2026
db5808d
Rename variable
codeconscious Nov 14, 2026
a3017c6
Use List.singleton over List.cons
codeconscious Nov 14, 2026
8dd1d7c
Improve display of URL indexes in messages
codeconscious Nov 15, 2026
c7cfb8b
Adjust empty lines; rename Printer type's methods
codeconscious Nov 15, 2026
e34f85e
Minor code layout tweaks
codeconscious Nov 15, 2026
baecc08
Remove unneeded parens
codeconscious Nov 16, 2026
2839d6f
Merge remote-tracking branch 'refs/remotes/origin/refactor-orchestrat…
codeconscious Nov 16, 2026
8cd32ae
Add PrintOptions.DefaultWithLineBefore
codeconscious Nov 16, 2026
cf2aebc
Use Option.ofPair with TryParse
codeconscious Nov 16, 2026
1c4324c
Remove PrintOptions.LineAfter
codeconscious Nov 17, 2026
91e41e0
Heavy rework of temp file confirmation and deletion; etc.
codeconscious Nov 18, 2026
ed9b77a
Rename YesNoAnswer to ConfirmationAnswer, and remove 'option'
codeconscious Nov 18, 2026
712bae4
Refactor isWorkingDirReady
codeconscious Nov 18, 2026
48ea4be
Tweak message
codeconscious Nov 20, 2026
e1fe555
Minor code tweaks
codeconscious Nov 20, 2026
5f2f4e3
Minor code tweaks
codeconscious Nov 20, 2026
3065eb2
Minor code layout
codeconscious Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CCVTAC.Main/CCVTAC.Main.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CCFSharpUtils" Version="0.4.8" />
<PackageReference Include="CCFSharpUtils" Version="0.5.0" />
<PackageReference Include="CodeConscious.Startwatch" Version="1.0.0" />
<PackageReference Include="FSharpPlus" Version="1.9.1" />
<PackageReference Include="FsToolkit.ErrorHandling" Version="5.2.0" />
<PackageReference Include="Spectre.Console" Version="0.57.2" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Update="FSharp.Core" Version="10.1.403" />
<PackageReference Update="FSharp.Core" Version="11.0.101" />
</ItemGroup>
</Project>
18 changes: 7 additions & 11 deletions src/CCVTAC.Main/Downloading/Updater.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ module Updater =

let run (printer: Printer) userSettings : unit =
if String.hasNoText userSettings.DownloaderUpdateCommand then
printer.Info "No downloader update command provided, so will skip."
printer.Info "No downloader update command provided, so will skip updating."
else
let toolSettings = ToolSettings.create userSettings.DownloaderUpdateCommand
userSettings.WorkingDirectory

let executionResult = Runner.runTool printer toolSettings []

match executionResult with
match Runner.runTool printer toolSettings [] with
| Ok details ->
if details.ExitCode <> successExitCode then
match details.Error with
| Some errMsg -> $"Update completed with minor issues: {errMsg}"
| None -> "Update completed with minor unspecified issues."
|> printer.Warning
printer.EmptyLine()
printer.Warning <|
match details.Error with
| Some errMsg -> $"Update completed with minor issues: {errMsg}"
| None -> "Update completed with minor unspecified issues."
| Error msg ->
let printOptions = { PrintOptions.Default with AppendLines = 1uy }
printer.Error($"Failure updating: {msg}", printOptions)
printer.Error $"Update failure: {msg}"
7 changes: 4 additions & 3 deletions src/CCVTAC.Main/History.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open CCFSharpUtils.Text
open System
open System.IO
open System.Text.Json
open FSharpPlus
open Spectre.Console

type History(filePath: string, displayCount: int) =
Expand Down Expand Up @@ -39,9 +40,9 @@ type History(filePath: string, displayCount: int) =
|> Seq.choose (fun line ->
match line.Split separator with
| [| dateText; url |] ->
match DateTime.TryParse dateText with
| true, date -> Some (date, url)
| _ -> None
DateTime.TryParse dateText
|> Option.ofPair
|> Option.map (fun date -> (date, url))
| _ -> None)
|> Seq.groupBy fst
|> Seq.map (fun (dt, pairs) -> dt, pairs |> Seq.map snd |> Seq.toList)
Expand Down
14 changes: 8 additions & 6 deletions src/CCVTAC.Main/IoUtilities/Directories.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module Directories =
[<Literal>]
let private allFilesSearchPattern = "*"

[<Literal>]
let maxFilesToShow = 10

/// Counts the number of audio files in a directory.
let audioFileCount dirName includedExtensions =
DirectoryInfo(dirName).EnumerateFiles()
Expand Down Expand Up @@ -46,10 +49,9 @@ module Directories =
|> Result.map delete

/// Ask the user to confirm the deletion of files in the specified directory.
let askToDeleteAllFiles (printer: Printer) dirName =
if printer.AskToBool("Delete all temporary files?", "Yes", "No")
then deleteAllFiles dirName
else Error "Will not delete the files."
let confirmDeleteFiles (printer: Printer) : ConfirmationAnswer =
let answer = printer.AskToBool("Delete all temporary files?", "Yes", "No")
if answer then Proceed else Decline "Temporary file deletion was declined."

let printDeletionResults (printer: Printer) (results: ResultMessages) : unit =
printer.Info $"Deleted %s{String.fileLabel results.Successes.Length}."
Expand All @@ -66,12 +68,12 @@ module Directories =
if Array.isEmpty fileNames then
Ok ()
else
SB($"Unexpectedly found {String.fileLabel fileNames.Length} in working directory \"{dirName}\":{String.nl}")
SB($"""Found {String.plur' "leftover file" S fileNames.Length} in working directory "{dirName}":{String.nl}""")
.AppendLine
(fileNames
|> Array.truncate showMax
|> Array.map (sprintf "• %s")
|> String.concat String.nl)
|> String.concatNL)
|> fun sb ->
if fileNames.Length > showMax
then sb.AppendLine $"... plus {fileNames.Length - showMax} more."
Expand Down
2 changes: 1 addition & 1 deletion src/CCVTAC.Main/IoUtilities/Files.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Files =

let imageFileExts = [".jpg"; ".jpeg"]

let filterByExt ext fs = fs |> List.filter (String.endsWithIgnoreCase ext)
let filterByExt ext fs = fs |> List.filter (String.endsWith' ext)

let readAllText (filePath: string) : Result<string, string> =
ofTry (fun _ -> File.ReadAllText filePath)
Expand Down
Loading