### Create Note with Editor (Example) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Demonstrates launching the default editor for note creation. ```bash $ hackmd-cli notes create --editor # Launches vim/nano/editor ``` -------------------------------- ### Configuration File Example (JSON) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/configuration.md Example of a JSON configuration file used to store API access token and endpoint URL. ```json { "accessToken": "MY_ACCESS_TOKEN", "hackmdAPIEndpointURL": "https://api.hackmd.io/v1" } ``` -------------------------------- ### List All Personal Notes Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Execute this command to display a table of all your personal notes. No specific setup is required beyond having the CLI installed. ```bash $ hackmd-cli notes ``` -------------------------------- ### Pipeline Usage Example (Bash) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/utilities-reference.md Demonstrates how to pipe content from a file to a command-line tool that utilizes safe standard input reading. ```bash $ cat README.md | hackmd-cli notes create # Content comes from stdin via safeStdinRead() ``` -------------------------------- ### List All Personal Folders (CLI) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md Use this command to display a table of all your personal folders. No specific setup is required beyond having the CLI installed and authenticated. ```bash $ hackmd-cli folders ``` -------------------------------- ### CLI Commands Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/README.md Documentation for all 26 available CLI commands, including their signatures, parameters, behavior, and examples. ```APIDOC ## CLI Commands ### Description This section details all 26 available CLI commands. Each command's documentation includes its full signature, parameters, return types, behavior, error handling, and usage examples. *(Note: Specific command details are extensive and would typically be listed individually here. Refer to the full documentation for each command.)* ``` -------------------------------- ### Example Usage of folderName Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to use the `--name` flag (aliased from `folderName`) to create a new folder with a specified name. ```bash $ hackmd-cli folders create --name="My Folder" ``` -------------------------------- ### Example ApiFolderOrder Usage Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/types.md An example demonstrating how to use the ApiFolderOrder type to specify the arrangement of folders and subfolders. ```typescript const order: ApiFolderOrder = { root: ['folder-1', 'folder-2'], 'folder-1': ['subfolder-a', 'subfolder-b'] } ``` -------------------------------- ### Example Usage of Note Permission Flags Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates setting both read and write permissions to 'owner' when creating a HackMD note. ```bash $ hackmd-cli notes create --readPermission=owner --writePermission=owner ``` -------------------------------- ### Example Usage of folderDescription Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Illustrates using the `--description` flag (aliased from `folderDescription`) to set a description for a newly created folder. ```bash $ hackmd-cli folders create --description="Project documentation" ``` -------------------------------- ### Example Usage of teamPath Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates how to use the --teamPath flag with the 'team-notes create' command to specify the target team. ```bash $ hackmd-cli team-notes create --teamPath=engineering ``` -------------------------------- ### Install and Use HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/README.md Install the HackMD CLI globally using npm and perform a basic login and note creation. Ensure Node.js is installed and meets the version requirement. ```bash npm install -g @hackmd/hackmd-cli hackmd-cli login hackmd-cli notes create --title="My Note" --content="# Hello" ``` -------------------------------- ### Example Usage of folderColor Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to apply a specific color to a folder using the `--color` flag (aliased from `folderColor`). ```bash $ hackmd-cli folders create --color=#4F46E5 ``` -------------------------------- ### Example Usage of EditorOptions Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/types.md Shows how to create an `EditorOptions` object to specify a custom editor, like 'nano', and pass it to the `openEditor` function. ```typescript const opts: EditorOptions = { editor: 'nano' } await openEditor('/tmp/file.md', opts) ``` -------------------------------- ### Example Usage of folderId Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates how to use the `--folderId` flag to delete a specific folder. ```bash $ hackmd-cli folders delete --folderId=91722050-bf47-4334-9e5d-87125a724c29 ``` -------------------------------- ### Example Usage of folderIcon Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates setting a folder icon using the `--icon` flag (aliased from `folderIcon`) with a Unicode codepoint. ```bash $ hackmd-cli folders create --icon=1F600 ``` -------------------------------- ### Example Usage of editor Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to use the --editor flag or its short form '-e' with the 'notes create' command to initiate note creation via the default editor. ```bash $ hackmd-cli notes create --editor # or $ hackmd-cli notes create -e ``` -------------------------------- ### Example Usage of getAPIClient Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-base-command.md Illustrates how to use the getAPIClient method to obtain an authenticated API client and fetch user information. ```typescript import HackMDCommand from './command' export default class MyCommand extends HackMDCommand { async run() { const apiClient = await this.getAPIClient() const user = await apiClient.getMe() this.log(`Logged in as: ${user.name}`) } } ``` -------------------------------- ### Get Help for a Specific HackMD CLI Command Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md To understand the options and usage for a particular command, append --help to the command. For example, to get help for creating notes, use 'hackmd-cli notes create --help'. ```bash hackmd-cli {command} --help # Example: hackmd-cli notes create --help ``` -------------------------------- ### Example Usage of folderOrder Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates how to reorder folders using the `--order` flag (aliased from `folderOrder`) with a JSON string defining the root and its children. ```bash $ hackmd-cli folders order --order='{"root":["folder-1","folder-2"]}' ``` -------------------------------- ### Example Usage of Note ID Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Demonstrates how to use the --noteId flag to specify a note for deletion. ```bash $ hackmd-cli notes delete --noteId=raUuSTetT5uQbqQfLnz9lA ``` -------------------------------- ### Update Note Permissions Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md This example shows how to change the read and write permissions for a note. Provide the `--noteId` and specify the desired `--readPermission` and `--writePermission`. ```bash $ hackmd-cli notes update \ --noteId=WNkLM6gkS0Cg2cQ8rv7bYA \ --readPermission=owner \ --writePermission=owner ``` -------------------------------- ### Create Team Note with Title and Tags Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md This example demonstrates creating a team note with a specific title and assigning comma-separated tags for organization. ```bash $ hackmd-cli team-notes create \ --teamPath=CLI-test \ --title="Team Docs" \ --content="# Documentation" \ --tags="documentation,team" ``` -------------------------------- ### Example Usage of parentFolderId Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Illustrates creating a new note within a specific parent folder using the `--parentFolderId` flag. ```bash $ hackmd-cli notes create --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c ``` -------------------------------- ### Example Usage of Note Content Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Illustrates using the --content flag to provide Markdown content when creating a HackMD note. ```bash $ hackmd-cli notes create --content="# Hello World" ``` -------------------------------- ### Example Usage of Note Title Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to use the --title flag to set a title when creating a new HackMD note. ```bash $ hackmd-cli notes create --title="My Note" ``` -------------------------------- ### Example Usage of Permalink Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to update a HackMD note's permalink using the --permalink flag along with the --noteId. ```bash $ hackmd-cli notes update --noteId=xyz --permalink="my-custom-slug" ``` -------------------------------- ### Get HackMD CLI Help Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md Display help information for the HackMD CLI, including available commands and usage patterns. ```sh-session $ hackmd-cli --help [COMMAND] USAGE $ hackmd-cli COMMAND ... ``` -------------------------------- ### Example Usage of Note Tags Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Illustrates assigning multiple tags to a HackMD note using the --tags flag with a comma-separated string. ```bash $ hackmd-cli notes create --tags="documentation,api,v1" ``` -------------------------------- ### Get HackMD CLI Version Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md Display the installed version of the HackMD CLI and the Node.js environment it is running in. ```sh-session $ hackmd-cli (--version|-v) @hackmd/hackmd-cli/2.5.0 darwin-arm64 node-v26.0.0 ``` -------------------------------- ### HackMD CLI Configuration File Example Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/INDEX.md This JSON structure represents the configuration file for the HackMD CLI. It requires an access token and optionally accepts the API endpoint URL. ```json { "accessToken": "YOUR_TOKEN", "hackmdAPIEndpointURL": "https://api.hackmd.io/v1" } ``` -------------------------------- ### Create a Personal Folder with Full Properties Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new personal folder with a name, description, icon, and color. ```bash hackmd-cli folders create \ --name="Docs" \ --description="Project documentation" \ --icon=1F4DA \ --color=#4F46E5 ``` -------------------------------- ### Create Personal Folder with Metadata Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Create a new personal folder and include metadata such as description, icon, and color. ```bash hackmd-cli folders create --name='Docs' --description='Project docs' --icon=1F600 --color='#4F46E5' ``` -------------------------------- ### Install HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md Install the HackMD CLI globally using npm. This command is used to access the hackmd-cli tool. ```sh-session $ npm install -g @hackmd/hackmd-cli $ hackmd-cli COMMAND ``` -------------------------------- ### Create a Folder and Add a Note Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Creates a new folder and then adds a note within that newly created folder. ```bash hackmd-cli folders create --name='Docs' hackmd-cli notes create --parentFolderId= --title='My Note' ``` -------------------------------- ### Install HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Install the HackMD CLI globally using npm. Ensure Node.js version is 24.0.0 or higher. ```bash npm install -g @hackmd/hackmd-cli ``` -------------------------------- ### CLI Flags and Parameters Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/README.md Documentation for reusable CLI flags, parameters, permission values, and input methods. ```APIDOC ## CLI Flags & Parameters ### Description Details on the 15+ reusable CLI flags, their associated parameters, accepted permission values with examples, and the different input methods supported (flags, stdin, editor). *(Note: Specific flag and parameter details are extensive and would typically be listed individually here. Refer to the full documentation for each flag.)* ``` -------------------------------- ### Create Team Folder with Full Properties Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-folders.md Use this command to create a team folder and specify all optional properties like parent folder ID, description, icon, and color. ```bash $ hackmd-cli team-folders create \ --teamPath=engineering \ --name="team-docs" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --description="Docs" \ --icon=1F600 \ --color=#4F46E5 ``` -------------------------------- ### Create Team Folder with Metadata Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Create a new team folder with metadata such as description, icon, and color, specifying the team path. ```bash hackmd-cli team-folders create --teamPath= --name='Team Docs' --description='Project docs' --icon=1F600 --color='#4F46E5' ``` -------------------------------- ### Get Specific Personal Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Fetch the details of a specific personal folder using its folder ID. ```bash hackmd-cli folders --folderId= ``` -------------------------------- ### Create a Personal Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new personal folder with a specified name. ```bash hackmd-cli folders create --name="My Folder" ``` -------------------------------- ### Get Specific Personal Note Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Fetch the details of a specific personal note using its unique note ID. ```bash hackmd-cli notes --noteId= ``` -------------------------------- ### Example Usage of Comment Permission Flag Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/flags-reference.md Shows how to disable comments on a HackMD note using the --commentPermission flag. ```bash $ hackmd-cli notes create --commentPermission=disabled ``` -------------------------------- ### Create Note with Interactive Editor Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Use the --editor flag to launch your default text editor (or specified via $EDITOR/$VISUAL) to create the note content. ```bash $ hackmd-cli notes create --editor # Opens $EDITOR or $VISUAL or vim (default) ``` -------------------------------- ### Get API Client Method Signature Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-base-command.md Defines the signature for the getAPIClient method, which returns a Promise resolving to an API client instance. ```typescript async getAPIClient(): Promise ``` -------------------------------- ### Create Simple Team Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-folders.md Use this command to create a basic team folder with only the required team path and folder name. ```bash $ hackmd-cli team-folders create \ --teamPath=engineering \ --name="docs" ``` -------------------------------- ### Create Notes from Template File Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new note using the content of a template file. The content is piped into the create command. ```bash cat template.md | hackmd-cli notes create --title="From Template" ``` -------------------------------- ### Create Note with Title and Content Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Use command-line flags to specify the title and Markdown content for a new note. ```bash $ hackmd-cli notes create --title="My Note" --content="# Hello" ``` -------------------------------- ### Handle Config File Write Error Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/errors.md Demonstrates how to handle errors when writing the configuration file, including checking permissions, manual configuration, and using environment variables. ```bash # Check permissions ls -la ~/.hackmd/ # Try manual configuration echo '{"accessToken":"YOUR_TOKEN"}' > ~/.hackmd/config.json # Or use environment variable instead export HMD_API_ACCESS_TOKEN=YOUR_TOKEN ``` -------------------------------- ### Create a Personal Note Using an Editor Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new personal note and open your default editor to compose the content. This is useful for longer notes. ```bash hackmd-cli notes create --editor ``` -------------------------------- ### Organize Team Documents in Team Folders Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Creates a team folder and a new note within that team folder. ```bash hackmd-cli team-folders create --teamPath= --name='Team Docs' hackmd-cli team-notes create --teamPath= --parentFolderId= --content='# Team Note' ``` -------------------------------- ### Create Personal Note with Editor Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Initiate the creation of a new personal note using your default editor. ```bash hackmd-cli notes create -e ``` -------------------------------- ### Manage Personal Folder Order Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Get the current order of personal folders or update their order by providing a JSON object specifying the root order. ```bash hackmd-cli folders order ``` ```bash hackmd-cli folders order --order='{"root":["folder-id-1","folder-id-2"]}' ``` -------------------------------- ### Create Team Note with Content and Permissions Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Use this command to create a new team note with specified content and read/write permissions for owners. ```bash $ hackmd-cli team-notes create \ --teamPath=CLI-test \ --content='# A new note' \ --readPermission=owner \ --writePermission=owner ``` -------------------------------- ### Order Team Folders Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-folders.md Gets or updates the order of team folders within a team. Supports both retrieving the current order and setting a new order. ```APIDOC ## hackmd-cli team-folders order ### Description Gets or updates the order of team folders. ### Command ``` hackmd-cli team-folders order --teamPath= [--order=] ``` ### Parameters #### Flags - `--teamPath` (string) - Required - Team path identifier - `--order` (string) - Optional - Team folder order JSON object - `--help` / `-h` (boolean) - Show help ### Behavior **Get folder order (no `--order` flag):** Retrieves and displays the current team folder ordering as JSON. **Set folder order (`--order` provided):** Updates the team folder order according to the provided JSON object. ### Order Format Folder order is a JSON object where: - Keys: Folder IDs (use `"root"` for root level) - Values: Arrays of child folder IDs in desired order **Example:** ```json { "root": ["folder-id-1", "folder-id-2"], "folder-id-1": ["subfolder-id-a", "subfolder-id-b"] } ``` ### Examples **Get current team folder order:** ```bash $ hackmd-cli team-folders order --teamPath=CLI-test { "root": [ "91722050-bf47-4334-9e5d-87125a724c29", "fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c" ] } ``` **Set team folder order:** ```bash $ hackmd-cli team-folders order \ --teamPath=CLI-test \ --order='{"root":["91722050-bf47-4334-9e5d-87125a724c29","fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c"]}' Team folder order updated ``` ### Error Handling - Missing teamPath: `Flag teamPath could not be empty` - Invalid JSON: JSON parsing error - Non-object JSON: `Folder order must be a JSON object` - Non-array values: `Folder order entry "{key}" must be an array of folder ids` - API error: `Update team folder order failed` ### Validation The order JSON must satisfy: 1. Top-level must be an object (not array or primitive) 2. All values must be arrays 3. All array elements must be strings (folder IDs) ``` -------------------------------- ### Get Specific Folder by ID (CLI) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md Retrieve details for a specific folder by providing its unique ID. This is useful for accessing information about a single folder. ```bash $ hackmd-cli folders --folderId=91722050-bf47-4334-9e5d-87125a724c29 ``` -------------------------------- ### folders create Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md Creates a new personal folder with specified properties. ```APIDOC ## folders create ### Description Creates a new personal folder. ### Command ```bash hackmd-cli folders create --name= [OPTIONS] ``` ### Parameters #### Flags - `--name` (string) - Required - Folder name - `--parentFolderId` (string) - Optional - UUID of parent folder - `--description` (string) - Optional - Folder description - `--icon` (string) - Optional - Emoji or icon code (e.g., 1F600) - `--color` (string) - Optional - Folder color (hex code, e.g., #4F46E5) - `--help` / `-h` (boolean) - Optional - Show help ### Output Table with created folder details: - `id` (string) - Folder unique identifier - `name` (string) - Folder name - `parentFolderId` (string) - Parent folder UUID - `color` (string) - Folder color - `description` (string) - Folder description - `icon` (string) - Folder icon ### Examples **Create simple folder:** ```bash $ hackmd-cli folders create --name="My Docs" ``` **Create folder with full properties:** ```bash hackmd-cli folders create \ --name="docs" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --description="Docs" \ --icon=1F600 \ --color=#4F46E5 ``` ### Error Handling - Missing name: `Flag name could not be empty` - API error: `Create folder failed` ``` -------------------------------- ### Get Specific Note by ID Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Retrieve a single note by providing its unique HackMD note ID. Ensure you have the correct note ID before executing. ```bash $ hackmd-cli notes --noteId=raUuSTetT5uQbqQfLnz9lA ``` -------------------------------- ### Create a Personal Note with Title and Content Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new personal note with a specified title and content. The content is provided as a string. ```bash hackmd-cli notes create --title="My Note" --content="# Hello World" ``` -------------------------------- ### Create Team Note using Command-line Flags Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Basic command to create a team note using the `--teamPath` and `--content` flags. ```bash $ hackmd-cli team-notes create --teamPath=CLI-test --content="# Team Note" ``` -------------------------------- ### Get or Update HackMD Team Folder Order Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md This command allows you to retrieve or modify the order of folders within a team. The order is specified as a JSON object. ```bash hackmd-cli team-folders order --teamPath=CLI-test ``` ```bash hackmd-cli team-folders order --teamPath=CLI-test --order='{"root":["91722050-bf47-4334-9e5d-87125a724c29","fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c"]}' ``` -------------------------------- ### Get Team Folder Order Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-folders.md Retrieves and displays the current ordering of team folders within a specified team. No `--order` flag is needed for this operation. ```bash hackmd-cli team-folders order --teamPath=CLI-test ``` -------------------------------- ### Create Note with Tags Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Add comma-separated tags to a new note using the --tags flag. ```bash $ hackmd-cli notes create \ --title="API Docs" \ --content="# API Reference" \ --tags="documentation,api,v1" ``` -------------------------------- ### Create Note with Specific Permissions Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new note with granular control over read, write, and comment permissions. Permissions can be set to 'owner', 'signed_in', or 'disabled'. ```bash hackmd-cli notes create \ --title="Private Note" \ --content="# Private" \ --readPermission=owner \ --writePermission=owner \ --commentPermission=disabled ``` -------------------------------- ### Output Notes in JSON Format using HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Specify --output=json to get your notes in JSON format. This is ideal for programmatic processing of your HackMD data. ```bash hackmd-cli notes --output=json ``` -------------------------------- ### Dependency Tree - Utility Functions Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/module-graph.md Shows the utility functions used across different command modules, such as configuration management, authentication helpers, input/output utilities, and folder order parsing. These utilities are imported from various files within the project. ```plaintext Utility Functions ├── config.ts │ └── getConfigFilePath() ├── login.ts │ └── setAccessTokenConfig() ├── logout.ts │ └── setAccessTokenConfig() ├── notes/create.ts, team-notes/create.ts │ ├── safeStdinRead() │ ├── temporaryMD() │ └── openEditor() └── folders/order.ts, team-folders/order.ts └── parseFolderOrder() ``` -------------------------------- ### Get Specific Team Note Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Retrieve a specific team note by providing both the `--teamPath` and the `--noteId`. This is useful for accessing a particular note's details. ```bash $ hackmd-cli team-notes --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA ``` -------------------------------- ### Check Command Flag Syntax Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/errors.md Ensure you are using the correct syntax for command-line flags. Use the --help option for any command to view its available flags and their proper usage. ```bash hackmd-cli {command} --help ``` -------------------------------- ### Create Personal Note from File or Stdin Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Create a new personal note using content piped from a file or standard input. ```bash cat README.md | hackmd-cli notes create ``` -------------------------------- ### Manage Team Folder Order Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Get the current order of team folders or update their order by providing a JSON object specifying the root order for a given team path. ```bash hackmd-cli team-folders order --teamPath= ``` ```bash hackmd-cli team-folders order --teamPath= --order='{"root":["folder-id-1","folder-id-2"]}' ``` -------------------------------- ### Get Folder Order using HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md Retrieves and displays the current order of personal folders as a JSON object. Use this command when no `--order` flag is provided. ```bash $ hackmd-cli folders order { "root": [ "91722050-bf47-4334-9e5d-87125a724c29", "fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c" ] } ``` -------------------------------- ### Handle Editor Launch Failure Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/errors.md Provides methods for handling editor launch failures, such as specifying the editor explicitly, setting environment variables, or using the --content flag. ```bash # Specify editor explicitly hackmd-cli notes create --editor EDITOR=nano # Or set environment variables export EDITOR=nano hackmd-cli notes create --editor # Or use flag instead of editor hackmd-cli notes create --content="# Note" ``` -------------------------------- ### Get Specific Team Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-folders.md Retrieve details for a particular team folder by providing both the team path and the specific folder ID. The `--folderId` flag is used for this purpose. ```bash $ hackmd-cli team-folders --teamPath=engineering --folderId=91722050-bf47-4334-9e5d-87125a724c29 ``` -------------------------------- ### HackMD CLI Authentication Commands Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Manage your HackMD CLI authentication. Use 'login' for interactive setup, 'logout' to clear credentials, and 'whoami' to view current user information. ```bash hackmd-cli login ``` ```bash hackmd-cli logout ``` ```bash hackmd-cli whoami ``` -------------------------------- ### Create a Team Note Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new note within a specific team by providing the team path, title, and content. ```bash hackmd-cli team-notes create \ --teamPath=my-team \ --title="Team Doc" \ --content="# Team Information" ``` -------------------------------- ### Get HackMD CLI Configuration File Path Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/utilities-reference.md Retrieves the absolute path to the HackMD CLI configuration file. It creates the necessary directories and the config file if they do not exist, prioritizing the HMD_CLI_CONFIG_DIR environment variable. ```typescript import {getConfigFilePath} from './utils' const configPath = getConfigFilePath() console.log(configPath) // /home/user/.hackmd/config.json ``` -------------------------------- ### Create Note with Title, Content, and Folder Parent Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Specify a parent folder ID and set read/write permissions to 'owner' when creating a note. ```bash $ hackmd-cli notes create \ --title="Setup Docs" \ --content="## Installation" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --readPermission=owner \ --writePermission=owner ``` -------------------------------- ### Get HackMD CLI Version Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md Displays the current version of the HackMD CLI. Use the --verbose flag to show additional system and plugin information. The --json flag formats the output as JSON. ```bash hackmd-cli version ``` -------------------------------- ### Automate Note Export and Backup Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md This script iterates through all notes, exports them individually, and saves them to a 'backups' directory. It uses CSV output to get note IDs and redirects output to a file named after the note ID. ```bash mkdir -p backups for note_id in $(hackmd-cli notes --csv | tail -n +2 | cut -d, -f1); do hackmd-cli export --noteId=$note_id > backups/$note_id.md done ``` -------------------------------- ### Update All Folder Properties with HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md This example demonstrates updating all properties of a folder, including name, parent folder, description, icon, and color. Provide the folder ID and the new values for each property you wish to change. ```bash $ hackmd-cli folders update \ --folderId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d \ --name="docs" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --description="Docs" \ --icon=1F600 \ --color=#4F46E5 ``` -------------------------------- ### Create Team Note via Pipeline (stdin) Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Utilize Unix pipeline to pipe content from a file (e.g., README.md) directly into a new team note. ```bash $ cat README.md | hackmd-cli team-notes create --teamPath=CLI-test ``` -------------------------------- ### Get or Update HackMD Folder Order Source: https://github.com/hackmdio/hackmd-cli/blob/develop/README.md This command allows you to retrieve the current order of folders or update it by providing a JSON string specifying the new order. The order is defined by folder IDs within a root array. ```bash hackmd-cli folders order ``` ```bash hackmd-cli folders order --order='{"root":["91722050-bf47-4334-9e5d-87125a724c29","fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c"]}' ``` -------------------------------- ### Test Single Note Creation Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Before performing batch operations, test the create command with a single note to ensure it functions as expected. This prevents unintended consequences with multiple notes. ```bash # Test single operation first hackmd-cli notes create --title="Test" --content="Test" ``` -------------------------------- ### List All Team Notes Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Use this command to list all notes within a specified team workspace. Ensure the `--teamPath` flag is provided. ```bash $ hackmd-cli team-notes --teamPath=CLI-test ``` -------------------------------- ### Create Team Note using Interactive Editor Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-team-notes.md Initiate the creation of a team note using an interactive editor by including the `--editor` flag. ```bash $ hackmd-cli team-notes create --teamPath=CLI-test --editor ``` -------------------------------- ### List Personal Folders Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Retrieve a list of all your personal folders. ```bash hackmd-cli folders ``` -------------------------------- ### Create a Nested Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Creates a parent folder and then a child folder within the parent. ```bash hackmd-cli folders create --name='Parent' hackmd-cli folders create --name='Child' --parentFolderId= ``` -------------------------------- ### notes create Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Creates a new personal note with optional content and permissions. This command can be used via command-line flags, Unix pipeline (stdin), or an interactive editor. ```APIDOC ## notes create Creates a new personal note with optional content and permissions. ### Command ``` hackmd-cli notes create [OPTIONS] ``` ### Flags | Flag | Type | Required | Default | Description | |------|------|----------|---------|-------------| | `--title` | string | No | undefined | Note title | | `--content` | string | No | undefined | Note content (Markdown) | | `--parentFolderId` | string | No | undefined | UUID of parent folder | | `--readPermission` | string | No | undefined | Read permission: owner, signed_in, guest | | `--writePermission` | string | No | undefined | Write permission: owner, signed_in, guest | | `--commentPermission` | string | No | undefined | Comment permission: disabled, forbidden, owners, signed_in_users, everyone | | `--tags` | string | No | undefined | Comma-separated tags (e.g., tag1,tag2) | | `--editor` / `-e` | boolean | No | false | Create note with $EDITOR | | `--help` / `-h` | boolean | - | - | Show help | ### Input Methods **Command-line flags:** ```bash $ hackmd-cli notes create --title="My Note" --content="# Hello" ``` **Unix pipeline (stdin):** ```bash $ cat README.md | hackmd-cli notes create ``` **Interactive editor:** ```bash $ hackmd-cli notes create --editor # Opens $EDITOR or $VISUAL or vim (default) ``` ### Output Table with created note details: | Column | Description | |--------|-------------| | `id` | Note unique identifier | | `title` | Note title | | `userPath` | Owner's user path | | `teamPath` | Associated team path | | `tags` | Comma-separated tags | ### Permission Values **Read/Write Permission:** - `owner`: Only note owner can read/write - `signed_in`: All signed-in users can read/write - `guest`: Anyone with link can read/write **Comment Permission:** - `disabled`: Comments are disabled - `forbidden`: Comments forbidden (legacy) - `owners`: Only note owners can comment - `signed_in_users`: All signed-in users can comment - `everyone`: Anyone can comment ### Examples **Create note with title and content:** ```bash $ hackmd-cli notes create --title="Project Plan" --content="# 2024 Plan" ``` **Create note with folder parent:** ```bash $ hackmd-cli notes create \ --title="Setup Docs" \ --content="## Installation" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --readPermission=owner \ --writePermission=owner ``` **Create note with tags:** ```bash $ hackmd-cli notes create \ --title="API Docs" \ --content="# API Reference" \ --tags="documentation,api,v1" ``` **Create note with editor:** ```bash $ hackmd-cli notes create --editor # Launches vim/nano/editor ``` **Create note from file:** ```bash $ cat architecture.md | hackmd-cli notes create --title="Architecture" ``` ### Error Handling | Condition | Error Message | |-----------|---------------| | API error | `Create note failed` | | Editor launch fails | Editor error details | ### Type Imports ```typescript import type { CommentPermissionType, CreateNoteOptions, NotePermissionRole, } from '@hackmd/api' ``` ``` -------------------------------- ### Create Note from File with Title Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-notes.md Use a Unix pipeline to send file content to the CLI and specify a title for the new note. ```bash $ cat architecture.md | hackmd-cli notes create --title="Architecture" ``` -------------------------------- ### Manage Team Notes Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/README.md Create a new note within a specific team. Replace 'my-team' with the actual team path. ```bash # Team operations hackmd-cli team-notes create --teamPath=my-team --title="Team Doc" ``` -------------------------------- ### Create Personal Note in Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Create a new personal note and place it directly inside a specified folder using its parent folder ID. ```bash hackmd-cli notes create --parentFolderId= --content='# Title' ``` -------------------------------- ### Create a Personal Note from a File Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/quick-start.md Create a new personal note by piping the content of a Markdown file into the 'create' command. The title is derived from the filename. ```bash cat document.md | hackmd-cli notes create --title="Document" ``` -------------------------------- ### Create Personal Folder Source: https://github.com/hackmdio/hackmd-cli/blob/develop/hackmd-cli/SKILL.md Create a new personal folder with a specified name. It can also be created as a nested folder within another folder. ```bash hackmd-cli folders create --name='Docs' ``` ```bash hackmd-cli folders create --name='Docs' --parentFolderId= ``` -------------------------------- ### Create Folder with Full Properties using HackMD CLI Source: https://github.com/hackmdio/hackmd-cli/blob/develop/_autodocs/api-reference-folders.md This command demonstrates creating a folder with all optional properties, including parent folder ID, description, icon, and color. The `parentFolderId` must be a valid UUID. ```bash $ hackmd-cli folders create \ --name="docs" \ --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c \ --description="Docs" \ --icon=1F600 \ --color=#4F46E5 ```