@@ -138,10 +138,12 @@ namespace
138
138
OPT_GIF_BGCOLOR,
139
139
OPT_SWIZZLE,
140
140
OPT_STRIP_MIPS,
141
- OPT_MAX
141
+ OPT_FLAGS_MAX,
142
+ OPT_VERSION,
143
+ OPT_HELP,
142
144
};
143
145
144
- static_assert (OPT_MAX <= 32 , " dwOptions is a unsigned int bitfield" );
146
+ static_assert (OPT_FLAGS_MAX <= 32 , " dwOptions is a unsigned int bitfield" );
145
147
146
148
// ////////////////////////////////////////////////////////////////////////////
147
149
// ////////////////////////////////////////////////////////////////////////////
@@ -194,13 +196,38 @@ namespace
194
196
{ L" wrap" , OPT_TA_WRAP },
195
197
{ L" mirror" , OPT_TA_MIRROR },
196
198
{ L" fl" , OPT_FEATURE_LEVEL },
199
+
200
+ // Deprecated options (recommend using new -- alternatives)
197
201
{ L" tonemap" , OPT_TONEMAP },
198
202
{ L" bgcolor" , OPT_GIF_BGCOLOR },
199
203
{ L" swizzle" , OPT_SWIZZLE },
200
204
{ L" stripmips" , OPT_STRIP_MIPS },
205
+
201
206
{ nullptr , 0 }
202
207
};
203
208
209
+ const SValue<uint32_t > g_pOptionsLong[] =
210
+ {
211
+ { L" feature-level" , OPT_FEATURE_LEVEL },
212
+ { L" file-list" , OPT_FILELIST },
213
+ { L" format" , OPT_FORMAT },
214
+ { L" gif-bg-color" , OPT_GIF_BGCOLOR },
215
+ { L" height" , OPT_HEIGHT },
216
+ { L" help" , OPT_HELP },
217
+ { L" image-filter" , OPT_FILTER },
218
+ { L" overwrite" , OPT_OVERWRITE },
219
+ { L" separate-alpha" , OPT_SEPALPHA },
220
+ { L" srgb-in" , OPT_SRGBI },
221
+ { L" srgb-out" , OPT_SRGBO },
222
+ { L" strip-mips" , OPT_STRIP_MIPS },
223
+ { L" swizzle" , OPT_SWIZZLE },
224
+ { L" to-lowercase" , OPT_TOLOWER },
225
+ { L" tonemap" , OPT_TONEMAP },
226
+ { L" version" , OPT_VERSION },
227
+ { L" width" , OPT_WIDTH },
228
+ { nullptr , 0 }
229
+ };
230
+
204
231
#define DEFFMT (fmt ) { L## #fmt, DXGI_FORMAT_ ## fmt }
205
232
206
233
const SValue<DXGI_FORMAT> g_pFormats[] =
@@ -500,7 +527,7 @@ namespace
500
527
501
528
static const wchar_t * const s_usage =
502
529
L" Usage: texassemble <command> <options> [--] <files>\n "
503
- L" \n "
530
+ L" \n COMMANDS \ n"
504
531
L" cube create cubemap\n "
505
532
L" volume create volume map\n "
506
533
L" array create texture array\n "
@@ -518,34 +545,43 @@ namespace
518
545
L" cube-from-ht create cubemap from a h-tee image\n "
519
546
L" cube-from-hs create cubemap from a h-strip image\n "
520
547
L" cube-from-vs create cubemap from a v-strip image\n "
521
- L" \n "
548
+ L" \n OPTIONS \ n"
522
549
L" -r wildcard filename search is recursive\n "
523
- L" -flist <filename> use text file with a list of input files (one per line)\n "
524
- L" -w <n> width\n "
525
- L" -h <n> height\n "
526
- L" -f <format> format\n "
527
- L" -if <filter> image filtering\n "
528
- L" -srgb{i|o} sRGB {input, output}\n "
529
- L" -o <filename> output filename\n "
530
- L" -l force output filename to lower case\n "
531
- L" -y overwrite existing output file (if any)\n "
532
- L" -sepalpha resize alpha channel separately from color channels\n "
550
+ L" -flist <filename>, --file-list <filename>\n "
551
+ L" use text file with a list of input files (one per line)\n "
552
+ L" \n "
553
+ L" -w <n>, --width <n> width for output\n "
554
+ L" -h <n>, --height <n> height for output\n "
555
+ L" -f <format>, --format <format> pixel format for output\n "
556
+ L" \n "
557
+ L" -if <filter>, --image-filter <filter> image filtering\n "
558
+ L" -srgb{i|o}, --srgb-in, --srgb-out sRGB {input, output}\n "
559
+ L" \n "
560
+ L" -o <filename> output filename\n "
561
+ L" -l, --to-lowercase force output filename to lower case\n "
562
+ L" -y, --overwrite overwrite existing output file (if any)\n "
563
+ L" \n "
564
+ L" -sepalpha, --separate-alpha resize/generate mips alpha channel separately from color channels\n "
565
+ L" \n "
533
566
L" -nowic Force non-WIC filtering\n "
534
567
L" -wrap, -mirror texture addressing mode (wrap, mirror, or clamp)\n "
535
568
L" -alpha convert premultiplied alpha to straight alpha\n "
536
569
L" -dx10 Force use of 'DX10' extended header\n "
537
570
L" -nologo suppress copyright message\n "
538
- L" -fl <feature-level> Set maximum feature level target (defaults to 11.0)\n "
571
+ L" \n "
572
+ L" -fl <feature-level>, --feature-level <feature-level>\n "
573
+ L" Set maximum feature level target (defaults to 11.0)\n "
574
+ L" \n "
539
575
L" -tonemap Apply a tonemap operator based on maximum luminance\n "
540
576
L" \n "
541
577
L" (gif only)\n "
542
- L" -bgcolor Use background color instead of transparency\n "
578
+ L" --gif-bg-color Use background color instead of transparency\n "
543
579
L" \n "
544
580
L" (merge only)\n "
545
- L" -swizzle <rgba> Select channels for merge (defaults to rgbB)\n "
581
+ L" -- swizzle <rgba> Select channels for merge (defaults to rgbB)\n "
546
582
L" \n "
547
583
L" (cube, volume, array, cubearray, merge only)\n "
548
- L" -stripmips Use only base image from input dds files\n "
584
+ L" --strip-mips Use only base image from input dds files\n "
549
585
L" \n "
550
586
L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n " ;
551
587
@@ -775,6 +811,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
775
811
return 0 ;
776
812
}
777
813
814
+ // check for these before the command
778
815
if ((' -' == argv[1 ][0 ]) && (' -' == argv[1 ][1 ]))
779
816
{
780
817
if (!_wcsicmp (argv[1 ], L" --version" ))
@@ -824,50 +861,76 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
824
861
std::list<SConversion> conversion;
825
862
bool allowOpts = true ;
826
863
827
- for (int iArg = 2 ; iArg < argc; iArg++ )
864
+ for (int iArg = 2 ; iArg < argc; ++iArg )
828
865
{
829
866
PWSTR pArg = argv[iArg];
830
867
831
- if (allowOpts
832
- && (' -' == pArg[0 ]) && (' -' == pArg[1 ]))
868
+ if (allowOpts && ((' -' == pArg[0 ]) || (' /' == pArg[0 ])))
833
869
{
834
- if (pArg[2 ] == 0 )
835
- {
836
- // "-- " is the POSIX standard for "end of options" marking to escape the '-' and '/' characters at the start of filepaths.
837
- allowOpts = false ;
838
- }
839
- else if (!_wcsicmp (pArg, L" --version" ))
840
- {
841
- PrintLogo (true , g_ToolName, g_Description);
842
- return 0 ;
843
- }
844
- else if (!_wcsicmp (pArg, L" --help" ))
870
+ uint64_t dwOption = 0 ;
871
+ PWSTR pValue = nullptr ;
872
+
873
+ if ((' -' == pArg[0 ]) && (' -' == pArg[1 ]))
845
874
{
846
- PrintUsage ();
847
- return 0 ;
875
+ if (pArg[2 ] == 0 )
876
+ {
877
+ // "-- " is the POSIX standard for "end of options" marking to escape the '-' and '/' characters at the start of filepaths.
878
+ allowOpts = false ;
879
+ continue ;
880
+ }
881
+ else
882
+ {
883
+ pArg += 2 ;
884
+
885
+ for (pValue = pArg; *pValue && (' :' != *pValue) && (' =' != *pValue); ++pValue);
886
+
887
+ if (*pValue)
888
+ *pValue++ = 0 ;
889
+
890
+ dwOption = LookupByName (pArg, g_pOptionsLong);
891
+
892
+ if (dwOption == OPT_VERSION)
893
+ {
894
+ PrintLogo (true , g_ToolName, g_Description);
895
+ return 0 ;
896
+ }
897
+ else if (dwOption == OPT_HELP)
898
+ {
899
+ PrintUsage ();
900
+ return 0 ;
901
+ }
902
+ }
848
903
}
849
904
else
850
905
{
851
- wprintf (L" Unknown option: %ls\n " , pArg);
852
- return 1 ;
853
- }
854
- }
855
- else if (allowOpts
856
- && ((' -' == pArg[0 ]) || (' /' == pArg[0 ])))
857
- {
858
- pArg++;
859
- PWSTR pValue;
906
+ pArg++;
907
+
908
+ for (pValue = pArg; *pValue && (' :' != *pValue) && (' =' != *pValue); ++pValue);
909
+
910
+ if (*pValue)
911
+ *pValue++ = 0 ;
860
912
861
- for (pValue = pArg; *pValue && ( ' : ' != *pValue); pValue++ );
913
+ dwOption = LookupByName (pArg, g_pOptions );
862
914
863
- if (*pValue)
864
- *pValue++ = 0 ;
915
+ if (!dwOption)
916
+ {
917
+ if (LookupByName (pArg, g_pOptionsLong))
918
+ {
919
+ wprintf (L" ERROR: did you mean `--%ls` (with two dashes)?\n " , pArg);
920
+ return 1 ;
921
+ }
922
+ }
923
+ }
865
924
866
- const uint32_t dwOption = LookupByName (pArg, g_pOptions);
925
+ if (!dwOption)
926
+ {
927
+ wprintf (L" ERROR: Unknown option: `%ls`\n\n Use %ls --help\n " , pArg, g_ToolName);
928
+ return 1 ;
929
+ }
867
930
868
- if (!dwOption || ( dwOptions & (1 << dwOption) ))
931
+ if (dwOptions & (1 << dwOption))
869
932
{
870
- PrintUsage ( );
933
+ wprintf ( L" ERROR: Duplicate option: `%ls` \n\n " , pArg );
871
934
return 1 ;
872
935
}
873
936
0 commit comments