/pup

A command-line tool that automatically uploads images from the markdown document to the GitHub repo and replaces the paths with the returned URL.

Primary LanguageRustGNU General Public License v2.0GPL-2.0

Pup

BUILD

A command-line tool that automatically uploads images from the markdown document to the GitHub repo and replaces the paths with the returned URL.

Table of contents

TO DO

  • Use system password management to store TOKEN
  • Multithreading file manipulation
  • Relative image path support
  • Async I/O

Supported platforms

Theoretically, all UNIX platforms should be supported. But only tested on Linux with Gnome Desktop.

Usage and Demo

$ pup --help
A command-line tool that automatically uploads images from the markdown document to the GitHub repo and replaces the paths with the returned URL


Usage: pup [OPTIONS] [FILEPATH]

Arguments:
  [FILEPATH]  The target markdown or image file

Options:
      --set-token     Set the token
      --update-token  Update the token
      --delete-token  Delete the token
  -h, --help          Print help
  -V, --version       Print version

demo

Getting started

  1. Go to token-settings to generate a new token, make sure it has access to your picture repo.

  2. get the pup binary

    $ cargo install --git https://github.com/SteveLauC/pup
  3. Double check you have pup installed

    $ which pup
    /home/$USER/.cargo/bin/pup
  4. init config file

    $ pup
    name is unset.
    repo is unset.
    mail is unset.
  5. On your first run, pup will create a configuration file and complain about the incompleteness of it to you. If you have $XDG_CONFIG_HOME validly set, then it is located in $XDG_CONFIG_HOME/pup; Otherwise, it is under $HOME/.config/pup

  6. Then edit it to make it complete.

    # vim $XDG_CONFIG_HOME/pup/config.toml if you have $XDG_CONFIG_HOME set
    $ vim $HOME/.config/pup/config.toml

    Make it something like the following one, remeber to replace each field with your own one.

    github_user_name = "SteveLauC"
    github_repo_name = "test-repo"
    mail = "stevelauc@outlook.com"
    
  7. Let's try it again!

    $ pup
    No TOKEN available.
    Use `pup --set-token` to set it

    Ohhhh, since we haven't entered a token yet, pup asks us to do this.

  8. Set the token: enter the token and press enter to confirm.

    $ pup --set-token
    Please input the new TOKEN:  
  9. All configuration is done! Time to enjoy:)

    $ pup your-markdown-file.md
    
    # or 
    
    $ pup image.jpeg/jpg/png/gif

What pup can NOT do

  1. Puting multi images in a single line is not supported.
  2. The causes of failure may be confusing. For example, you may upload a photo that has already been uploaded, perhaps you are expecting something like [FAILED]: DuplicateFile, but pup will tell you [FAILED]: ValidationFaile.

Uninstallation

If you have set TOKEN in pup, use pup --delete-token to delete it first.

Then:

$ cargo uninstall pup

How it works

workflow