コード例 #1
0
ファイル: AptGetCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #2
0
ファイル: ColorCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
                }
            }
        }
コード例 #4
0
ファイル: WinApiCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #5
0
ファイル: ICommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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));
        }
コード例 #6
0
ファイル: ZipCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #7
0
ファイル: MenuCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #8
0
ファイル: EchoCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #9
0
ファイル: CdCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 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;
     }
 }
コード例 #10
0
ファイル: DirCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #11
0
ファイル: WGetCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #12
0
ファイル: RunCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 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;
     }
 }
コード例 #13
0
ファイル: TelnetCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #14
0
ファイル: UnzipCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        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;
        }
コード例 #15
0
ファイル: HelpCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 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;
 }
コード例 #16
0
ファイル: PluginCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        //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;
        }
コード例 #17
0
ファイル: AptGetCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 void RemoveRepo(Command c)
 {
     db.Repositories.Remove(c.Arguments[1]);
     db.Save();
 }
コード例 #18
0
ファイル: PrintCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        public override bool Interact(ref DirectoryInfo di, Command c)
        {
            Console.Write(c.Arguments[0]);

            return true;
        }
コード例 #19
0
ファイル: PluginCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "plugins";
 }
コード例 #20
0
ファイル: AptGetCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 void Uninstall(Command c)
 {
     var prog = new cmd.contracts.Progress.AnimatedBar();
     prog.PrintMessage("Removing");
 }
コード例 #21
0
ファイル: ColorCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "color";
 }
コード例 #22
0
ファイル: PrintCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "print";
 }
コード例 #23
0
ファイル: TitleCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "title";
 }
コード例 #24
0
ファイル: SleepCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "sleep";
 }
コード例 #25
0
ファイル: CdUpperCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Interact(ref DirectoryInfo di, Command c)
 {
     di = new DirectoryInfo(di.Parent.FullName);
     return true;
 }
コード例 #26
0
ファイル: EvalCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            ScriptInterpreter.Interprete(command.Arguments[0], ref path, Commands);

            return true;
        }
コード例 #27
0
ファイル: SleepCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            Thread.Sleep(int.Parse(command.Arguments[0]));

            return true;
        }
コード例 #28
0
ファイル: CopyCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Interact(ref DirectoryInfo path, Command c)
 {
     File.Copy(path.FullName + "\\" + c.Arguments[0], c.Arguments[1]);
     return true;
 }
コード例 #29
0
ファイル: TitleCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
        public override bool Interact(ref DirectoryInfo path, Command command)
        {
            Console.Title = command.Arguments[0];

            return true;
        }
コード例 #30
0
ファイル: WinApiCommand.cs プロジェクト: SchwarzerLoewe/Ecmd
 public override bool Accept(Command command)
 {
     return command.Name == "winapi";
 }