Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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;
                }
            }
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 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;
     }
 }
Esempio n. 10
0
        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;
        }
Esempio n. 11
0
        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;
        }
Esempio n. 12
0
 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;
     }
 }
Esempio n. 13
0
        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;
        }
Esempio n. 14
0
        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;
        }
Esempio n. 15
0
 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;
 }
Esempio n. 16
0
        //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;
        }
Esempio n. 17
0
 void RemoveRepo(Command c)
 {
     db.Repositories.Remove(c.Arguments[1]);
     db.Save();
 }
Esempio n. 18
0
        public override bool Interact(ref DirectoryInfo di, Command c)
        {
            Console.Write(c.Arguments[0]);

            return true;
        }
Esempio n. 19
0
 public override bool Accept(Command command)
 {
     return command.Name == "plugins";
 }
Esempio n. 20
0
 void Uninstall(Command c)
 {
     var prog = new cmd.contracts.Progress.AnimatedBar();
     prog.PrintMessage("Removing");
 }
Esempio n. 21
0
 public override bool Accept(Command command)
 {
     return command.Name == "color";
 }
Esempio n. 22
0
 public override bool Accept(Command command)
 {
     return command.Name == "print";
 }
Esempio n. 23
0
 public override bool Accept(Command command)
 {
     return command.Name == "title";
 }
Esempio n. 24
0
 public override bool Accept(Command command)
 {
     return command.Name == "sleep";
 }
Esempio n. 25
0
 public override bool Interact(ref DirectoryInfo di, Command c)
 {
     di = new DirectoryInfo(di.Parent.FullName);
     return true;
 }
Esempio n. 26
0
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            ScriptInterpreter.Interprete(command.Arguments[0], ref path, Commands);

            return true;
        }
Esempio n. 27
0
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            Thread.Sleep(int.Parse(command.Arguments[0]));

            return true;
        }
Esempio n. 28
0
 public override bool Interact(ref DirectoryInfo path, Command c)
 {
     File.Copy(path.FullName + "\\" + c.Arguments[0], c.Arguments[1]);
     return true;
 }
Esempio n. 29
0
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            Console.Title = command.Arguments[0];

            return true;
        }
Esempio n. 30
0
 public override bool Accept(Command command)
 {
     return command.Name == "winapi";
 }