Add CLI source code and update .gitignore

This commit is contained in:
2026-04-07 09:38:12 +08:00
parent 6ef2dddf3f
commit 9e17f1bf29
18 changed files with 2663 additions and 1 deletions

View File

@@ -0,0 +1,118 @@
# CodiMD CLI Harness
A stateful CLI for [CodiMD](https://github.com/hackmdio/codimd) - collaborative markdown notes on all platforms.
## Installation
```bash
pip install cli-anything-codimd
```
## Quick Start
```bash
# Set your CodiMD server
cli-anything-codimd config set server https://your-codimd-server.com
# List your notes
cli-anything-codimd note list
# Create a new note
cli-anything-codimd note create --content "# My New Note\n\nHello world"
# Get note content
cli-anything-codimd note get <note-id>
# Export as markdown
cli-anything-codimd export markdown <note-id> --output note.md
# Get user info
cli-anything-codimd user me
```
## Commands
### Note Operations
| Command | Description |
|---------|-------------|
| `note list` | List user's notes |
| `note get <id>` | Get note content |
| `note create` | Create new note |
| `note update <id>` | Update note content |
| `note delete <id>` | Delete note |
| `note info <id>` | Get note metadata |
| `note publish <id>` | Get publish link |
### User Operations
| Command | Description |
|---------|-------------|
| `user me` | Get current user info |
| `user login` | Login to server |
| `user logout` | Logout from session |
| `user export` | Export all user data |
| `user delete` | Delete user account |
### Export Operations
| Command | Description |
|---------|-------------|
| `export markdown <id>` | Export as markdown |
| `export pdf <id>` | Export as PDF |
| `export html <id>` | Export as HTML |
| `export slide <id>` | Export as reveal.js slides |
### Revision Operations
| Command | Description |
|---------|-------------|
| `revision list <id>` | List note revisions |
| `revision get <id> <time>` | Get note at specific time |
### Configuration
| Command | Description |
|---------|-------------|
| `config get [key]` | Get configuration value |
| `config set <key> <value>` | Set configuration value |
## JSON Output Mode
All commands support `--json` flag for machine-readable output:
```bash
cli-anything-codimd --json note list
```
Response format:
```json
{
"status": "success|error",
"data": {...},
"error": "error message if status is error"
}
```
## Session Management
The CLI stores session data in `~/.config/cli-anything-codimd/`:
- `session.json`: Auth tokens and session data
- `config.json`: Server configuration
## Development
```bash
# Install in development mode
pip install -e .
# Run tests
pytest cli_anything/codimd/tests/ -v
# Run with specific command
python -m cli_anything.codimd.codimd_cli --help
```
## License
MIT License