public override bool Interact(ref DirectoryInfo di, Command c) { db.Load(); switch (c.Arguments[0]) { case "update": Update(); break; case "install": Install(c); break; case "remove": Uninstall(c); break; case "add-repository": AddRepo(c); break; case "remove-repository": RemoveRepo(c); break; } return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { Console.BackgroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), command.Arguments[0]); Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), command.Arguments[1]); return true; }
public static IEnumerable<Command> Create(string cmd) { if (cmd != "") { var cmds = Regex.Split(cmd, "&&"); foreach (var item in cmds) { var spl = Utilities.Split(item.Trim(), ' ', '"'); var c = new Command(); c.Name = spl[0]; var args = spl.ToList(); args.RemoveAt(0); for (int i = 0; i < args.Count; i++) { foreach (var v in VariableCache.data) { args[i] = args[i].Replace("%" + v.Key + "%", v.Value); } } c.Arguments = args.ToArray(); yield return c; } } }
public override bool Interact(ref DirectoryInfo path, Command command) { switch (command.Arguments[0]) { case "taskbar": if (command.Arguments[1] == "--show") { API.ShowTasktbar(); } else if (command.Arguments[1] == "--hide") { API.HideTasktbar(); } break; case "window": if (command.Arguments[1] == "--show") { API.ShowConsole(); } else if (command.Arguments[1] == "--hide") { API.HideConsole(); } break; } return true; }
protected string formatter(Command c) { var output = c.Arguments[0]; var ff = new List<string>(c.Arguments); ff.RemoveAt(0); return Format.ToString(output, cast(ff)); }
public override bool Interact(ref DirectoryInfo path, Command c) { ZipOutputStream zip = new ZipOutputStream(File.Create(c.Arguments[1])); zip.SetLevel(9); ZipFolder(path.FullName + "\\" + c.Arguments[0], path.FullName + "\\" + c.Arguments[0], zip); zip.Finish(); zip.Close(); return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { Console.WriteLine("Menu sample: Simple text formatting."); Menu m = new Menu(); m.Add("Convert to Upper-case", new MenuCallback(DoUppercase)); m.Add("Convert to Lower-case", new MenuCallback(DoLowercase)); m.Add("Capitalize", new MenuCallback(DoCapitalize)); m.Show(); return true; }
public override bool Interact(ref DirectoryInfo di, Command c) { var output = c.Arguments[0]; var ff = new List<string>(c.Arguments); ff.RemoveAt(0); Console.WriteLine(Format.ToString(output, cast(ff))); return true; }
public override bool Interact(ref DirectoryInfo di, Command c) { if (Directory.Exists(di.FullName + "\\" + c.Arguments[0])) { di = new DirectoryInfo(di.FullName + "\\" + c.Arguments[0]); return true; } else { Console.WriteLine("Directory '" + c.Arguments[0] + "' not found!"); return false; } }
public override bool Interact(ref DirectoryInfo di, Command c) { var table = new ConsoleTable(); foreach (var item in Directory.GetDirectories(di.FullName)) { var d = new DirectoryInfo(item); table.PrintRow(d.Name, "<DIR>", d.CreationTime.ToShortDateString()); } foreach (var item in Directory.GetFiles(di.FullName)) { var d = new FileInfo(item); table.PrintRow(d.Name, "<FILE>", d.CreationTime.ToShortDateString()); } return true; }
public override bool Interact(ref DirectoryInfo path, Command c) { var wc = new WebClient(); var prog = new contracts.Progress.SwayBar(); bool returns = false; wc.DownloadProgressChanged += (s, e) => { prog.Step(); }; wc.DownloadFileCompleted += (s, e) => { returns = true; }; wc.DownloadFileAsync(new Uri(c.Arguments[0]), path.FullName + "\\" + Path.GetFileName(c.Arguments[0])); while (wc.IsBusy) { } return returns; }
public override bool Interact(ref DirectoryInfo di, Command c) { if (File.Exists(di.FullName + "\\" + c.Arguments[0])) { if (c.Arguments.Length == 1) { Process.Start(di.FullName + "\\" + c.Arguments[0]); } else if (c.Arguments.Length == 2) { Process.Start(di.FullName + "\\" + c.Arguments[0], c.Arguments[1]); } return true; } else { return false; } }
public override bool Interact(ref DirectoryInfo path, Command cmd) { if (cmd.Arguments[0] == "connect") { socket.Connect(cmd.Arguments[1]); } else if (cmd.Arguments[0] == "disconnect") { socket.Close(); } else if (cmd.Arguments[0] == "write") { socket.Write(cmd.Arguments[1]); } else if (cmd.Arguments[0] == "writeline") { socket.WriteLine(cmd.Arguments[1]); } return true; }
public override bool Interact(ref DirectoryInfo path, Command c) { if (File.Exists(c.Arguments[0])) { using (var zip = new ZipFile(path.FullName + "\\" + c.Arguments[0])) { if (IsPasswordProtectedZipFile(path.FullName + "\\" + c.Arguments[0])) { Console.Write("Please type in your Zip Password: "******"\\" + ze.Name, FileMode.OpenOrCreate, FileAccess.Write)) zip.GetInputStream(ze).CopyTo(fs); } else { Directory.CreateDirectory(path.FullName + "\\" + ze.Name); } } } } return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { if (command.Arguments.Length == 0) { foreach (var c in Program.commands) { foreach (var h in c.Help) { if (!string.IsNullOrEmpty(h.Command)) { Console.WriteLine(h.Command + " " + h.Description); } else { continue; } } } } else { foreach (var c in Program.commands) { foreach (var h in c.Help) { if(h.Command == command.Arguments[0]) { foreach (var item in h.HelpText.Split(new[] { '\r' }, StringSplitOptions.RemoveEmptyEntries )) { Console.WriteLine(item); } } } } } return true; }
//ToDo: implement uninstall/install plugin public override bool Interact(ref DirectoryInfo di, Command c) { switch (c.Arguments[0]) { case "install": break; case "uninstall": break; case "refresh": Console.WriteLine("Refreshing Plugins.."); Program._plugInManager.LoadPlugIns(); foreach (var item in Program._plugInManager.PlugIns) { Program.commands.AddRange(item.PlugInProxy.GetCommands()); } break; } return true; }
void RemoveRepo(Command c) { db.Repositories.Remove(c.Arguments[1]); db.Save(); }
public override bool Interact(ref DirectoryInfo di, Command c) { Console.Write(c.Arguments[0]); return true; }
public override bool Accept(Command command) { return command.Name == "plugins"; }
void Uninstall(Command c) { var prog = new cmd.contracts.Progress.AnimatedBar(); prog.PrintMessage("Removing"); }
public override bool Accept(Command command) { return command.Name == "color"; }
public override bool Accept(Command command) { return command.Name == "print"; }
public override bool Accept(Command command) { return command.Name == "title"; }
public override bool Accept(Command command) { return command.Name == "sleep"; }
public override bool Interact(ref DirectoryInfo di, Command c) { di = new DirectoryInfo(di.Parent.FullName); return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { ScriptInterpreter.Interprete(command.Arguments[0], ref path, Commands); return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { Thread.Sleep(int.Parse(command.Arguments[0])); return true; }
public override bool Interact(ref DirectoryInfo path, Command c) { File.Copy(path.FullName + "\\" + c.Arguments[0], c.Arguments[1]); return true; }
public override bool Interact(ref DirectoryInfo path, Command command) { Console.Title = command.Arguments[0]; return true; }
public override bool Accept(Command command) { return command.Name == "winapi"; }