CLI tool for running Playbooks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

1 year ago
10 months ago
1 year ago
6 months ago
1 year ago
  1. using System;
  2. using System.Threading.Tasks;
  3. using TrustedUninstaller.Shared.Tasks;
  4. using YamlDotNet.Serialization;
  5. namespace TrustedUninstaller.Shared.Actions
  6. {
  7. public class WriteStatusAction : TaskAction, ITaskAction
  8. {
  9. public void RunTaskOnMainThread() { throw new NotImplementedException(); }
  10. [YamlMember(typeof(string), Alias = "status")]
  11. public string Status { get; set; }
  12. private bool InProgress { get; set; }
  13. public void ResetProgress() => InProgress = false;
  14. public string ErrorString() => "";
  15. public int GetProgressWeight() => 0;
  16. public UninstallTaskStatus GetStatus()
  17. {
  18. if (InProgress)
  19. {
  20. return UninstallTaskStatus.InProgress;
  21. }
  22. return hasCompleted ? UninstallTaskStatus.Completed : UninstallTaskStatus.ToDo;
  23. }
  24. private bool hasCompleted;
  25. public async Task<bool> RunTask()
  26. {
  27. if (String.IsNullOrEmpty(Status))
  28. {
  29. Console.WriteLine(":AME-STATUS: " + "Running actions");
  30. }
  31. else
  32. {
  33. Console.WriteLine(":AME-STATUS: " + Status);
  34. }
  35. hasCompleted = true;
  36. return true;
  37. }
  38. }
  39. }