Ejemplo n.º 1
0
        public void Run(string[] args)
        {
            // Run the initial commands
            var commands = this.ConstructMultipleCommands(args);

            try
            {
                ExecuteCommands(commands);
            }
            catch (Exception e)
            {
                _console.WriteLine("An exception was thrown while running your initial commands\n  Message: {0}\n  Trace: {1}", e.Message, e.StackTrace);
            }

            // Allow more commands to be entered via UI
            var command = string.Empty;

            do
            {
                try
                {
                    ExecuteCommand(command);
                }
                catch (Exception e)
                {
                    _console.WriteLine("An exception was thrown while running your command\n  Message: {0}\n  Trace: {1}", e.Message, e.StackTrace);
                }

                _console.Write(_state.CmdPrompt);
                command = _console.ReadLine();
            }while (!_state.ExitCodes.Contains(command));
        }
Ejemplo n.º 2
0
        public void ListDirectory(IDictionary<string, string> param, ICmdRConsole console, ICmdRState state)
        {
            foreach(var file in Directory.GetFiles(_directory))
            {
                console.WriteLine(Path.GetFileName(file));
            }

            foreach (var directory in Directory.GetDirectories(_directory))
            {
                console.WriteLine(directory);
            }
        }
Ejemplo n.º 3
0
        public void ListDirectory(IDictionary <string, string> param, ICmdRConsole console, ICmdRState state)
        {
            foreach (var file in Directory.GetFiles(_directory))
            {
                console.WriteLine(Path.GetFileName(file));
            }

            foreach (var directory in Directory.GetDirectories(_directory))
            {
                console.WriteLine(directory);
            }
        }
Ejemplo n.º 4
0
        public void DeleteFile(IDictionary<string, string> param, ICmdRConsole console, ICmdRState state)
        {
            var file = param["file"];

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            else if (File.Exists(_directory + file))
            {
                File.Delete(_directory + file);
            }
            else console.WriteLine("{0} does not exist", file);
        }
Ejemplo n.º 5
0
        public void DeleteFile(IDictionary <string, string> param, ICmdRConsole console, ICmdRState state)
        {
            var file = param["file"];

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            else if (File.Exists(_directory + file))
            {
                File.Delete(_directory + file);
            }
            else
            {
                console.WriteLine("{0} does not exist", file);
            }
        }
Ejemplo n.º 6
0
        public void ChangeDirectory(IDictionary<string, string> param, ICmdRConsole console, ICmdRState state)
        {
            var path = param["path"];

            if (Directory.Exists(path))
            {
                _directory = path;
            }
            else if (Directory.Exists(_directory + path))
            {
                _directory = _directory + path;
            }
            else console.WriteLine("{0} is not a valid directory", path);

            if (_directory.Last() != '\\')
                _directory = _directory + "\\";

            state.CmdPrompt = string.Format("{0}> ", _directory);
        }
Ejemplo n.º 7
0
        public void ChangeDirectory(IDictionary <string, string> param, ICmdRConsole console, ICmdRState state)
        {
            var path = param["path"];

            if (Directory.Exists(path))
            {
                _directory = path;
            }
            else if (Directory.Exists(_directory + path))
            {
                _directory = _directory + path;
            }
            else
            {
                console.WriteLine("{0} is not a valid directory", path);
            }

            if (_directory.Last() != '\\')
            {
                _directory = _directory + "\\";
            }

            state.CmdPrompt = string.Format("{0}> ", _directory);
        }