Ejemplo n.º 1
0
        /// <summary>
        /// Transform a command line string into CommandLineArgs, applying MapPath
        /// </summary>
        /// <param name="commandLine"></param>
        /// <returns></returns>
        public CommandLineArgs ParseArgs(TccCommand tccCommand, string commandLine)
        {
            var cmd = new CommandLineArgs(commandLine);

            if (MapPath != null)
            {
                foreach (var arg in cmd)
                {
                    ParseArg(tccCommand, arg);
                }
            }

            return(cmd);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute a command on the Tcc API. If the command line arguments include /?, it will be deferred
        /// to the generic command line executor, as this seems to be pre-processed by TCC natively.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public uint ExecuteCmd(TccCommand command, CommandLineArgs commandLineArgs)
        {
            try
            {
                if (commandLineArgs.Any(item => item.IsFlag && item.Option == "?"))
                {
                    return(Command(command.Name + " " + commandLineArgs.ToString()));
                }


                return(CmdExecutor.Execute(command.WinApiCmd, commandLineArgs.ToString()));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(1);
            }
        }
Ejemplo n.º 3
0
        private void ParseArg(TccCommand command, CommandLineArg argument)
        {
            // only parse things which we are sure aren't options; either by
            // nature of it not having a slash, or if it starts with a slash,
            // then by see if it matches a drive letter. Note that this could conflict
            // with options

            if (!command.IsOptionsDefined)
            {
                return;
            }

            if (argument.IsOption && command.HasOption(argument.Option, argument.IsFlag))
            {
                return;
            }

            argument.Value    = MapPath(argument.ToString());
            argument.IsOption = false;
        }