Giter Site home page Giter Site logo

stevelauc / pup Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 1.0 13.12 MB

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

License: GNU General Public License v2.0

Rust 100.00%
cli command-line-tool markdown pic-uploader

pup's Introduction

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 = "[email protected]"
    
  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

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.