Example #1
0
        //adds a new command
        public override void Run()
        {
            string name = this.Arguments.GetSwitch("-add");

            //make sure a command name was present
            if (string.IsNullOrEmpty(name))
            {
                Console.WriteLine("You need to provide a name of the command to add.");
                return;
            }
            else if (string.IsNullOrEmpty(this.Arguments.Command))
            {
                Console.WriteLine("The command to add is blank.");
                return;
            }

            //build the command to save
            JumperCommand command = new JumperCommand {
                Name    = name,
                Command = this.Arguments.Command
            };

            //check alternate settings
            if (this.Arguments.GetSwitch("-rebase").Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                command.Path = Environment.CurrentDirectory;
            }

            //check alternate settings
            command.QuietMode = true;
            if (this.Arguments.GetSwitch("-quiet").Equals("false", StringComparison.OrdinalIgnoreCase))
            {
                command.QuietMode = false;
            }

            //check for an alternate argument prefix
            command.ArgumentPrefix = this.Arguments.GetSwitch("-args");

            //check of this replaces or not
            if (this.Settings.HasCommand(name))
            {
                Console.WriteLine("Replacing command '{0}'", name);
            }
            else
            {
                Console.WriteLine("Added command '{0}'", name);
            }
            this.Settings.AddCommand(command);
            this.Settings.Save();
        }
Example #2
0
        public override void Run()
        {
            //get the parts to execute
            string[] parts = this.Arguments.Command.Split(new char[] { ' ' });
            string   name  = parts.First();

            parts = parts.Skip(1).ToArray();

            //try and find the command to execute
            JumperCommand command = this.Settings.GetCommandByName(name);

            if (command == null)
            {
                Console.WriteLine("No command was found with the name '{0}'.", name);
                return;
            }

            //build the actual string to execute
            string execute = command.BuildCommand(parts);

            //create the BAT to run
            var builder = new StringBuilder();

            builder.AppendLine("@ECHO OFF");

            //construct the command
            if (command.ShouldRepath)
            {
                builder.AppendLine("SET JUMPER_START_DIRECTORY=%CD%");
                builder.AppendLine(string.Format("CD /D \"{0}\"", command.Path));
            }

            //include the command to run
            if (!command.QuietMode)
            {
                builder.AppendLine("@ECHO ON");
            }
            builder.AppendLine(string.Format("CALL {0}", execute));
            builder.AppendLine("@ECHO OFF");

            //return to the original directory if needed
            if (command.ShouldRepath)
            {
                builder.AppendLine("CD /D %JUMPER_START_DIRECTORY%");
            }

            //save the command to execute immediately
            File.WriteAllText(JumperSettings.BATFile, builder.ToString());
        }
Example #3
0
        //adds a new command
        public override void Run()
        {
            string name = this.Arguments.GetSwitch("-add");

            //make sure a command name was present
            if (string.IsNullOrEmpty(name)) {
                Console.WriteLine("You need to provide a name of the command to add.");
                return;
            }
            else if (string.IsNullOrEmpty(this.Arguments.Command)) {
                Console.WriteLine("The command to add is blank.");
                return;
            }

            //build the command to save
            JumperCommand command = new JumperCommand {
                Name = name,
                Command = this.Arguments.Command
            };

            //check alternate settings
            if (this.Arguments.GetSwitch("-rebase").Equals("true", StringComparison.OrdinalIgnoreCase))
                command.Path = Environment.CurrentDirectory;

            //check alternate settings
            command.QuietMode = true;
            if (this.Arguments.GetSwitch("-quiet").Equals("false", StringComparison.OrdinalIgnoreCase))
                command.QuietMode = false;

            //check for an alternate argument prefix
            command.ArgumentPrefix = this.Arguments.GetSwitch("-args");

            //check of this replaces or not
            if (this.Settings.HasCommand(name)) Console.WriteLine("Replacing command '{0}'", name);
            else Console.WriteLine("Added command '{0}'", name);
            this.Settings.AddCommand(command);
            this.Settings.Save();
        }
Example #4
0
 //includes a new command
 public void AddCommand(JumperCommand command)
 {
     this.RemoveCommand(command.Name);
     this.Commands.Add(command);
 }
Example #5
0
 //includes a new command
 public void AddCommand(JumperCommand command)
 {
     this.RemoveCommand(command.Name);
     this.Commands.Add(command);
 }