diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2022-07-29 20:10:48 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2022-07-29 20:10:48 +0300 |
commit | 0805133048ae2661901dedbf72232ba5f503cfb6 (patch) | |
tree | b255aef81847e720332080344c514ee5855bcf6f /UVtools.Cmd | |
parent | 315ce3bc0dfc7a950138473f66ac83e0fa119f6c (diff) |
v3.5.6v3.5.6
- **Tools**
- **PCB Exposure:**
- (Add) Able to choose the size midpoint rounding method (#520)
- (Fix) Allow to flash alone D03 commands (#520)
- (Fix) Correct line thickness to have at least 1px error (#523)
- (Improvement) Layer arithmetic: Use ; to split and start a new arithmetic operation
- (Add) Cmd: Convert command now allow to pass 'auto' as target type to auto convert specific files, valid for SL1 files configured with FILEFORMAT_xxx (#522)
- (Add) GCode: Command to sync and wait for movement completion [Only enabled for cws format] (#514)
- (Add) VDT: Transition layer count
- (Upgrade) AvaloniaUI from 0.10.16 to 0.10.17
Diffstat (limited to 'UVtools.Cmd')
-rw-r--r-- | UVtools.Cmd/Symbols/ConvertCommand.cs | 39 | ||||
-rw-r--r-- | UVtools.Cmd/UVtools.Cmd.csproj | 2 |
2 files changed, 39 insertions, 2 deletions
diff --git a/UVtools.Cmd/Symbols/ConvertCommand.cs b/UVtools.Cmd/Symbols/ConvertCommand.cs index 89a4fdb..66a46d2 100644 --- a/UVtools.Cmd/Symbols/ConvertCommand.cs +++ b/UVtools.Cmd/Symbols/ConvertCommand.cs @@ -7,6 +7,7 @@ */ using System; using System.CommandLine; +using System.Globalization; using System.IO; using System.Linq; using UVtools.Core.Extensions; @@ -21,7 +22,7 @@ internal static class ConvertCommand var command = new Command("convert", "Convert input file into a output file format by a known type or extension") { GlobalArguments.InputFileArgument, - new Argument<string>("target-type/ext", "Target format type or extension"), + new Argument<string>("target-type/ext", "Target format type or extension. Use 'auto' for SL1 files with specified FILEFORMAT_xxx"), GlobalArguments.OutputFileArgument, new Option<ushort>(new[] {"-v", "--version"}, "Sets the file format version"), @@ -30,6 +31,42 @@ internal static class ConvertCommand command.SetHandler((FileInfo inputFile, string targetTypeExt, FileInfo? outputFile, ushort version, bool noOverwrite) => { + if (string.Equals(targetTypeExt, "auto", StringComparison.InvariantCultureIgnoreCase)) + { + using var testFile = Program.OpenInputFile(inputFile, FileFormat.FileDecodeType.Partial); + string? convertFileExtension; + switch (testFile) + { + case SL1File sl1File: + convertFileExtension = sl1File.LookupCustomValue<string>(SL1File.Keyword_FileFormat, null); + break; + case VDTFile vdtFile: + if (string.IsNullOrWhiteSpace(vdtFile.ManifestFile.Machine.UVToolsConvertTo) || vdtFile.ManifestFile.Machine.UVToolsConvertTo == "None") + convertFileExtension = vdtFile.LookupCustomValue<string>(SL1File.Keyword_FileFormat, null); + else + convertFileExtension = vdtFile.ManifestFile.Machine.UVToolsConvertTo; + break; + default: + Program.WriteLineError($"The file '{testFile.Filename}' is not a valid candidate for auto conversion. Please specify the target format instead."); + return; + } + + if (string.IsNullOrWhiteSpace(convertFileExtension)) + { + Program.WriteLineError($"The file '{testFile.Filename}' does not specify a target format, unable to guess. Please specify the target format instead."); + return; + } + + convertFileExtension = convertFileExtension.ToLower(CultureInfo.InvariantCulture); + var fileExtension = FileFormat.FindExtension(convertFileExtension); + if (fileExtension is null) + { + Program.WriteLineError($"Unable to find a valid target type from '{convertFileExtension}' extension."); + } + targetTypeExt = fileExtension!.GetFileFormat()!.GetType().Name; + outputFile = new FileInfo(Path.Combine(testFile.DirectoryPath!, $"{testFile.FilenameNoExt}.{convertFileExtension}")); + } + var targetType = FileFormat.FindByType(targetTypeExt); if (targetType is null) { diff --git a/UVtools.Cmd/UVtools.Cmd.csproj b/UVtools.Cmd/UVtools.Cmd.csproj index edd17c2..448c116 100644 --- a/UVtools.Cmd/UVtools.Cmd.csproj +++ b/UVtools.Cmd/UVtools.Cmd.csproj @@ -5,7 +5,7 @@ <TargetFramework>net6.0</TargetFramework> <AssemblyName>UVtoolsCmd</AssemblyName> <ApplicationIcon>UVtools.ico</ApplicationIcon> - <Version>1.0.1</Version> + <Version>1.0.2</Version> <Authors>Tiago Conceição, sn4k3</Authors> <Company>PTRTECH</Company> <PackageLicenseFile>LICENSE</PackageLicenseFile> |