Skip to content

CLI to store logs of your life/work using the terminal storing locally or syncing with a GitHub gist

Notifications You must be signed in to change notification settings

djalmaaraujo/lg

Repository files navigation

Life Logger CLI (lg)

A simple command-line tool for logging daily life events with cloud synchronization, interactive dashboard, and offline support.

Features

  • πŸ“ Simple Logging: Quickly log your daily activities with a simple command
  • πŸ”„ Cloud Sync: Synchronize your logs across devices using GitHub Gists
  • πŸ“Š Interactive Dashboard: Visualize and manage your logs with a rich terminal UI
  • πŸ”Œ Offline Support: Work seamlessly without internet connection
  • πŸ” Powerful Search: Find entries by date, content, or tags
  • πŸ› οΈ Extensible: Easy to add new features and commands

Installation

From Source

# Clone the repository
git clone https://github.com/yourusername/lg.git
cd lg

# Install dependencies
npm install

# Build the project
npm run build

# Link the CLI globally
npm link

For Development

If you're developing the CLI, you can use the included update script to quickly rebuild and relink the tool:

# After making changes to the code
./update-cli.sh

This script will:

  1. Build the project with TypeScript
  2. Unlink any existing global installation
  3. Link the updated package globally

Usage

Getting Started

# Initialize the CLI and follow the setup prompts
lg setup

# When asked, enable GitHub Gist sync for cloud storage
# You'll need a GitHub Personal Access Token with 'gist' scope

Daily Logging

# Interactive Mode (Recommended)
lg  # Directly prompts for a log entry

# Log an entry directly
lg "Had a great day today!"
lg log "Learned something new"

Managing Entries

# List all entries (uses local storage by default)
lg list

# Force a full sync with GitHub Gist before listing entries
lg list --sync

# Remove entries
lg remove

Advanced Features

# View interactive dashboard
lg dash

# Enable debug logging
lg debug --enable

# Check sync status
lg list --sync

Multi-Device Workflow

# On your first device
lg setup  # Enable GitHub Gist sync during setup

# On additional devices
lg setup  # Use the same GitHub token
lg list --sync  # Pull all existing entries from the cloud

Commands

Core Commands

  • setup: Initialize the CLI and configure GitHub Gist sync
  • log or add: Log a life entry
  • list or ls: List all logged entries
  • remove or rm: Remove log entries

Advanced Features

  • dashboard or dash: Display interactive dashboard
  • debug or dbg: Enable or disable debug logging

Interactive Mode

The CLI features an interactive mode that makes logging entries easier, especially when dealing with special characters:

$ lg
? Enter your log entry: Meeting with Tom at 9am (might be late) #work

This interactive mode automatically handles special characters without requiring quotes or escaping.

Dashboard

The CLI includes a rich interactive dashboard for visualizing and managing your log entries:

$ lg dash

Dashboard Features

  • Calendar View: Shows days with entries highlighted
  • Recent Entries: Lists your most recent log entries
  • Tag Statistics: Shows most frequently used tags
  • Entry Statistics: Displays metrics about your logging habits
  • Quick Entry Form: Add new entries directly from the dashboard

Dashboard Navigation

  • Use arrow keys to navigate between panels
  • Press 'e' to focus on entries panel
  • Press 'i' to focus on input panel
  • Press ENTER when in input panel to start editing
  • Press ESC to exit editing mode
  • Press Ctrl+S to save a new entry
  • Press q to quit the dashboard

GitHub Gist Synchronization

Setting Up Gist Sync

  1. You'll need a GitHub Personal Access Token with the "gist" scope
  2. Create one at: https://github.com/settings/tokens
  3. When prompted during setup, choose "yes" to set up GitHub Gist synchronization
  4. Paste your GitHub Personal Access Token when prompted

How Sync Works

  • Every time you add or remove entries, they are automatically synced with your GitHub Gist in the background
  • Sync happens without blocking your commands - you can continue using the CLI even without internet
  • If you use Life Logger on multiple devices with the same GitHub account, your entries will be synchronized
  • When setting up a new device, if the Gist already contains entries, they will be imported automatically

Offline Support

Life Logger works seamlessly offline:

  • All operations work locally without requiring an internet connection
  • When you're offline, changes are stored locally
  • When internet becomes available, background sync will automatically update the remote storage
  • Use lg list --sync to force a full sync with remote storage when you're back online

Benefits of Gist Sync

  • Backup: Your entries are safely stored in your GitHub account
  • Multi-device: Access and update your logs from any device
  • Private: Gists are created as private by default
  • Seamless: Sync happens automatically in the background
  • Offline-first: Works without internet, syncs when connection is available

Debug Logging

The debug command allows you to control the verbosity of the CLI's logging:

# Show current debug status
lg debug

# Enable debug logging
lg debug --enable

# Disable debug logging
lg debug --disable

# Show current debug status
lg debug --status

When debug logging is enabled, you'll see detailed information about operations like GitHub Gist synchronization, file operations, and more. This can be helpful for troubleshooting issues or understanding how the CLI works internally.

Handling Special Characters

When logging entries directly (non-interactive mode) with special characters like #, !, &, (), etc., you must use quotes:

lg "Meeting with Tom at 9am (might be late) #work"

This is because shell interpreters like bash and zsh process special characters before passing arguments to the CLI.

For the easiest experience with special characters, use the interactive mode by simply typing lg without arguments.

Development

Project Structure

lg/
β”œβ”€β”€ src/                    # Source code
β”‚   β”œβ”€β”€ index.ts            # Entry point
β”‚   β”œβ”€β”€ commands/           # Command implementations
β”‚   β”‚   β”œβ”€β”€ index.ts        # Commands registry
β”‚   β”‚   └── [command].ts    # Individual command files
β”‚   β”œβ”€β”€ utils/              # Utility functions
β”‚   β”‚   β”œβ”€β”€ logger.ts       # Logging utilities
β”‚   β”‚   β”œβ”€β”€ gistSync.ts     # GitHub Gist synchronization
β”‚   β”‚   └── ...
β”‚   └── types/              # TypeScript type definitions
β”œβ”€β”€ dist/                   # Compiled JavaScript (generated)
β”œβ”€β”€ update-cli.sh           # Development utility script
β”œβ”€β”€ package.json            # Project metadata and dependencies
└── README.md               # Project documentation

Adding a New Command

  1. Create a new file in src/commands/ (e.g., mycommand.ts)
  2. Implement the Command interface
  3. Register the command in src/commands/index.ts
  4. Run ./update-cli.sh to build and link the updated CLI

Deployment

To package the CLI for distribution:

# Build the project
npm run build

# Create a tarball
npm pack

# The resulting .tgz file can be installed globally with:
npm install -g lg-0.1.0.tgz

For publishing to npm:

# Build the project
npm run build

# Publish to npm (requires npm account)
npm publish

License

MIT

About

CLI to store logs of your life/work using the terminal storing locally or syncing with a GitHub gist

Resources

Stars

Watchers

Forks

Releases

No releases published