Skip to content

Commit dbfd059

Browse files
authored
meshconvert updated to support feedback (#281)
1 parent 0c31882 commit dbfd059

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

Meshconvert/CmdLineHelpers.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace Helpers
5858
};
5959

6060
template<typename T>
61-
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray)
61+
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray) noexcept
6262
{
6363
while (pArray->name)
6464
{
@@ -72,7 +72,7 @@ namespace Helpers
7272
}
7373

7474
template<typename T>
75-
const wchar_t* LookupByValue(T value, const SValue<T> *pArray)
75+
const wchar_t* LookupByValue(T value, const SValue<T> *pArray) noexcept
7676
{
7777
while (pArray->name)
7878
{
@@ -85,7 +85,7 @@ namespace Helpers
8585
return L"";
8686
}
8787

88-
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList)
88+
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList) noexcept
8989
{
9090
for (auto pFormat = pFormatList; pFormat->name; pFormat++)
9191
{
@@ -99,7 +99,7 @@ namespace Helpers
9999
wprintf(L"*UNKNOWN*");
100100
}
101101

102-
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2)
102+
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2) noexcept
103103
{
104104
for (auto pFormat = pFormatList1; pFormat->name; pFormat++)
105105
{
@@ -123,7 +123,7 @@ namespace Helpers
123123
}
124124

125125
template<typename T>
126-
void PrintList(size_t cch, const SValue<T> *pValue)
126+
void PrintList(size_t cch, const SValue<T> *pValue) noexcept
127127
{
128128
while (pValue->name)
129129
{
@@ -143,7 +143,7 @@ namespace Helpers
143143
wprintf(L"\n");
144144
}
145145

146-
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc)
146+
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc) noexcept
147147
{
148148
wchar_t version[32] = {};
149149

@@ -336,7 +336,7 @@ namespace Helpers
336336
}
337337
}
338338

339-
const wchar_t* GetErrorDesc(HRESULT hr)
339+
const wchar_t* GetErrorDesc(HRESULT hr) noexcept
340340
{
341341
static wchar_t desc[1024] = {};
342342

Meshconvert/Meshconvert.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
#include "Mesh.h"
5050

51+
#include <shellapi.h>
52+
5153
#define TOOL_VERSION DIRECTX_MESH_VERSION
5254
#include "CmdLineHelpers.h"
5355

@@ -58,6 +60,7 @@ namespace
5860
{
5961
const wchar_t* g_ToolName = L"meshconvert";
6062
const wchar_t* g_Description = L"Microsoft (R) MeshConvert Command-line Tool [DirectXMesh]";
63+
const wchar_t* g_FeedbackURL = L"https://github.com/microsoft/DirectXMesh/issues";
6164

6265
enum OPTIONS : uint32_t
6366
{
@@ -236,13 +239,14 @@ HRESULT LoadFromOBJ(const wchar_t* szFilename,
236239

237240
namespace
238241
{
239-
void PrintUsage()
242+
void PrintUsage(bool full = false) noexcept
240243
{
241244
PrintLogo(false, g_ToolName, g_Description);
242245

243246
static const wchar_t* const s_usage =
244-
L"Usage: meshconvert <options> [--] <files>\n"
245-
L"\n"
247+
L"Usage: meshconvert <options> [--] <files>\n\n";
248+
249+
static const wchar_t* const s_fullUsage =
246250
L" Input file type must be Wavefront Object (.obj)\n"
247251
L"\n"
248252
L" -ft <filetype>, --file-type <filetype> output file type\n"
@@ -291,6 +295,11 @@ namespace
291295

292296
wprintf(L"%ls", s_usage);
293297

298+
if (!full)
299+
return;
300+
301+
wprintf(L"%ls", s_fullUsage);
302+
294303
wprintf(L"\n <normal-format>: ");
295304
PrintList(13, g_vertexNormalFormats);
296305

@@ -323,6 +332,24 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
323332
std::locale::global(std::locale(""));
324333

325334
// Process command line
335+
if (argc < 2)
336+
{
337+
PrintUsage();
338+
return 0;
339+
}
340+
341+
// check for these first
342+
if (!_wcsicmp(argv[1], L"help") || !_wcsicmp(argv[1], L"/?"))
343+
{
344+
PrintUsage(true);
345+
return 0;
346+
}
347+
else if (!_wcsicmp(argv[1], L"feedback"))
348+
{
349+
std::ignore = ShellExecuteW(nullptr, L"open", g_FeedbackURL, nullptr, nullptr, SW_SHOW);
350+
return 0;
351+
}
352+
326353
uint32_t dwOptions = 0;
327354
std::list<SConversion> conversion;
328355
bool allowOpts = true;
@@ -402,7 +429,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
402429
return 0;
403430

404431
case OPT_HELP:
405-
PrintUsage();
432+
PrintUsage(true);
406433
return 0;
407434

408435
default:

0 commit comments

Comments
 (0)