initial checkin
This commit is contained in:
		
				commit
				
					
						abd1c5023d
					
				
			
		
					 2 changed files with 82 additions and 0 deletions
				
			
		
							
								
								
									
										51
									
								
								bugwarrior-check.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										51
									
								
								bugwarrior-check.py
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| # TaskWarrior hook to keep a logseq->bugwarrior task open, but taskopen it | ||||
| # so that it may directly be closed in logseq. | ||||
| 
 | ||||
| import json | ||||
| import os | ||||
| import sys | ||||
| import subprocess | ||||
| 
 | ||||
| 
 | ||||
| def get_task_data() -> str: | ||||
|     """ | ||||
|     Gets task data from stdin. | ||||
| 
 | ||||
|     It might be first line on task addition and second line on task | ||||
|     modification. | ||||
| 
 | ||||
|     :return: str | ||||
|     """ | ||||
|     input_data = sys.stdin.readlines() | ||||
| 
 | ||||
|     #    with open("/tmp/abracadabra", "w") as f: | ||||
|     #        f.write(input_data[-1]) | ||||
| 
 | ||||
|     return input_data[-1] | ||||
| 
 | ||||
| 
 | ||||
| def is_from_cli() -> bool: | ||||
|     """ | ||||
|     Checks for TASK_SRC being set to CLI.  If it is, then return True | ||||
|     If it isn't set, or is set to something other than cli, return False | ||||
|     """ | ||||
|     try: | ||||
|         if "cli" in os.environ["TASK_SRC"]: | ||||
|             return True | ||||
|     except KeyError: | ||||
|         return False | ||||
|     return False | ||||
| 
 | ||||
| 
 | ||||
| task_data_raw = get_task_data() | ||||
| 
 | ||||
| task_data = json.loads(task_data_raw) | ||||
| 
 | ||||
| if "bw" in task_data["tags"] and task_data['status'] == 'completed' and is_from_cli(): | ||||
|     task_data["status"] = "pending" | ||||
|     subprocess.run(["taskopen", task_data["uuid"]], stdout=subprocess.DEVNULL) | ||||
| 
 | ||||
| print(json.dumps(task_data, ensure_ascii=False)) | ||||
| sys.exit(0) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue