feat(application): add new metadata to frontmatter (#9)

* feat(frontmatter): frontmatter method to add key, values

* build: add pysnooper to aid in debugging

* feat(application): add new frontmatter

* build: clean up dev container

* fix(notes): diff now pretty prints in a table

* docs(readme): update usage information

* docs(readme): fix markdown lists
This commit is contained in:
Nathaniel Landau
2023-01-30 11:06:31 -05:00
committed by GitHub
parent ac0090c6c9
commit eeaa1e7576
18 changed files with 1307 additions and 675 deletions

View File

@@ -70,29 +70,50 @@ def main(
None, "--version", help="Print version and exit", callback=version_callback, is_eager=True
),
) -> None:
r"""A script to make batch updates to metadata in an Obsidian vault.
r"""A script to make batch updates to metadata in an Obsidian vault. No changes are made to the Vault until they are explicitly committed.
[bold] [/]
[bold underline]Features:[/]
- [code]in-text tags:[/] delete every occurrence
- [code]in-text tags:[/] Rename tag ([dim]#tag1[/] -> [dim]#tag2[/])
- [code]frontmatter:[/] Delete a key matching a regex pattern and all associated values
- [code]frontmatter:[/] Rename a key
- [code]frontmatter:[/] Delete a value matching a regex pattern from a specified key
- [code]frontmatter:[/] Rename a value from a specified key
- [code]inline metadata:[/] Delete a key matching a regex pattern and all associated values
- [code]inline metadata:[/] Rename a key
- [code]inline metadata:[/] Delete a value matching a regex pattern from a specified key
- [code]inline metadata:[/] Rename a value from a specified key
- [code]vault:[/] Create a backup of the Obsidian vault.
[bold underline]Usage:[/]
[tan]Obsidian-metadata[/] allows you to make batch updates to metadata in an Obsidian vault. Once you have made your changes, review them prior to committing them to the vault. The script provides a menu of available actions. Make as many changes as you require and review them as you go. No changes are made to the Vault until they are explicitly committed.
[bold underline]It is strongly recommended that you back up your vault prior to committing changes.[/] This script makes changes directly to the markdown files in your vault. Once the changes are committed, there is no ability to recreate the original information unless you have a backup. Follow the instructions in the script to create a backup of your vault if needed. The author of this script is not responsible for any data loss that may occur. Use at your own risk.
[bold underline]Configuration:[/]
Configuration is specified in a configuration file. On First run, this file will be created at [tan]~/.{0}.env[/]. Any options specified on the command line will override the configuration file.
[bold underline]Usage:[/]
[tan]Obsidian-metadata[/] provides a menu of sub-commands.
[bold underline]Vault Actions[/]
• Backup: Create a backup of the vault.
• Delete Backup: Delete a backup of the vault.
[bold underline]Inspect Metadata[/]
• View all metadata in the vault
[bold underline]Filter Notes in Scope[/]
Limit the scope of notes to be processed with a regex.
• Apply regex: Set a regex to limit scope
• List notes in scope: List notes that will be processed.
[bold underline]Add Metadata[/]
• Add metadata to the frontmatter
• [dim]Add to inline metadata (Not yet implemented)[/]
• [dim]Add to inline tag (Not yet implemented)[/]
[bold underline]Rename Metadata[/]
• Rename a key
• Rename a value
• rename an inline tag
[bold underline]Delete Metadata[/]
• Delete a key and associated values
• Delete a value from a key
• Delete an inline tag
[bold underline]Review Changes[/]
• View a diff of the changes that will be made
[bold underline]Commit Changes[/]
• Commit changes to the vault
"""
# Instantiate logger
alerts.LoggerManager( # pragma: no cover
@@ -134,7 +155,7 @@ def main(
vault_to_use = next(vault for vault in config.vaults if vault.name == vault_name)
application = Application(dry_run=dry_run, config=vault_to_use)
application.main_app()
application.application_main()
if __name__ == "__main__":