Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Close #158 - Open directory in file explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
jibedoubleve committed Aug 10, 2021
1 parent 2a34f93 commit 42771d7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion chocolatey/lanceur/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $packageArgs = @{

softwareName = 'lanceur'

checksum = 'E9D049645C7A3BCA0EB6337DC44E35E837AC2308E6F6EB1EFEF0EBDD5B8197EA'
checksum = '56C4499E14EEF6D378EE0D133C2A47D9D816A200EEF970E2C7B1196D34B680FE'
checksumType = 'sha256'

validExitCodes= @(0, 3010, 1641)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="ServicesImpl\SlickRunExtractor.cs" />
<Compile Include="ServicesImpl\TraceLogger.cs" />
<Compile Include="ServicesImpl\Wildcards.cs" />
<Compile Include="Utils\ExplorerProxy.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Probel.Lanceur.Core\Probel.Lanceur.Core.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Probel.Lanceur.Core.Entities;
using Probel.Lanceur.Core.Services;
using Probel.Lanceur.Infrastructure.Utils;
using Probel.Lanceur.Plugin;
using Probel.Lanceur.Repositories;
using Probel.Lanceur.SharedKernel.Logs;
Expand Down Expand Up @@ -83,10 +84,9 @@ private IEnumerable<AliasText> LoadAliasNames(long sessionId, string keyword)
/// <param name="cmdline">The command line to execute. That's the alias and the arguments (which are not mandatory)</param>
public ExecutionResult Execute(AliasText alias, string cmdline, long idSession)
{
if (File.Exists(cmdline.Trim('"')))
{
return _cmdRunner.Execute(Alias.FromPath(cmdline.Trim('"')));
}
var proxy = new ExplorerProxy(cmdline, _cmdRunner);

if (proxy.CanOpenInExplorer()) { return proxy.OpenInExplorer(); }
if (_pluginManager.Exists(alias.Name))
{
var cmd = _resolver.Split(cmdline, idSession);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Probel.Lanceur.Core.Entities;
using Probel.Lanceur.Core.Services;
using System.IO;

namespace Probel.Lanceur.Infrastructure.Utils
{
public class ExplorerProxy
{
#region Fields

private readonly ICommandRunner _cmdRunner;

private readonly string _path;

#endregion Fields

#region Constructors

public ExplorerProxy(string path, ICommandRunner cmdRunner)
{
_cmdRunner = cmdRunner;
_path = path.Trim('"');
}

#endregion Constructors

#region Methods

public bool CanOpenInExplorer() => IsDirectory() || IsFile();

public bool IsDirectory() => Directory.Exists(_path);

public bool IsFile() => File.Exists(_path);

public ExecutionResult OpenInExplorer() => _cmdRunner.Execute(Alias.FromPath(_path));

#endregion Methods
}
}
4 changes: 2 additions & 2 deletions src/Version.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;

[assembly: AssemblyVersion("0.8.1.8")]
[assembly: AssemblyVersion("0.8.1.11")]
[assembly: AssemblyFileVersion("0.8.1.0")]
[assembly: AssemblyInformationalVersion("0.8.1-beta.8+Branch.develop.Sha.a97991f6042fca627e488aaf26e627e8a343c67c")]
[assembly: AssemblyInformationalVersion("0.8.1-beta.11+Branch.develop.Sha.2a34f934bfd41dc676e032e2c83829de88a79a58")]

0 comments on commit 42771d7

Please sign in to comment.