public IEnumerable <string> GetArgValidationErrors()
        {
            var errors = new List <string>();

            if (List)
            {
                return(errors);
            }

            if (!ShowDefaults && Account == ServiceAccount.User)
            {
                if (string.IsNullOrWhiteSpace(Username))
                {
                    errors.Add("user is required when account=User");
                }
                if (string.IsNullOrWhiteSpace(Password))
                {
                    errors.Add("pwd is required when account=User");
                }
            }

            if (string.IsNullOrWhiteSpace(CommandLine))
            {
                errors.Add("command is required");
            }
            else
            {
                if (ExtraArgs.Count > 0)
                {
                    CommandLine = CommandLine.TrimEnd() + " " + string.Join(" ", ExtraArgs);
                    ExtraArgs.Clear();
                }

                _commandRunData = CommandsOptions.Load(CommandLine);

                if (_commandRunData.Errors.Count > 0)
                {
                    errors.Add("errors with arguments for /command");
                    errors.AddRange(_commandRunData.Errors);
                }
                else
                {
                    _serviceCommand = _commandRunData.Command as ICanRunAsService;
                    if (_serviceCommand == null)
                    {
                        errors.Add(_commandRunData.Command.GetType().Name + " does not implement ICanRunAsService");
                    }
                    else
                    {
                        ServiceName = ServiceName ?? _serviceCommand.ServiceName;
                        DisplayName = DisplayName ?? _serviceCommand.DisplayName;
                        Description = Description ?? _serviceCommand.Description;
                    }
                }
            }
            return(errors);
        }
        public IEnumerable<string> GetArgValidationErrors()
        {
            var errors = new List<string>();
            if (List)
            {
                return errors;
            }

            if (!ShowDefaults && Account == ServiceAccount.User)
            {
                if (string.IsNullOrWhiteSpace(Username))
                {
                    errors.Add("user is required when account=User");
                }
                if (string.IsNullOrWhiteSpace(Password))
                {
                    errors.Add("pwd is required when account=User");
                }
            }

            if (string.IsNullOrWhiteSpace(CommandLine))
            {
                errors.Add("command is required");
            }
            else
            {
                if (ExtraArgs.Count > 0)
                {
                    CommandLine = CommandLine.TrimEnd() + " " + string.Join(" ", ExtraArgs);
                    ExtraArgs.Clear();
                }

                _commandRunData = CommandsOptions.Load(CommandLine);

                if (_commandRunData.Errors.Count > 0)
                {
                    errors.Add("errors with arguments for /command");
                    errors.AddRange(_commandRunData.Errors);
                }
                else
                {
                    _serviceCommand = _commandRunData.Command as ICanRunAsService;
                    if (_serviceCommand == null)
                    {
                        errors.Add(_commandRunData.Command.GetType().Name + " does not implement ICanRunAsService");
                    }
                    else
                    {
                        ServiceName = ServiceName ?? _serviceCommand.ServiceName;
                        DisplayName = DisplayName ?? _serviceCommand.DisplayName;
                        Description = Description ?? _serviceCommand.Description;
                    }
                }
            }
            return errors;
        }