forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenVSCommand.cs
More file actions
43 lines (36 loc) · 1.33 KB
/
OpenVSCommand.cs
File metadata and controls
43 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using ScriptCs.Contracts;
using System;
namespace ScriptCs.Hosting.ReplCommands
{
public class OpenVsCommand : IReplCommand
{
private readonly IConsole _console;
private IVisualStudioSolutionWriter _writer;
public OpenVsCommand(IConsole console, IVisualStudioSolutionWriter writer)
{
_console = console;
_writer = writer;
}
public object Execute(IRepl repl, object[] args)
{
if (PlatformID != PlatformID.Win32NT)
{
_console.WriteLine("Requires Windows 8 or later to run");
return null;
}
var fs = repl.FileSystem;
string arg = args.Length > 0 ? (string)args[0] : null;
var launcher = _writer.WriteSolution(fs, arg, new VisualStudioSolution());
_console.WriteLine("Opening Visual Studio");
LaunchSolution(launcher);
return null;
}
protected internal virtual void LaunchSolution(string launcher)
{
System.Diagnostics.Process.Start(launcher);
}
protected internal virtual PlatformID PlatformID => Environment.OSVersion.Platform;
public string Description => "Opens a script to edit/debug in Visual Studio";
public string CommandName => "openvs";
}
}