Skip to content

Commit

Permalink
fixed windows cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tolik518 committed Feb 16, 2024
1 parent 61796e8 commit bd3f454
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
35 changes: 21 additions & 14 deletions SoG_SGreader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Forms;
using SoG_SGreader.Wrapper;
using CommandLine;
using System.Diagnostics;

namespace SoG_SGreader
{
Expand All @@ -12,27 +13,33 @@ public static class Program
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AllocConsole();

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FreeConsole();

[STAThread]
public static void Main(string[] args)
{
if (args.Length <= 0)
if (args.Length > 0)
{
RunApp();
return;
}
PlatformID pid = Environment.OSVersion.Platform;
// If on Windows, allocate a console.
if (pid == PlatformID.Win32NT || pid == PlatformID.Win32S ||
pid == PlatformID.Win32Windows || pid == PlatformID.WinCE)
{
AllocConsole();

PlatformID pid = Environment.OSVersion.Platform;
// If on Windows, allocate a console.
if (pid == PlatformID.Win32NT || pid == PlatformID.Win32S ||
pid == PlatformID.Win32Windows || pid == PlatformID.WinCE)
}

Parser.Default
.ParseArguments<ComandLineOptions>(args)
.WithParsed(RunOptions);
}
else
{
AllocConsole();
FreeConsole();
RunApp();
}

Parser.Default
.ParseArguments<ComandLineOptions>(args)
.WithParsed(RunOptions);

}

private static void RunOptions(ComandLineOptions opts)
Expand Down
5 changes: 4 additions & 1 deletion SoG_SGreader/SoG_SGreader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA45322A-6A3C-4652-B5F4-D2DC917FC93A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<RootNamespace>SoG_SGreader</RootNamespace>
<AssemblyName>SoG_SGreader</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
Expand Down Expand Up @@ -104,6 +104,9 @@
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>SoG_SGreader.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=2.9.1.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.9.1\lib\net45\CommandLine.dll</HintPath>
Expand Down
6 changes: 3 additions & 3 deletions SoG_SGreader/VersionInc.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

using System.Reflection;

[assembly: AssemblyVersion("0.5.2")]
[assembly: AssemblyFileVersion("0.5.2.1379")]
[assembly: AssemblyInformationalVersionAttribute("0.5.2")]
[assembly: AssemblyVersion("0.5.3")]
[assembly: AssemblyFileVersion("0.5.3.1436")]
[assembly: AssemblyInformationalVersionAttribute("0.5.3")]

2 changes: 1 addition & 1 deletion SoG_SGreader/VersionInc.tt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using System.Reflection;
<#+
public static int Major = 0;
public static int Minor = 5;
public static int Patch = 2;
public static int Patch = 3;
public static string Version = Major + "." + Minor + "." + Patch;

public static DateTime ProjectStartedDate = new DateTime(year: 2020, month: 3, day: 12);
Expand Down

0 comments on commit bd3f454

Please sign in to comment.