Skip to content

Commit

Permalink
优化代码;修改 README
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed May 30, 2024
1 parent 5711768 commit 0b927b6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Base16384.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.0.0-RC.1</Version>
<Version>2.0.0</Version>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace ConsoleHelpers;

public static class Helpers {
public static readonly CultureInfo cultureInfoEnUs = new("en-US", false);

public static readonly string? debugEnv = Environment.GetEnvironmentVariable("Base16384_Net_Debug");
public static readonly bool DEBUG = !string.IsNullOrWhiteSpace(debugEnv) && debugEnv.ToLower(new CultureInfo("en-US", false)) is not "false" and not "0";
public static readonly bool DEBUG = !string.IsNullOrWhiteSpace(debugEnv) && debugEnv.ToLower(cultureInfoEnUs) is not "false" and not "0";


public static int PrintErrorMessage(string? message, string? debugMessage = null, int exitCode = 0) {
Expand Down
14 changes: 2 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
// 新的解析方式:Base16384.Net.exe <"e" | "d"> <source | "-"> [out | "-"]
/*
错误代码:
1. 无法解析命令行参数
2. 无法读写文件(可能是文件不存在或文件名存在问题)
3. Standard IO Stream 开启失败
4. 编解码失败
5. 无法创建输出文件夹(可能是输出文件夹是一个已存在的文件)
*/

if (args is ["debug", string]) {
var lower = args[1].ToLower(new CultureInfo("en-US", false));
if (args is ["debug", string]) {
var lower = args[1].ToLower(Helpers.cultureInfoEnUs);
if (lower == "enable") {
Console.WriteLine("$env:Base16384_Net_Debug = 1");
Console.WriteLine("export Base16384_Net_Debug=1");
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ Base16384.Net <"e" | "d"> <source | "-"> [out | "-"]
## 出错时调试
将环境变量 `Base16384_Net_Debug` 设为 `true``1` 等值,可输出调试信息。<br/>
特别注意,即使编解码到标准输出,也会输出异常信息!<br/>
只要环境变量 `Base16384_Net_Debug` 存在,且转小写后不为 `false``0`,就会进入调试模式。
只要环境变量 `Base16384_Net_Debug` 存在且不为空,且转小写后不为 `false``0`,就会进入调试模式。
特别注意,只有值为 `false``0` 会被认为是关闭调试模式,**其他值都会被认为是开启调试模式**
若环境变量 `Base16384_Net_Debug` **不存在****为空**,则**不进入**调试模式。

## 注意事项
UTF16BE 编码的文件需要 BOM,使用输出到文件时,会自动添加 BOM,<br/>
Expand Down

0 comments on commit 0b927b6

Please sign in to comment.