Skip to content

Commit 133c5f9

Browse files
committed
Add help when running the exe file directly
1 parent 93253da commit 133c5f9

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

minitool/Program.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using minitool.Models;
55
using minitool.Utils;
66
using System;
7+
using System.Diagnostics;
78
using System.Globalization;
89
using System.Security.Cryptography.X509Certificates;
910

@@ -23,6 +24,21 @@ public class Program
2324

2425
public static void Main(string[] args)
2526
{
27+
// If the application was ran by executing the exe file from the desktop environment, rather than the commandline,
28+
// open a new commandline window and run the application from there. This helps users that are not that familiar with CLI.
29+
// This check can be done by looking whether no args are specified and the cursor is all the way at the top.
30+
if(args.Length == 0 && Console.CursorTop == 0)
31+
{
32+
33+
// Run a CMD session and initially print the help text to guide the user on how to start.
34+
Process.Start(new ProcessStartInfo("cmd.exe", "/k minitool help")
35+
{
36+
UseShellExecute = false
37+
});
38+
39+
return;
40+
}
41+
2642
// Set the culture for the whole application to invariant to allow consistent parsing.
2743
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
2844

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"profiles": {
33
"minitool": {
4-
"commandName": "Project",
5-
"commandLineArgs": "console 4"
4+
"commandName": "Project"
65
}
76
}
87
}

minitool/minitool.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<RootNamespace>minitool</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
9+
<Authors>minisbett</Authors>
910
</PropertyGroup>
1011

1112
<ItemGroup>

0 commit comments

Comments
 (0)