Example #1
0
        public HelpCommand(ICollection <Command> col)
        {
            this._cmds = col as ConsoleCommander.Structures.LinkedList <Command>;
            _names     = new String[col.Count];
            Int32 i = 0;

            if (_cmds == null)
            {
                _cmds = new ConsoleCommander.Structures.LinkedList <Command>();
                foreach (Command c in col)
                {
                    _cmds.Add(c);
                    _names[i] = c.GetName();
                    i++;
                }
            }
            else
            {
                foreach (Command c in col)
                {
                    _names[i] = c.GetName();
                    i++;
                }
            }
        }
Example #2
0
        public override void Execute(ConsoleCommander.Structures.LinkedList <String> args)
        {
            List <String> l = new List <String>(Directory.EnumerateFileSystemEntries(_d.CPath));

            String cp  = _d.CPath;
            Int32  ind = 1;
            String ce;

            LinkedStack <String> STACK = new LinkedStack <String>();
            LinkedStack <Int32>  S2    = new LinkedStack <Int32>();

            foreach (String p in l)
            {
                STACK.Push(p);
                S2.Push(1);
            }
            while (!STACK.IsEmpty())
            {
                ce = STACK.Top();
                STACK.Pop();
                ind = S2.Top();
                S2.Pop();
                String temp = $"{__GenEStr(ind)+ce.Substring(ce.LastIndexOf(Path.DirectorySeparatorChar) + 1)}";
                Console.WriteLine(temp);
                if (Directory.Exists(ce))
                {
                    List <String> _ne = new List <String>(Directory.EnumerateFileSystemEntries(Path.Combine(cp, ce)));
                    for (Int32 i = 0; i < _ne.Count; i++)
                    {
                        STACK.Push(_ne[i]);
                        S2.Push(ind + 4);
                    }
                }
            }
        }
Example #3
0
        public override void Execute(ConsoleCommander.Structures.LinkedList <String> args)
        {
            if (args.Count > 2)
            {
                String inp  = args[1]; //files
                String k    = args[2]; //key
                String dest = args[3]; //destination directory.
                if (k != "d")
                {
                    Console.WriteLine("Syntax Error. Type destination directory like d=dirName");
                    return;
                }
                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }


                //IF IT IS A DIRECTORY COPY ITS CONTENT RECURSIVELY
                if (Directory.Exists(inp))
                {
                    __CopyDirectory(dest, inp);
                }

                List <String> files = new List <String>(Directory.EnumerateFiles(_d.CPath, inp));
                __CopyFiles(files, dest);
            }
            else if (args.Count == 2)
            {
                String k    = args[1]; //key
                String dest = args[2]; //destination directory.
                if (k != "d")
                {
                    Console.WriteLine("Syntax Error. Type destination directory like d=dirName");
                    return;
                }
                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }

                __CopyDirectory(dest);
            }
            else
            {
                Console.WriteLine("ERROR. Type filename and destination directory!");
            }
        }
Example #4
0
        public override void Execute(ConsoleCommander.Structures.LinkedList <String> args)
        {
            if (args == null || args.Count == 0)//help was typed.
            {
                for (Int32 i = 1; i <= _cmds.Count; i++)
                {
                    Console.WriteLine("{0}: {1} {2}", _names[i - 1], _cmds[i].Description(), i);
                }
                Console.WriteLine(base.GetName() + ": " + base.Description());//overrite Description()
            }
            else if (args.Count == 1)
            {
                String c  = args[1];
                Int32  ii = 0;
                if (c == "help")
                {
                    Console.WriteLine(base.GetName() + ": " + base.Description());//overrite Description()
                    return;
                }

                while (ii < _names.Length)
                {
                    if (_names[ii].ToLower().IndexOf(c) != -1)
                    {
                        break;
                    }
                    ii++;
                }

                if (ii < _names.Length)
                {
                    Command dc = _cmds[ii + 1];
                    Console.WriteLine(dc.GetName() + ": " + dc.Description());
                }
                else
                {
                    Console.WriteLine("command not found");
                }
            }
            else
            {
                Console.WriteLine("SYNTAX ERROR");
            }
        }
Example #5
0
 public HelpCommand()
 {
     this._cmds = new ConsoleCommander.Structures.LinkedList <Command>();
     _names     = new String[1];
 }