Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        private void Init(IParseCommands parser, IRouteCommands routing, IParseRoutes routeParser, ICmdRConsole console, ICmdRState state, string[] exitcodes = null, string cmdPrompt = "> ")
        {
            _state           = state;
            _state.CmdPrompt = cmdPrompt;
            _state.Routes    = routing.GetRoutes();
            _state.ExitCodes = exitcodes ?? new string[] { "exit" };

            _console = console;

            _commandParser = parser;
            _commandRouter = routing;
            _routeParser   = routeParser;
        }
Exemplo n.º 3
0
        private void Init(IParseCommands parser, IRouteCommands routing, IParseRoutes routeParser, ICmdRConsole console, ICmdRState state, string[] exitcodes = null, string cmdPrompt = "> ")
        {
            _state = state;
            _state.CmdPrompt = cmdPrompt;
            _state.Routes = routing.GetRoutes();
            _state.ExitCodes = exitcodes ?? new string[] { "exit" };

            _console = console;

            _commandParser = parser;
            _commandRouter = routing;
            _routeParser = routeParser;
        }
Exemplo 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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public void Clear(IDictionary<string, string> param, ICmdRConsole console, ICmdRState state)
 {
     console.Clear();
 }
Exemplo n.º 7
0
 public void Execute(IDictionary<string, string> parameters, ICmdRConsole console, ICmdRState state)
 {
     Action.Invoke(parameters, console, state);
 }
Exemplo n.º 8
0
 public CmdR(IParseCommands parser = null, IRouteCommands routing = null, IParseRoutes routeParser = null, ICmdRConsole console = null, ICmdRState state = null, string[] exitcodes = null, string cmdPrompt = "> ")
 {
     Init(parser ?? new OrderedCommandParser(), routing ?? new Routing(), routeParser ?? new RouteParser(), console ?? new CmdRConsole(), state ?? new CmdRState(), exitcodes, cmdPrompt);
 }
Exemplo n.º 9
0
 public void Execute(IDictionary <string, string> parameters, ICmdRConsole console, ICmdRState state)
 {
     Action.Invoke(parameters, console, state);
 }
Exemplo n.º 10
0
 public void Clear(IDictionary <string, string> param, ICmdRConsole console, ICmdRState state)
 {
     console.Clear();
 }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 public CmdR(IParseCommands parser = null, IRouteCommands routing = null, IParseRoutes routeParser = null, ICmdRConsole console = null, ICmdRState state = null, string[] exitcodes = null, string cmdPrompt = "> ")
 {
     Init(parser ?? new OrderedCommandParser(), routing ?? new Routing(), routeParser ?? new RouteParser(), console ?? new CmdRConsole(), state ?? new CmdRState(), exitcodes, cmdPrompt);
 }