Skip to content

Commit

Permalink
feat: Add support for command line args
Browse files Browse the repository at this point in the history
  • Loading branch information
rvost committed Mar 18, 2023
1 parent 05c7f7d commit 3775f77
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions PboSpy/Modules/PboManager/IPboManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface IPboManager
event EventHandler<PboManagerEventArgs> PboLoaded;
event EventHandler<PboManagerEventArgs> PboRemoved;

// TODO: Make async
void LoadSupportedFiles(IEnumerable<string> fileNames);
void Close(ITreeSubnode file);
void CloseAll();
Expand Down
25 changes: 24 additions & 1 deletion PboSpy/Modules/Startup/Module.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using PboSpy.Modules.About;
using PboSpy.Modules.ConfigExplorer;
using PboSpy.Modules.Explorer;
using PboSpy.Modules.PboManager;
using PboSpy.Properties;
using System.IO;
using System.Windows;
using System.Windows.Media.Imaging;

Expand All @@ -11,6 +13,7 @@ namespace PboSpy.Modules.Startup;
public class Module : ModuleBase
{
private readonly IMainWindow _mainWindow;
private readonly IPboManager _pboManager;

public override IEnumerable<IDocument> DefaultDocuments
{
Expand All @@ -30,9 +33,10 @@ public override IEnumerable<Type> DefaultTools
}

[ImportingConstructor]
public Module(IMainWindow mainWindow)
public Module(IMainWindow mainWindow, IPboManager pboManager)
{
_mainWindow = mainWindow;
_pboManager = pboManager;
}

public override void Initialize()
Expand All @@ -46,7 +50,26 @@ public override void Initialize()

public override Task PostInitializeAsync()
{
LoadFromArguments();//TODO: Make async

Shell.ActiveLayoutItem = IoC.Get<IPboExplorer>();
return Task.CompletedTask;
}

private void LoadFromArguments()
{
var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
var paths = args
.Skip(1)
.Where(str => File.Exists(str) || Directory.Exists(str))
.ToList();

if (paths.Any())
{
_pboManager.LoadSupportedFiles(paths);
}
}
}
}

0 comments on commit 3775f77

Please sign in to comment.