/chrome-cli

Primary LanguageJavaScript

Chrome CLI

Chrome CLI is a command-line interface tool to manage Google Chrome bookmarks across different profiles. The tools is intended for my personal use. Currently the tool facilitates exporting bookmarks in various formats such as JSON, CSV, Markdown, and more. More actions may be implemented at a later date.

Prerequisites

Before you begin, ensure you have Node.js installed on your computer. You can download and install Node.js from Node.js official website.

Installation

To set up the Chrome CLI tool on your local machine, follow these steps:

  1. Clone the repository:
    git clone https://github.com/cliffpyles/chrome-cli.git
  2. Navigate to the project directory:
    cd chrome-cli
  3. Install the dependencies:
    npm install
  4. Link the package globally to use the chrome command anywhere on your system:
    npm link

Usage

After installation, you can use the chrome command followed by specific subcommands and options to interact with your Chrome bookmarks.

Commands

List Bookmarks

  • Description: Lists all Chrome bookmarks from all profiles in the specified format.
  • Command:
    chrome bookmarks list [options]
  • Options:
    • -f, --format <type>: Specify the output format. Supported formats are json, csv, text, raw, and markdown. The default format is json.

Examples

  • List bookmarks in JSON format:
    chrome bookmarks list --format json
  • List bookmarks in CSV format:
    chrome bookmarks list --format csv
  • Display raw bookmark data:
    chrome bookmarks list --format raw

Bookmark Data Format

The Chrome CLI tool exports bookmarks in several formats such as JSON, CSV, Markdown, text, and raw. Each format presents the bookmark data with specific semantics to accommodate different usage contexts. This section details the semantics of the bookmark data.

Fields in Bookmark Object

Each bookmark object contains these key fields:

  • name: Title of the bookmark.
  • url: URL of the bookmark.
  • date_added: Date and time the bookmark was added, in ISO 8601 format.
  • guid: A unique identifier for the bookmark.
  • type: Type of the item (url for bookmarks, folder for directories).
  • folder_name: Name of the immediate folder containing the bookmark.
  • folder_path: Full path from the root to the bookmark's folder.
  • profile_name: Name of the associated Chrome profile.
  • profile_email: Email associated with the profile.

Example of Nested Bookmark Structure

Consider a nested bookmark structure like this:

  • Resources
    • Articles
      • Technology: Bookmark to a tech article.
    • Docs
      • Meeting Notes: Bookmark to online notes.

Here’s how a sample of the bookmarks might look in JSON format:

[
  {
    "name": "Technology",
    "url": "https://example.com/tech-article",
    "date_added": "2023-05-20T15:30:00Z",
    "guid": "1234",
    "folder_name": "Technology",
    "folder_path": "Resources/Articles/Technology",
    "profile_name": "User",
    "profile_email": "user@example.com"
  },
  {
    "name": "Meeting Notes",
    "url": "https://example.com/meeting-notes",
    "date_added": "2023-05-20T12:00:00Z",
    "guid": "5678",
    "folder_name": "Docs",
    "folder_path": "Resources/Docs",
    "profile_name": "User",
    "profile_email": "user@example.com"
  }
]

Troubleshooting

If you encounter any issues with the CLI, first ensure that you are running the latest version of Node.js and that all dependencies are correctly installed. Check the console output for any error messages that could provide more insight into what might be going wrong.

Contributing

Since this project is intended for personal use, contributions are not actively sought. However, suggestions and improvements are welcome and can be discussed through GitHub issues.

License

This project is provided as-is, without any warranty. Use at your own risk.