improvements

This commit is contained in:
olivier committed 2025-10-28 21:52:04 -04:00
1 parent 3d122b5022
commit bf1dca3bc4
12 files changed
+303 -103

No files matched your search

+105 -83
View File
@@ -1,6 +1,6 @@
# Onyx Python Helper
# Onyx CLI - Obsidian Command Line Tool
A Python-based command-line interface tool for interacting with Obsidian vaults. This tool allows you to manage your Obsidian notes directly from the terminal.
A Python-based command-line interface for interacting with Obsidian vaults. Manage notes directly from the terminal without opening Obsidian.
## Installation
@@ -10,130 +10,153 @@ A Python-based command-line interface tool for interacting with Obsidian vaults.
pip install -r requirements.txt
```
## Usage
### Set Default Vault
First, you need to set up your vault with both its name and path:
## Quick Start
Set up your default vault:
```bash
# Set up a new vault with its path (required for first use)
ob-cli set-default "vault-name" --path "/path/to/vault"
# Print current default vault and its path
ob-cli print-default
# Switch to another existing vault (only works for already configured vaults)
ob-cli set-default "another-vault"
ob-cli set-default "my-vault" --path "/path/to/vault"
```
### Open Notes
Then use any command:
```bash
ob-cli open "note-name"
ob-cli daily
ob-cli frontmatter "note-name" --view --key "tags"
```
## Commands
### Vault Management
```bash
# Set default vault (required first time)
ob-cli set-default "vault-name" --path "/path/to/vault"
# Print current default vault
ob-cli print-default
```
### Opening Notes
```bash
# Open a note in Obsidian
python src/obsidian_cli.py open "note-name"
ob-cli open "note-name"
# Open a note in specific vault
python src/obsidian_cli.py open "note-name" --vault "vault-name"
# Open note from specific vault
ob-cli open "note-name" --vault "vault-name"
```
### Daily Notes
### Periodic Notes
```bash
# Create and open today's daily note
python src/obsidian_cli.py daily
# Create or open today's daily note
ob-cli daily
# Create daily note in specific vault
python src/obsidian_cli.py daily --vault "vault-name"
# Create or open this week's note
ob-cli weekly
# Create or open this month's note
ob-cli monthly
# Create or open this quarter's note
ob-cli quarterly
# Create or open this year's note
ob-cli yearly
```
### Create/Update Notes
### Creating & Editing Notes
```bash
# Create a new note
python src/obsidian_cli.py create "note-name"
ob-cli create "note-name"
# Create note with content
python src/obsidian_cli.py create "note-name" --content "Your content here"
# Create with content
ob-cli create "note-name" --content "Your content here"
# Create note in specific vault
python src/obsidian_cli.py create "note-name" --vault "vault-name"
# Create in specific vault
ob-cli create "note-name" --vault "vault-name"
# Overwrite existing note
python src/obsidian_cli.py create "note-name" --content "New content" --overwrite
ob-cli create "note-name" --content "New content" --overwrite
# Append to existing note
python src/obsidian_cli.py create "note-name" --content "Additional content" --append
ob-cli create "note-name" --content "Additional content" --append
# Create and open note
python src/obsidian_cli.py create "note-name" --content "content" --open
# Create and open
ob-cli create "note-name" --content "content" --open
```
### View Notes
### Viewing Notes
```bash
# Print note contents
python src/obsidian_cli.py print-note "note-name"
# Print note contents to terminal
ob-cli print-note "note-name"
# Print note from specific vault
python src/obsidian_cli.py print-note "note-name" --vault "vault-name"
# Print from specific vault
ob-cli print-note "note-name" --vault "vault-name"
```
### Move/Rename Notes
### Moving & Deleting Notes
```bash
# Move/rename a note
python src/obsidian_cli.py move "old-path" "new-path"
# Move or rename a note (auto-updates internal links)
ob-cli move "old-path" "new-path"
# Move in specific vault
python src/obsidian_cli.py move "old-path" "new-path" --vault "vault-name"
ob-cli move "old-path" "new-path" --vault "vault-name"
# Move and open note
python src/obsidian_cli.py move "old-path" "new-path" --open
```
# Move and open
ob-cli move "old-path" "new-path" --open
### Delete Notes
```bash
# Delete a note
python src/obsidian_cli.py delete "note-path"
ob-cli delete "note-path"
# Delete from specific vault
python src/obsidian_cli.py delete "note-path" --vault "vault-name"
ob-cli delete "note-path" --vault "vault-name"
```
### Frontmatter Management
```bash
# Edit frontmatter
python src/obsidian_cli.py frontmatter "note-name" --edit --key "tags" --value "project"
python src/obsidian_cli.py frontmatter "note-name" --edit --key "tags" --value "project,urgent"
python src/obsidian_cli.py frontmatter "note-name" --edit --key "status" --value "in-progress"
Edit note metadata in YAML frontmatter:
# View frontmatter
python src/obsidian_cli.py frontmatter "note-name" --view --key "tags"
python src/obsidian_cli.py frontmatter "note-name" --view --key "tags" --value "project"
```bash
# View a frontmatter key
ob-cli frontmatter "note-name" --view --key "tags"
# Check if a value exists in frontmatter
ob-cli frontmatter "note-name" --view --key "tags" --value "project"
# Edit frontmatter (add or update key)
ob-cli frontmatter "note-name" --edit --key "tags" --value "project"
ob-cli frontmatter "note-name" --edit --key "tags" --value "project,urgent"
ob-cli frontmatter "note-name" --edit --key "status" --value "in-progress"
# Clear frontmatter values
python src/obsidian_cli.py frontmatter "note-name" --clear --key "tags"
python src/obsidian_cli.py frontmatter "note-name" --clear --key "date,status,tags"
ob-cli frontmatter "note-name" --clear --key "tags"
ob-cli frontmatter "note-name" --clear --key "date,status,tags"
# Delete frontmatter keys
python src/obsidian_cli.py frontmatter "note-name" --delete --key "tags"
python src/obsidian_cli.py frontmatter "note-name" --delete --key "date,status,tags"
ob-cli frontmatter "note-name" --delete --key "tags"
ob-cli frontmatter "note-name" --delete --key "date,status,tags"
```
### Version
```bash
# Display version
ob-cli --version
```
## Features
The tool now includes all major features from the original Obsidian CLI tool:
- Set and manage default vault
- Open notes in Obsidian
- Create and manage daily notes
- Create/update notes with content
- Print note contents
- Move/rename notes (with automatic link updates)
- Delete notes
- Complete frontmatter management (edit, view, clear, delete)
- **Vault Management**: Set and switch between multiple Obsidian vaults
- **Note Operations**: Create, open, move, rename, and delete notes
- **Recursive Search**: Find notes in nested directories
- **Periodic Notes**: Support for daily, weekly, monthly, quarterly, and yearly notes
- **Frontmatter Management**: Edit, view, clear, and delete YAML frontmatter
- **Link Updates**: Automatically update internal links when moving notes
- **Cross-Platform**: Works on macOS, Windows, and Linux
## Requirements
@@ -145,8 +168,6 @@ The tool now includes all major features from the original Obsidian CLI tool:
### Running Tests
To run the tests:
```bash
# Install test dependencies
pip install -r requirements.txt
@@ -154,15 +175,16 @@ pip install -r requirements.txt
# Run tests
python -m pytest
# Run tests with coverage report
# Run with coverage
python -m pytest --cov=src tests/
```
The test suite includes tests for:
- Vault management
- Note creation and modification
- Frontmatter operations
- Note movement and link updates
- Daily notes
- Platform-specific note opening
- Note deletion
## Configuration
The CLI stores vault configuration in `~/.onyx-cli/config.yaml`. You can manually edit this file to manage vaults:
```yaml
default_vault: my-vault
vaults:
my-vault: /path/to/vault
work: /path/to/work/vault