Skip to content

Latest commit

 

History

History
122 lines (83 loc) · 4.28 KB

README.md

File metadata and controls

122 lines (83 loc) · 4.28 KB

devto -- publish to dev.to from your terminal

CI Release GitHub release (latest by date) Coverage Status Go Report Card GitHub

What is this?

devto is a CLI tool that helps submit articles to DEV from the terminal. It makes use of the APIs that DEV kindly provides in OpenAPI specification. devto mainly does two things:

  1. It collects all image links from the Markdown file into a devto.yml file with the generate subcommand. For example, if we have ./image-1.png and ./image-2.png in the Markdown file, we will get the following:

    images:
      ./image-1.png: ""
      ./image-2.png: ""
  2. It submits the article to DEV with the submit subcommand. The submit subcommand creates a new article in DEV and updates the devto.yml with the resulting article_id. devto will use this article_id in the following execution to perform an update operation instead of creating a new entry for the same article.

The DEV API does not have a way of uploading images yet. If we submit a Markdown content with relative paths of image links, DEV will not be able to show those images. As a workaround of this problem, we need to provide a full path for the images either manually via the devto.yml file or using the --prefix flag.

The Markdown file must contains at least the title property of the Jekyll front matter, like in:

---
title: An example title
description: ...
tags: ...
cover_image: ...
---

You can find more information about the usage via the --help flag.

devto --help

Installation

brew install shihanng/devto/devto

Debian, Ubuntu

curl -sLO https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.deb
dpkg -i devto_linux_amd64.deb

RedHat, CentOS

rpm -ivh https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.rpm

Binaries

The release page contains binaries built for various platforms. Download the version matches your environment (e.g. linux_amd64) and place the binary in the executable $PATH e.g. /usr/local/bin:

curl -sL https://github.com/shihanng/devto/releases/latest/download/devto_linux_amd64.tar.gz | \
    tar xz -C /usr/local/bin/ devto

For Gophers

With Go already installed in your system, use go get

go get github.com/shihanng/devto

or clone this repo and make install

git clone https://github.com/shihanng/devto.git
cd devto
make install

Configuration

Description CLI Flag Environment Variable config.yml
DEV API key is needed to talk with DEV API. --api-key DEVTO_API_KEY api-key

Sample config in YAML

api-key: abcd1234

Contributing

Want to add missing feature? Found bug 🐛? Pull requests and issues are welcome. For major changes, please open an issue first to discuss what you would like to change ❤️.

make lint
make test

should help with the idiomatic Go styles and unit-tests.

How to generate DEV's API client

make gen

See pkg/devto for client documentation.

License

MIT