diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 7d0c9197..c2e57b49 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -32,7 +32,27 @@ namespace SourceGit.ViewModels Pages = new AvaloniaList(); AddNewTab(); - if (Preference.Instance.RestoreTabs) + var commandlines = Environment.GetCommandLineArgs(); + if (commandlines.Length == 2) + { + var path = commandlines[1].Replace('\\', '/'); + var root = new Commands.QueryRepositoryRootPath(path).Result(); + if (string.IsNullOrEmpty(root)) + { + Pages[0].Notifications.Add(new Models.Notification + { + IsError = true, + Message = $"Given path: '{commandlines[1]}' is NOT a valid repository!" + }); + return; + } + + var gitDir = new Commands.QueryGitDir(root).Result(); + var repo = Preference.AddRepository(root, gitDir); + var node = Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null); + OpenRepositoryInTab(node, null); + } + else if (Preference.Instance.RestoreTabs) { foreach (var id in Preference.Instance.OpenedTabs) {