rename
This commit is contained in:
		
							parent
							
								
									615a0c9254
								
							
						
					
					
						commit
						279b45b1ee
					
				
					 4 changed files with 34 additions and 11 deletions
				
			
		|  | @ -1,11 +1,12 @@ | |||
| # maddog | ||||
| # modo | ||||
| 
 | ||||
| A suite of tools for dealing with a directory of markdown files. | ||||
| 
 | ||||
| ## Tasks | ||||
| 
 | ||||
| - TODO: improve inline help | ||||
| - TODO: more flags | ||||
|   - [ ] filters | ||||
|   - [x] filters | ||||
|   - [x] sorting | ||||
|   - [ ] reverse sort | ||||
| - TODO: add config file {by:2024-08-01} | ||||
|  | @ -14,7 +15,7 @@ A suite of tools for dealing with a directory of markdown files. | |||
| - DONE: support checkboxes | ||||
|   - [x] scan lists | ||||
|   - [x] percent complete | ||||
| - TODO: decide on more permanent name {by:2024-08-15} | ||||
| - DONE: decide on more permanent name {by:2024-08-15} | ||||
| - IDEA: recurring? | ||||
| - IDEA: track changes | ||||
| - DONE: add color {by: 2024-07-26} | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| [project] | ||||
| name = "maddog" | ||||
| name = "modo" | ||||
| version = "0.1.0" | ||||
| description = "markdown tools" | ||||
| description = "todos and more from simple markdown" | ||||
| authors = [{ name = "James Turk", email = "dev@jpt.sh" }] | ||||
| dependencies = ["click>=8.1.7", "rich>=13.7.1", "python-dateutil>=2.9.0.post0"] | ||||
| requires-python = ">=3.12" | ||||
|  | @ -9,7 +9,7 @@ readme = "README.md" | |||
| license = { text = "MIT" } | ||||
| 
 | ||||
| [project.scripts] | ||||
| maddog = "maddog.app:cli" | ||||
| modo = "modo.app:cli" | ||||
| 
 | ||||
| [build-system] | ||||
| requires = ["pdm-backend"] | ||||
|  |  | |||
|  | @ -187,19 +187,37 @@ def get_todo_sort_func(keys): | |||
|     return sort_func | ||||
| 
 | ||||
| 
 | ||||
| def apply_filter(items, rule): | ||||
|     key, val = rule.split(":") | ||||
|     if key == "status": | ||||
|         return [item for item in items if item.status == val] | ||||
|     else: | ||||
|         return [item for item in items if rule in item.tags] | ||||
| 
 | ||||
| 
 | ||||
| @cli.command() | ||||
| @click.argument("dirname", nargs=-1) | ||||
| @click.argument("dirname", default="") | ||||
| @click.option("--sort", "-s") | ||||
| def todos(dirname, sort): | ||||
| @click.option("--filter", "-f", multiple=True) | ||||
| def todos(dirname, sort, filter): | ||||
|     # scan files | ||||
|     output = []  # list of data | ||||
|     for file in get_files(dirname): | ||||
|         output += pull_todos(file) | ||||
| 
 | ||||
|     # filter | ||||
|     for rule in filter: | ||||
|         output = apply_filter(output, rule) | ||||
| 
 | ||||
|     # do sorting | ||||
|     if not sort: | ||||
|         sort = ["status", "due"] | ||||
|     else: | ||||
|         sort = sort.split(",") | ||||
|     sort_func = get_todo_sort_func(sort) | ||||
|     output.sort(key=sort_func) | ||||
| 
 | ||||
|     # display | ||||
|     table = lod_table(output) | ||||
|     console.print(table) | ||||
| 
 | ||||
|  | @ -256,7 +274,7 @@ def human_readable_date(dt: datetime.datetime) -> str: | |||
|     elif delta < datetime.timedelta(days=1): | ||||
|         return f"{int(delta.total_seconds() / 3600)}h ago" | ||||
|     else: | ||||
|         return f"{int(delta.total_seconds() / 3600 / 24)}d ago" | ||||
|         return f"{delta.days}d ago" | ||||
| 
 | ||||
| 
 | ||||
| def scan_contents(file: pathlib.Path) -> dict: | ||||
|  | @ -266,10 +284,10 @@ def scan_contents(file: pathlib.Path) -> dict: | |||
| 
 | ||||
| 
 | ||||
| @cli.command() | ||||
| @click.argument("dirname", nargs=-1) | ||||
| @click.argument("dirname", default="") | ||||
| @click.option("--sort", "-s") | ||||
| def ls(dirname, sort): | ||||
|     table = Table() | ||||
|     # scan files | ||||
|     output = [] | ||||
|     for file in get_files(dirname): | ||||
|         st = file.stat() | ||||
|  | @ -283,12 +301,16 @@ def ls(dirname, sort): | |||
|                 **scan, | ||||
|             ) | ||||
|         ) | ||||
| 
 | ||||
|     # sort | ||||
|     if not sort: | ||||
|         sort = ["file", "modified"] | ||||
|     else: | ||||
|         sort = sort.split(",") | ||||
|     sort_func = get_ls_sort_func(sort) | ||||
|     output.sort(key=sort_func) | ||||
| 
 | ||||
|     # display | ||||
|     table = lod_table(output) | ||||
|     console.print(table) | ||||
| 
 | ||||
		Loading…
	
		Reference in a new issue