mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-06-03 00:58:13 -04:00
[CLI] Fix wrong error handler. Fix option description msgs
This commit is contained in:
parent
f54cc004bd
commit
4cd246592b
@ -496,7 +496,7 @@ namespace AssetStudioCLI.Options
|
|||||||
var option = resplittedArgs[workModeOptionIndex];
|
var option = resplittedArgs[workModeOptionIndex];
|
||||||
if (workModeOptionIndex + 1 >= resplittedArgs.Count)
|
if (workModeOptionIndex + 1 >= resplittedArgs.Count)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error during parsing options:".Color(brightRed)} Value for [{option.Color(brightRed)}] option was not found.\n");
|
Console.WriteLine($"{"Error during parsing options:".Color(brightRed)} Value for [{option.Color(brightYellow)}] option was not found.\n");
|
||||||
TryFindOptionDescription(option, optionsDict);
|
TryFindOptionDescription(option, optionsDict);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -538,8 +538,8 @@ namespace AssetStudioCLI.Options
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported working mode: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported working mode: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_workMode.Description);
|
ShowOptionDescription(o_workMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resplittedArgs.RemoveRange(workModeOptionIndex, 2);
|
resplittedArgs.RemoveRange(workModeOptionIndex, 2);
|
||||||
@ -567,16 +567,16 @@ namespace AssetStudioCLI.Options
|
|||||||
resplittedArgs.RemoveAt(i);
|
resplittedArgs.RemoveAt(i);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
|
||||||
ShowOptionDescription(f_loadAllAssets.Description, isFlag: true);
|
ShowOptionDescription(f_loadAllAssets, isFlag: true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "--l2d-force-bezier":
|
case "--l2d-force-bezier":
|
||||||
if (o_workMode.Value != WorkMode.ExportLive2D)
|
if (o_workMode.Value != WorkMode.ExportLive2D)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
|
||||||
ShowOptionDescription(o_workMode.Description);
|
ShowOptionDescription(o_workMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
f_l2dForceBezier.Value = true;
|
f_l2dForceBezier.Value = true;
|
||||||
@ -635,12 +635,12 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unknown asset type specified [{type.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unknown asset type specified [{type.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_exportAssetTypes.Description);
|
ShowOptionDescription(o_exportAssetTypes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Asset type [{type.Color(brightRed)}] is not supported for exporting.\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Asset type [{type.Color(brightRed)}] is not supported for exporting.\n");
|
||||||
ShowOptionDescription(o_exportAssetTypes.Description);
|
ShowOptionDescription(o_exportAssetTypes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -668,8 +668,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_groupAssetsBy.Value = AssetGroupOption.None;
|
o_groupAssetsBy.Value = AssetGroupOption.None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported grouping option: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported grouping option: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_groupAssetsBy.Description);
|
ShowOptionDescription(o_groupAssetsBy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -687,8 +687,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_filenameFormat.Value = FilenameFormat.PathID;
|
o_filenameFormat.Value = FilenameFormat.PathID;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported file name format: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported file name format: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_filenameFormat.Description);
|
ShowOptionDescription(o_filenameFormat);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -738,8 +738,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_logLevel.Value = LoggerEvent.Error;
|
o_logLevel.Value = LoggerEvent.Error;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported log level value: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported log level value: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_logLevel.Description);
|
ShowOptionDescription(o_logLevel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -756,8 +756,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_logOutput.Value = LogOutputMode.Both;
|
o_logOutput.Value = LogOutputMode.Both;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported log output mode: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported log output mode: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_logOutput.Description);
|
ShowOptionDescription(o_logOutput);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -784,8 +784,8 @@ namespace AssetStudioCLI.Options
|
|||||||
convertTexture = false;
|
convertTexture = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported image format: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported image format: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_imageFormat.Description);
|
ShowOptionDescription(o_imageFormat);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -800,16 +800,16 @@ namespace AssetStudioCLI.Options
|
|||||||
o_audioFormat.Value = AudioFormat.None;
|
o_audioFormat.Value = AudioFormat.None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported audio format: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported audio format: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_audioFormat.Description);
|
ShowOptionDescription(o_audioFormat);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "--l2d-motion-mode":
|
case "--l2d-motion-mode":
|
||||||
if (o_workMode.Value != WorkMode.ExportLive2D)
|
if (o_workMode.Value != WorkMode.ExportLive2D)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. This option is not suitable for the current working mode [{o_workMode.Value}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. This option is not suitable for the current working mode [{o_workMode.Value}].\n");
|
||||||
ShowOptionDescription(o_workMode.Description);
|
ShowOptionDescription(o_workMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (value.ToLower())
|
switch (value.ToLower())
|
||||||
@ -826,8 +826,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_l2dMotionMode.Value = CubismLive2DExtractor.Live2DMotionMode.AnimationClipV1;
|
o_l2dMotionMode.Value = CubismLive2DExtractor.Live2DMotionMode.AnimationClipV1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported Live2D motion mode: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported Live2D motion mode: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_l2dMotionMode.Description);
|
ShowOptionDescription(o_l2dMotionMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -839,8 +839,8 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported scale factor value: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported scale factor value: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_fbxScaleFactor.Description);
|
ShowOptionDescription(o_fbxScaleFactor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -852,8 +852,8 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported bone size value: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported bone size value: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_fbxBoneSize.Description);
|
ShowOptionDescription(o_fbxBoneSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -868,8 +868,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_customCompressionType.Value = CustomCompressionType.Lz4;
|
o_customCompressionType.Value = CustomCompressionType.Lz4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported compression type: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported compression type: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_customCompressionType.Description);
|
ShowOptionDescription(o_customCompressionType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -883,8 +883,8 @@ namespace AssetStudioCLI.Options
|
|||||||
o_exportAssetList.Value = ExportListType.None;
|
o_exportAssetList.Value = ExportListType.None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Unsupported asset list export option: [{value.Color(brightRed)}].\n");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Unsupported asset list export option: [{value.Color(brightRed)}].\n");
|
||||||
ShowOptionDescription(o_exportAssetList.Description);
|
ShowOptionDescription(o_exportAssetList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -912,7 +912,7 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option}] option. Assembly folder [{value.Color(brightRed)}] was not found.");
|
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{option.Color(brightYellow)}] option. Assembly folder [{value.Color(brightRed)}] was not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -929,11 +929,11 @@ namespace AssetStudioCLI.Options
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
catch (IndexOutOfRangeException)
|
catch (ArgumentOutOfRangeException)
|
||||||
{
|
{
|
||||||
if (optionsDict.Any(x => x.Key.Contains(option)))
|
if (optionsDict.Any(x => x.Key.Contains(option)))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{"Error during parsing options:".Color(brightRed)} Value for [{option.Color(brightRed)}] option was not found.\n");
|
Console.WriteLine($"{"Error during parsing options:".Color(brightRed)} Value for [{option.Color(brightYellow)}] option was not found.\n");
|
||||||
TryFindOptionDescription(option, optionsDict);
|
TryFindOptionDescription(option, optionsDict);
|
||||||
}
|
}
|
||||||
else if (flagsDict.Any(x => x.Key.Contains(option)))
|
else if (flagsDict.Any(x => x.Key.Contains(option)))
|
||||||
@ -978,10 +978,11 @@ namespace AssetStudioCLI.Options
|
|||||||
return value.Split(separator);
|
return value.Split(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowOptionDescription(string desc, bool isFlag = false)
|
private static void ShowOptionDescription<T>(Option<T> option, bool isFlag = false)
|
||||||
{
|
{
|
||||||
var arg = isFlag ? "Flag" : "Option";
|
var arg = isFlag ? "Flag" : "Option";
|
||||||
Console.WriteLine($"{arg} description:\n{desc}");
|
var optionDesc = option.Description + option.Example.Color(ColorConsole.BrightBlack);
|
||||||
|
Console.WriteLine($"{arg} description:\n{optionDesc}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryFindOptionDescription(string option, Dictionary<string, string> dict, bool isFlag = false)
|
private static bool TryFindOptionDescription(string option, Dictionary<string, string> dict, bool isFlag = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user