MetaManager is a CLI tool for managing your files metadata. It supports both local filesystem and Google Drive, allowing you to track, tag, search, and organize your files across different contexts.
- Context Management: Create and switch between multiple named environments (local, Google Drive, work, etc.)
- File Tracking: Track local directories or Google Drive folders
- Tagging System: Add and manage tags for files and directories
- ID Management: Assign unique IDs to nodes for quick access
- Search Capabilities: Find files and directories using regex patterns
- Google Drive Integration: Browse and manage Google Drive files directly from the CLI
- Metadata Storage: Persistent storage of file metadata and directory structures
- Go 1.23.0 or later
- Google Cloud Credentials (for Google Drive features) -
credentials.jsonfile
git clone <repository-url>
cd MetaManagergo mod downloadIf you want to use Google Drive features:
-
Create OAuth 2.0 Client ID in Google Cloud Console:
- Go to Google Cloud Console
- Navigate to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Desktop app" as the application type
- Download the
credentials.jsonfile
-
Place the
credentials.jsonfile in the project root directory -
The credentials will be embedded into the binary during build
Note: The credentials.json file contains a public OAuth client ID (not a secret). This is the standard way to configure OAuth for desktop applications and is safe to include in your repository. It's not a credential leak - Google designed these credentials to be public for desktop apps. The actual authentication happens through user login via MetaManager login.
go build -o MetaManagerOr install it:
go install# Create a local context
./MetaManager context create local --type local --root /path/to/your/directory
# Or create a Google Drive context (requires login first)
./MetaManager login
./MetaManager context create gdrive --type gdrive --root "Drive Folder Name"# Set the current context
./MetaManager context set local
# Track a directory
./MetaManager track /path/to/directory
# List files in current directory
./MetaManager ls
# Search for files
./MetaManager search searchNode "pattern"
# Add tags to a file
./MetaManager tag add /path/to/file tag1 tag2
# Assign an ID to a file
./MetaManager id set /path/to/file my-unique-id
# Jump to a file by ID
./MetaManager id jump my-unique-id# Login to Google Drive
./MetaManager login
# List Google Drive files
./MetaManager gdrive list
# Navigate Google Drive
./MetaManager gdrive cd "Folder Name"
./MetaManager gdrive ls
./MetaManager gdrive pwdComplete command documentation is available in the docs/ directory. All documentation is auto-generated from the CLI commands using Cobra.
- MetaManager.md - Main command overview and all available commands
- context.md - Context management commands
- track.md - File tracking commands
- tag.md - Tagging commands
- id.md - ID management commands
- gdrive.md - Google Drive commands
- search.md - Search commands
You can view any command's documentation using:
# View help for any command
./MetaManager <command> --help
# Or read the markdown files directly
cat docs/MetaManager_<command>.mdTo regenerate the documentation files:
cd docs
go run gen_doc.goThis will update all markdown files in the docs/ directory based on the current command structure.
MetaManager/
├── cmd/ # CLI command implementations
├── docs/ # Auto-generated command documentation
├── internal/ # Internal packages
│ ├── data/ # Data management
│ ├── ds/ # Data structures
│ ├── file/ # File operations
│ ├── repository/ # Storage repositories
│ └── services/ # Service layer
├── main.go # Application entry point
├── go.mod # Go module definition
└── README.md # This file
go test ./...# Build for current platform
go build -o MetaManager
# Build for specific platform
GOOS=linux GOARCH=amd64 go build -o MetaManager-linuxThis project uses mockery to generate mocks for testing. The mock configuration is defined in .mockery.yaml.
# Install mockery
go install github.com/vektra/mockery/v2@latest
# Or using Homebrew (macOS)
brew install mockeryTo generate all mocks defined in .mockery.yaml:
mockeryThis will generate mock files in the internal/mocks/ directory based on the configuration.
To add mocks for new interfaces:
- Edit
.mockery.yamland add the interface under the appropriate package - Run
mockeryto generate the mocks - The generated mocks will be placed in the directory specified in the config
Example configuration entry:
github.com/heroku/self/MetaManager/internal/yourpackage:
config:
dir: "internal/mocks/yourpackage"
filename: "mock_{{.InterfaceName}}.go"
structname: "Mock{{.InterfaceName}}"
interfaces:
YourInterface:The generated mocks use the testify mock framework. Example usage:
import (
"testing"
"github.com/heroku/self/MetaManager/internal/mocks/filesys"
)
func TestSomething(t *testing.T) {
mockScanner := filesys.NewMockScanner(t)
mockScanner.EXPECT().Scan("/path").Return(&ds.TreeNode{}, nil)
// Use mockScanner in your test
}Enable debug logging for troubleshooting:
./MetaManager --debug <command>| Command | Description |
|---|---|
context create |
Create a new context |
context set |
Set the current context |
context list |
List all contexts |
track <path> |
Start tracking a directory |
untrack <path> |
Stop tracking a directory |
tag add <path> <tags...> |
Add tags to a file/directory |
tag list |
List all tags |
id set <path> <id> |
Assign an ID to a node |
id get <path> |
Get the ID of a node |
id jump <id> |
Print path for a given ID |
search searchNode <pattern> |
Search for files/directories |
gdrive list |
List Google Drive files |
login |
Authenticate with Google |
If you encounter authentication issues:
- Ensure
credentials.jsonis in the project root - Run
./MetaManager loginto re-authenticate - Check that the token file has proper permissions
If you get "context not found" errors:
- List contexts:
./MetaManager context list - Create a context if needed:
./MetaManager context create <name> --type <local|gdrive> --root <path> - Set the context:
./MetaManager context set <name>
For detailed error messages, use debug mode:
./MetaManager --debug <command>- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Copyright © 2023
For issues and questions, please open an issue in the repository.