Note CLI tool!!
English | 日本語
note-cli is a CLI tool to create and manage articles on note, an article submission site, in your local environment instead of on the service. note-cli was created with the following motivation
- I want to write in my preferred editor, not the one opened in my web browser. (For example, VSCode)
- I want to manage the version of articles written in markdown format on GitHub, etc.
- It is troublesome to prepare article images. (I don't want to use the free images provided by NOTE.)
note-cli should be able to be used as a non-note article management tool. For example, you can use it to manage articles on your own blog. If there are any missing features or improvements, please feel free to let us know via Pull Request or issue.
- Create an article directory containing markdown files with the command so that articles can be written immediately.
- Create images for uploading to articles with the command.
go install github.com/JY8752/note-cli@latest
brew install JY8752/tap/note-cli
% note-cli -h
note-cli is a CLI command tool for creating, writing, and managing note articles
Usage:
note-cli [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
create Create a new article directory.
help Help about any command
Flags:
-h, --help help for note-cli
-t, --toggle Help message for toggle
Use "note-cli [command] --help" for more information about a command.
- Create and move to a directory to manage articles.
mkdir note-cli-demo
cd note-cli-demo
- Create article directory.
% note-cli create article .
Create directory. a6b420c6-9bb2-4060-869c-20c171fc9827
Create file. a6b420c6-9bb2-4060-869c-20c171fc9827.md
.
└── a6b420c6-9bb2-4060-869c-20c171fc9827
└── a6b420c6-9bb2-4060-869c-20c171fc9827.md
a6b420c6-9bb2-4060-869c-20c171fc9827.md
Article file. The file name is the same as the directory name, this time using a random value (UUID).config.yaml
Config file. This file is used to set the title of the article, the name of the author, etc.
title: article title
author: your name
config.yaml is obsolete. Configuration information such as article title and author name has been changed to be included as metadata in the article markdown file.
- Create article image.
The following command will generate output.png
.
% note-cli create image ./a6b420c6-9bb2-4060-869c-20c171fc9827.md
Complete generate OGP image
Icons can also be placed on the image by providing an icon image. You can also choose a different type of template image.
% note-cli create image ./a6b420c6-9bb2-4060-869c-20c171fc9827.md -i ./icon.png --template 2
- Summary
-
The
note-cli create article
command allows you to create article files and directories for posting. Once you have created an article in the created markdown file, copy and paste it and submit it from the web. -
The image required to post an article can be created by command in the style of an OGP image. You can choose other types of this template image or prepare your own custom template.
-
In this way, the article and image files needed to post a note article can be created from the command, and version control can be done at GitHub or elsewhere.
create article
command creates a directory with a unique random value (UUID). The following files will also be created and placed in the directory.The argument is the location where the directory or file was created.
<directory name>.md
Article file.The content of the article you wish to submit will be written in this file.config.yaml
This file contains settings related to the generation of articles and image files.
title: article title
author: your name
Field | Type | Description |
---|---|---|
title | string | Article Title |
author | string | Article Author |
The markdown file will have the following metadata The title
and author
fields are used for image output.
---
title: ""
tags: []
date: "2023-09-29"
author: ""
---
Field | Type | Description |
---|---|---|
title | string | Article Title |
tags | []string | tags |
date | string | File created day |
author | string | Article Author |
This flag allows directories and files to be created with the current time instead of the default UUID. The current time depends on the time zone of the operating system under which the command is executed and is generated in the format YYYY-mm-dd
.
% note-cli create article . -t
Create directory. 2023-09-08
Create file. 2023-09-08.md
If the directory already exists, it creates the directory by incrementing number in the form YYYY-mm-dd-{number}
.
% note-cli create article . -t
Create directory. 2023-09-08-2
Create file. 2023-09-08-2.md
This flag allows you to create a directory with an arbitrary name. If the directory already exists with the specified name, the command will fail.
% note-cli create article . -n article-A
Create directory. article-A
Create file. article-A.md
This flag allows the name of the article author to be passed in advance.
% go run main.go create article . -a Yamanaka.J
Create directory. cc4ab85a-2aa7-48a6-8472-3b36ef4778fa
Create file. cc4ab85a-2aa7-48a6-8472-3b36ef4778fa/cc4ab85a-2aa7-48a6-8472-3b36ef4778fa.md
% cat cc4ab85a-2aa7-48a6-8472-3b36ef4778fa/cc4ab85a-2aa7-48a6-8472-3b36ef4778fa.md
---
title: ""
tags: []
date: "2023-09-29"
author: "Yamanaka.J"
---
Using this flag creates file without creating directory.
% note-cli create article . --no-dir -t
Create file. 2023-09-30.md
% cat 2023-09-30.md
---
title: ""
tags: []
date: "2023-09-30"
author: ""
---
note-cli uses a directory structure to facilitate managing images generated from articles along with the articles. However, if you do not need this directory structure, you can use the no-dir
flag to manage only files. For example, if you are writing a personal blog in markdown, you may use it to manage your articles.
Image like OGP can be generated by executing the create image
command.The config.yaml must exist in the current directory to generate images.If config.yaml does not exist, the command will fail.
config.yaml is obsolete. Instead, the metadata for the markdown file must be present. If the metadata cannot be read, config.yaml in the current directory is searched for compatibility, and if it is still missing, the command will fail.
To generate images, specify the path to the markdown file containing the metadata as the command argument.
% note-cli create image ./article.md
Complete generate OGP image
You can include an icon in an image by specifying the path of the icon image after this flag.
% note-cli create image ./article.md -i ./icon.png
By default, images are output to the current directory under the file name output.png
. If you wish to change the output destination, you can do so by specifying the path after this flag.
% note-cli create image ./article.md -o ./ogp.png
The generation of images is output in several template HTML files, including the necessary information. You can change the template file to be used by specifying template number
after this flag. For more information about template files here. (By default, template file number 1 is used.)
% note-cli create image ./article.md --template 2
You can also use your own custom template files by placing a file named template.tmpl
in the current directory. The format of the template file is existing file.
The template file uses template/html
package of Go. The following variables can be used in the template file.
variable | description |
---|---|
{{.Title}} | Article title. This value is set in the config.yaml. |
{{.IconPath}} | Icon image. If specified in the command, the value is the base64 encoded icon image. |
{{.Author}} | Author name. This value is set in the config.yaml. |
If you have created a custom template file, please send us a Pull Request so we can add it to the built-in template file. For instructions on how to create a Pull Request, please see here for instructions on how to create a Pull Request.