https://github.com/stevelauc/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.
https://github.com/stevelauc/pup
cli command-line-tool markdown pic-uploader
Last synced: 10 months ago
JSON representation
A command-line tool that automatically uploads images from the markdown document to the GitHub repo and replaces the paths with the returned URL.
- Host: GitHub
- URL: https://github.com/stevelauc/pup
- Owner: SteveLauC
- License: gpl-2.0
- Created: 2022-04-12T09:16:02.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-13T12:47:39.000Z (over 1 year ago)
- Last Synced: 2025-04-04T04:13:04.584Z (about 1 year ago)
- Topics: cli, command-line-tool, markdown, pic-uploader
- Language: Rust
- Homepage:
- Size: 12.8 MB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Pup
[](https://github.com/stevelauc/pup/actions/workflows/ci.yml)
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](https://github.com/SteveLauC/pup#to-do)
* [Supported platforms](https://github.com/SteveLauC/pup#supported-platforms)
* [Usage and Demo](https://github.com/SteveLauC/pup#demo-video)
* [Getting Started](https://github.com/SteveLauC/pup#getting-started)
* [What pup can NOT do](https://github.com/SteveLauC/pup#what-pup-can-not-do)
* [Uninstallation](https://github.com/SteveLauC/pup#uninstallation)
* [How it works](https://github.com/SteveLauC/pup#how-it-works)
# TO DO
- [x] Use system password management to store TOKEN
- [x] Multithreading file manipulation
- [x] 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
```shell
$ 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
```

# Getting started
1. Go to [token-settings](https://github.com/settings/tokens) to generate a new
token, make sure it has access to your picture repo.
2. get the `pup` binary
```shell
$ cargo install --git https://github.com/SteveLauC/pup
```
3. Double check you have pup installed
```shell
$ which pup
/home/$USER/.cargo/bin/pup
```
4. init config file
```shell
$ 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.
```shell
# 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!
```shell
$ 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.
```shell
$ pup --set-token
Please input the new TOKEN:
```
8. All configuration is done! Time to enjoy:)
```shell
$ 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:
```shell
$ cargo uninstall pup
```
# How it works
