mirror of
https://github.com/natelandau/obsidian-metadata.git
synced 2025-11-17 01:13:39 -05:00
feat: export metadata (#14)
* docs(readme): fix line breaks * feat: export metadata to a CSV * fix: finalize colors for questions * feat: inspect frontmatter, inline, and tags separately * feat: export metadata to JSON * fix: do not count in-page links as tags * ci(codecov): adjust patch target percentage down * feat(metadata): export CSV or JSON from command line
This commit is contained in:
@@ -28,16 +28,30 @@ HELP_TEXT = """
|
||||
@app.command()
|
||||
@docstring_parameter(__package__)
|
||||
def main(
|
||||
vault_path: Path = typer.Option(
|
||||
None,
|
||||
help="Path to Obsidian vault",
|
||||
show_default=False,
|
||||
),
|
||||
config_file: Path = typer.Option(
|
||||
Path(Path.home() / f".{__package__}.toml"),
|
||||
help="Specify a custom path to a configuration file",
|
||||
show_default=False,
|
||||
),
|
||||
export_csv: Path = typer.Option(
|
||||
None,
|
||||
help="Exports all metadata to a specified CSV file and exits. (Will overwrite any existing file)",
|
||||
show_default=False,
|
||||
dir_okay=False,
|
||||
file_okay=True,
|
||||
),
|
||||
export_json: Path = typer.Option(
|
||||
None,
|
||||
help="Exports all metadata to a specified JSON file and exits. (Will overwrite any existing file)",
|
||||
show_default=False,
|
||||
dir_okay=False,
|
||||
file_okay=True,
|
||||
),
|
||||
vault_path: Path = typer.Option(
|
||||
None,
|
||||
help="Path to Obsidian vault",
|
||||
show_default=False,
|
||||
),
|
||||
dry_run: bool = typer.Option(
|
||||
False,
|
||||
"--dry-run",
|
||||
@@ -89,6 +103,10 @@ def main(
|
||||
[bold underline]Inspect Metadata[/]
|
||||
Inspect the metadata in your vault.
|
||||
• View all metadata in the vault
|
||||
• View all frontmatter
|
||||
• View all inline metadata
|
||||
• View all inline tags
|
||||
• Export all metadata to CSV or JSON file
|
||||
|
||||
[bold underline]Filter Notes in Scope[/]
|
||||
Limit the scope of notes to be processed with one or more filters.
|
||||
@@ -165,6 +183,15 @@ 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)
|
||||
|
||||
if export_json is not None:
|
||||
path = Path(export_json).expanduser().resolve()
|
||||
application.noninteractive_export_json(path)
|
||||
raise typer.Exit(code=0)
|
||||
if export_csv is not None:
|
||||
path = Path(export_json).expanduser().resolve()
|
||||
application.noninteractive_export_csv(path)
|
||||
raise typer.Exit(code=0)
|
||||
|
||||
application.application_main()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user