forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCdCommand.cs
More file actions
34 lines (27 loc) · 789 Bytes
/
CdCommand.cs
File metadata and controls
34 lines (27 loc) · 789 Bytes
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
using System.IO;
using ScriptCs.Contracts;
namespace ScriptCs.ReplCommands
{
public class CdCommand : IReplCommand
{
public string Description
{
get { return "Changes the working directory to the path provided."; }
}
public string CommandName
{
get { return "cd"; }
}
public object Execute(IRepl repl, object[] args)
{
Guard.AgainstNullArgument("repl", repl);
if (args == null || args.Length == 0)
{
return null;
}
var path = args[0].ToString();
repl.FileSystem.CurrentDirectory = Path.GetFullPath(Path.Combine(repl.FileSystem.CurrentDirectory, path));
return null;
}
}
}