GithubHelp home page GithubHelp logo

jy8752 / note-cli Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 0.0 365 KB

note-cli is CLI tool to manage article. ex) note(Article Submission Service), Blog

License: MIT License

Go 100.00%
cli cobra go golang headless-browsers rod template

note-cli's Introduction

Note CLI tool!!

GitHub release (latest by date) GitHub all releases Go Report Card Codecov

English | 日本語

note-cli

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.

What's note-cli

  • 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.

Install

Go install

go install github.com/JY8752/note-cli@latest

Homebrew

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.

Getting started

  1. Create and move to a directory to manage articles.
mkdir note-cli-demo
cd note-cli-demo
  1. 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.

  1. 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

  1. 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

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.

config.yaml

title: article title
author: your name
Field Type Description
title string Article Title
author string Article Author

<directory name>.md

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

--time(-t)

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

--name(-n)

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

--author(-a)

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"
---

--no-dir

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.

create image

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

--icon(-i)

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 

--output(-o)

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 

--template

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

use custom template file

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.

note-cli's People

Contributors

aqyuki avatar jy8752 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

note-cli's Issues

failed test when run on windows

description

When I running go test ./..., I got panic

This is probably due to the fact that directory delimiters are represented by \ ɑ in Windows environments, whereas they are represented by / in Mac and Linux environments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.