The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ArgumentOptions.cs 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using CommandLine;
  2. using CommandLine.Text;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace ServerMaint
  9. {
  10. public class ArgumentOptions
  11. {
  12. [ParserState]
  13. public IParserState LastParserState { get; set; }
  14. [Option('a', "all", DefaultValue = false, Required = false, HelpText = "Run All Processes")]
  15. public bool RunAll { get; set; }
  16. [Option('u', "clean-users", DefaultValue = false, Required = false, HelpText = "Clean all inactive users")]
  17. public bool CleanUsers { get; set; }
  18. [Option('e', "clean-emails", DefaultValue = false, Required = false, HelpText = "Clean all unused email accounts")]
  19. public bool CleanEmails { get; set; }
  20. [Option('g', "clean-git", DefaultValue = false, Required = false, HelpText = "Clean all unused git accounts")]
  21. public bool CleanGit { get; set; }
  22. [Option('w', "warn", DefaultValue = false, Required = false, HelpText = "Warn all invalid accounts")]
  23. public bool WarnAccounts { get; set; }
  24. [Option('s', "scan", DefaultValue = false, Required = false, HelpText = "Scan all uploads for viruses")]
  25. public bool ScanUploads { get; set; }
  26. [Option('c', "config", Required = false, HelpText = "The path to the teknik config file")]
  27. public string Config { get; set; }
  28. [Option('d', "days", DefaultValue = 90, Required = false, HelpText = "Days before the user is deleted")]
  29. public int DaysBeforeDeletion { get; set; }
  30. [Option('l', "last-seen", DefaultValue = false, Required = false, HelpText = "Generate a list of user's last seen stats")]
  31. public bool GenerateLastSeen { get; set; }
  32. [Option('f', "last-seen-file", Required = false, HelpText = "The file in which you want the last seen stats to be saved to")]
  33. public string LastSeenFile { get; set; }
  34. [Option('i', "invalid", DefaultValue = false, Required = false, HelpText = "Generate a list of invalid accounts")]
  35. public bool GenerateInvalid { get; set; }
  36. [Option('t', "invalid-file", Required = false, HelpText = "The file in which you want the invalid accounts to be saved to")]
  37. public string InvalidFile { get; set; }
  38. [Option('o', "to-clean", DefaultValue = false, Required = false, HelpText = "Generate a list of accounts to be cleaned")]
  39. public bool GenerateCleaning { get; set; }
  40. [Option('n', "to-clean-file", Required = false, HelpText = "The file in which you want the accounts to be cleaned to be saved to")]
  41. public string CleaningFile { get; set; }
  42. // Omitting long name, default --verbose
  43. [Option(HelpText = "Prints all messages to standard output.")]
  44. public bool Verbose { get; set; }
  45. [HelpOption]
  46. public string GetUsage()
  47. {
  48. var help = new HelpText();
  49. // ...
  50. if (this.LastParserState.Errors.Any())
  51. {
  52. var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
  53. if (!string.IsNullOrEmpty(errors))
  54. {
  55. help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
  56. help.AddPreOptionsLine(errors);
  57. }
  58. }
  59. // ...
  60. return help;
  61. }
  62. }
  63. }