public void Exec(params string[] args) { foreach (var entry in Directory.EnumerateFileSystemEntries(Directory.GetCurrentDirectory())) { var f = PathUtils.MakeRelativePath(Directory.GetCurrentDirectory(), entry); ConsoleColor printColor = Console.ForegroundColor; FileAttributes attr = File.GetAttributes(entry); if (attr.HasFlag(FileAttributes.Directory)) //Is a directory { printColor = ConsoleColor.Cyan; } else //Is a file { printColor = ConsoleColor.Gray; if (attr.HasFlag(FileAttributes.ReadOnly)) { printColor = ConsoleColor.Red; } if (attr.HasFlag(FileAttributes.Encrypted)) { printColor = ConsoleColor.Magenta; } } if (attr.HasFlag(FileAttributes.Hidden) && printColor != ConsoleColor.Gray) { printColor -= 8; //HACK: will subtract to the dark version of the color. } ShellEnvironment.WriteColorLine(f, printColor); } }
public void Exec(params string[] args) { if (args.Length < 1) { ShellEnvironment.WriteNormalLine(BuiltInResources.HelpMessage); } else { } }
public void Exec(params string[] args) { int i = 1; foreach (var command in ShellEnvironment.Instance.CommandHistory) { ShellEnvironment.WriteNormalLine($"{i} {command}"); i++; } }
public void Exec(params string[] args) { if (args.Length < 1) { ShellEnvironment.WriteNormal($"History buffer size is {ShellEnvironment.Instance.HistoryBufferSize}"); } else { if (ulong.TryParse(args[0], out ulong result)) { if (result == 0) { result = 1; } ShellEnvironment.Instance.HistoryBufferSize = result; ShellEnvironment.WriteNormalLine($"Set history buffer size to {result}"); } } }
public void Exec(params string[] args) { if (args.Length > 0) { string fullPath = Path.Combine(Directory.GetCurrentDirectory(), args[0]); if (Directory.Exists(fullPath)) { ShellEnvironment.WriteErrorLine("Specified directory already exists"); } else { try { Directory.CreateDirectory(fullPath); } catch (Exception ex) { ShellEnvironment.WriteErrorLine($"Could not create directory: {ex.Message}"); } } } }
public void Exec(params string[] args) { if (args.Length < 1) { ShellEnvironment.WriteNormalLine(Directory.GetCurrentDirectory()); } else { string resolvedPathName = Path.GetFullPath(args[0]); if (!resolvedPathName.EndsWith(Path.DirectorySeparatorChar.ToString())) //Add a / on if we didn't do one. { resolvedPathName += Path.DirectorySeparatorChar; } try { Directory.SetCurrentDirectory(resolvedPathName); } catch (Exception ex) { ShellEnvironment.WriteErrorLine($"Could not set directory: {ex.Message}"); } } }
void SetupShellEnvVar() { ShellEnv = new ShellEnvironment(VariableNamespace.env + ""); }
public void Exec(params string[] args) { ShellEnvironment.WriteNormalLine(Directory.GetCurrentDirectory()); }
public P4Shell() { env = new ShellEnvironment(); }