Added: command line support

This commit is contained in:
Ray 2021-09-29 16:49:09 +01:00
parent dbdc654268
commit 90473e092d
3 changed files with 55 additions and 7 deletions

View File

@ -85,8 +85,14 @@ namespace FizzyLauncher
InvalidateAppSession(); InvalidateAppSession();
string[] commandLineArgs = Environment.GetCommandLineArgs();
bool hasCommands = await LoadCommandLine(commandLineArgs);
if (!hasCommands)
{
newToolStripMenuItem_Click(null, null); newToolStripMenuItem_Click(null, null);
} }
}
protected async override void OnClosing(CancelEventArgs e) protected async override void OnClosing(CancelEventArgs e)
{ {
@ -936,6 +942,48 @@ namespace FizzyLauncher
}); });
} }
protected async Task<bool> LoadCommandLine(string[] args)
{
bool rs = false;
if (args.Length > 1)
{
int i = 1;
while (true)
{
if (i > (args.Length - 1))
{
break;
}
switch (args[i].Trim().ToLower())
{
case "-o":
case "-open":
if ((i + 1) > (args.Length - 1)) break;
string openFilename = args[(i + 1)];
if (string.IsNullOrWhiteSpace(openFilename)) break;
if (!File.Exists(openFilename)) break;
await LoadFile(openFilename);
//LoadBookmarksForm loadFileForm = new LoadBookmarksForm(this, openFilename);
//loadFileForm.ShowDialog();
rs = true;
i++;
break;
}
i++;
}
}
return rs;
}
protected async Task<Result> LoadFile(string filename) protected async Task<Result> LoadFile(string filename)
{ {
return await Task.Run(() => return await Task.Run(() =>

View File

@ -23,8 +23,8 @@ DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes DisableProgramGroupPage=yes
; Remove the following line to run in administrative install mode (install for all users.) ; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest PrivilegesRequired=lowest
OutputDir=L:\gitlab-hiimray\fizzy-launcher\bin OutputDir=L:\gitlab-hiimray\bookmark-manager-r4\bin
OutputBaseFilename=fizzy-launcher-64 OutputBaseFilename=bookmark-manager-64
Compression=lzma Compression=lzma
SolidCompression=yes SolidCompression=yes
WizardStyle=modern WizardStyle=modern
@ -36,7 +36,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files] [Files]
Source: "L:\gitlab-hiimray\fizzy-launcher\bin\Release\64\fizzylauncher.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "L:\gitlab-hiimray\bookmark-manager-r4\bin\Release\64\bookmarkmanager.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]

View File

@ -23,8 +23,8 @@ DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes DisableProgramGroupPage=yes
; Remove the following line to run in administrative install mode (install for all users.) ; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest PrivilegesRequired=lowest
OutputDir=L:\gitlab-hiimray\fizzy-launcher\bin OutputDir=L:\gitlab-hiimray\bookmark-manager-r4\bin
OutputBaseFilename=fizzy-launcher-86 OutputBaseFilename=bookmark-manager-86
Compression=lzma Compression=lzma
SolidCompression=yes SolidCompression=yes
WizardStyle=modern WizardStyle=modern
@ -36,7 +36,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files] [Files]
Source: "L:\gitlab-hiimray\fizzy-launcher\bin\Release\86\fizzylauncher.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "L:\gitlab-hiimray\bookmark-manager-r4\bin\Release\86\bookmarkmanager.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]