Compare commits
4 Commits
v2020.10.2
...
master
Author | SHA1 | Date |
---|---|---|
James Tomasino | 41be140abb | |
James Tomasino | 053ebb142b | |
James Tomasino | c5d06b17f9 | |
James Tomasino | a6cea6f11a |
21
README.md
21
README.md
|
@ -1,4 +1,4 @@
|
|||
pb ![calver](https://img.shields.io/badge/calver-2020.10.27-22bfda.svg?style=flat-square) [![Build Status](https://drone.tildegit.org/api/badges/tomasino/pb/status.svg)](https://drone.tildegit.org/tomasino/pb) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square)
|
||||
pb ![calver](https://img.shields.io/badge/calver-2022.11.03-22bfda.svg?style=flat-square) [![Build Status](https://drone.tildegit.org/api/badges/tomasino/pb/status.svg)](https://drone.tildegit.org/tomasino/pb) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square)
|
||||
------
|
||||
|
||||
**pb** is a helper utility for using 0x0 pastebin services
|
||||
|
@ -33,12 +33,6 @@ Upload a file to a different pastebin endpoint
|
|||
pb -s http://0x0.st scores.txt
|
||||
```
|
||||
|
||||
Shorten a URL
|
||||
|
||||
```bash
|
||||
pb -u https://google.com
|
||||
```
|
||||
|
||||
Re-upload an image from the web
|
||||
|
||||
```bash
|
||||
|
@ -48,13 +42,12 @@ curl -s https://tildegit.org/_/static/img/gitea-lg.png | pb -e "png"
|
|||
### Options
|
||||
|
||||
```bash
|
||||
-h Show this help
|
||||
-v Show current version number
|
||||
-f Explicitly interpret stdin as filename
|
||||
-c Pretty color output
|
||||
-u Shorten URL
|
||||
-s server_address Use alternative pastebin server address
|
||||
-e bin_extension Specify a binary file extension used in the upload
|
||||
-h | --help) Show this help
|
||||
-v | --version) Show current version number
|
||||
-f | --file) Explicitly interpret stdin as filename
|
||||
-c | --color) Pretty color output
|
||||
-s | --server server_address) Use alternative pastebin server address
|
||||
-e | --extension bin_extension) Specify file extension used in the upload
|
||||
```
|
||||
|
||||
### Install
|
||||
|
|
89
pb
89
pb
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
# init variables
|
||||
version="v2020.10.27"
|
||||
ENDPOINT="https://ttm.sh"
|
||||
flag_options=":hvcufe:s::"
|
||||
version="v2023.12.04"
|
||||
ENDPOINT="https://envs.sh"
|
||||
flag_options=":hvcfe:s:"
|
||||
long_flag_options="help,version,color,file,extension:,server:"
|
||||
flag_version=0
|
||||
flag_help=0
|
||||
flag_file=0
|
||||
flag_url=0
|
||||
flag_colors=0
|
||||
flag_ext=0
|
||||
data=""
|
||||
|
@ -23,13 +23,12 @@ or
|
|||
Uploads a file or data to the tilde 0x0 paste bin
|
||||
|
||||
OPTIONAL FLAGS:
|
||||
-h Show this help
|
||||
-v Show current version number
|
||||
-f Explicitly interpret stdin as filename
|
||||
-c Pretty color output
|
||||
-u Shorten URL
|
||||
-s server_address Use alternative pastebin server address
|
||||
-e bin_extension Specify a binary file extension used in the upload
|
||||
-h | --help) Show this help
|
||||
-v | --version) Show current version number
|
||||
-f | --file) Explicitly interpret stdin as filename
|
||||
-c | --color) Pretty color output
|
||||
-s | --server server_address) Use alternative pastebin server address
|
||||
-e | --extension bin_extension) Specify file extension used in the upload
|
||||
END
|
||||
}
|
||||
|
||||
|
@ -59,49 +58,27 @@ die () {
|
|||
}
|
||||
|
||||
# attempt to parse options or die
|
||||
if ! parsed=$(getopt ${flag_options} "$@"); then
|
||||
if ! PARSED_ARGUMENTS=$(getopt -a -n pb -o ${flag_options} --long ${long_flag_options} -- "$@"); then
|
||||
printf "pb: unknown option\\n"
|
||||
show_usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# handle options
|
||||
eval set -- "${parsed}"
|
||||
while true; do
|
||||
# For debugging: echo "PARSED_ARGUMENTS is $PARSED_ARGUMENTS"
|
||||
eval set -- "$PARSED_ARGUMENTS"
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
-h|?)
|
||||
flag_help=1
|
||||
;;
|
||||
-v)
|
||||
flag_version=1
|
||||
;;
|
||||
-c)
|
||||
flag_colors=1
|
||||
;;
|
||||
-f)
|
||||
flag_file=1
|
||||
;;
|
||||
-e)
|
||||
shift
|
||||
flag_ext=1
|
||||
EXT="$1"
|
||||
;;
|
||||
-s)
|
||||
shift
|
||||
ENDPOINT="$1"
|
||||
;;
|
||||
-u)
|
||||
flag_url=1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
die "Internal error: $1" 3
|
||||
;;
|
||||
-h | --help) flag_help=1 ; shift ;;
|
||||
-v | --version) flag_version=1 ; shift ;;
|
||||
-c | --color) flag_color=1 ; shift ;;
|
||||
-f | --file) flag_file=1 ; shift ;;
|
||||
-e | --extension) flag_ext=1; EXT="$2" ; shift 2 ;;
|
||||
-s | --server) ENDPOINT="$2" ; shift 2 ;;
|
||||
--) shift; break ;;
|
||||
*) echo "Unexpected option: $1 - this should not happen."
|
||||
show_usage ; die 3 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# display current version
|
||||
|
@ -145,24 +122,6 @@ else
|
|||
RESET=""
|
||||
fi
|
||||
|
||||
# URL shortening reference
|
||||
|
||||
# If URL mode detected, process URL shortener and end processing without
|
||||
# checking for a file to upload to the pastebin
|
||||
if [ ${flag_url} -gt 0 ]; then
|
||||
|
||||
if [ -z "${data}" ]; then
|
||||
# if no data
|
||||
# print error message
|
||||
printf "%sProvide URL to shorten%s\\n" "$ERROR" "$RESET"
|
||||
else
|
||||
# shorten URL and print results
|
||||
result=$(curl -sF"shorten=${data}" "${ENDPOINT}")
|
||||
printf "%s%s%s\\n" "$SUCCESS" "$result" "$RESET"
|
||||
fi
|
||||
die "" 0
|
||||
fi
|
||||
|
||||
if [ ${flag_file} -gt 0 ]; then
|
||||
# file mode
|
||||
if [ -z "${data}" ]; then
|
||||
|
|
16
pb.1
16
pb.1
|
@ -1,11 +1,11 @@
|
|||
.TH PB 1 "27 October 2020" "v2020.10.27"
|
||||
.TH PB 1 "04 December 2023" "v2023.12.04"
|
||||
|
||||
.SH NAME
|
||||
pb \- a helper utility for using 0x0 pastebin services
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B pb
|
||||
[-fucvh] [-s server_endpoint]
|
||||
[-fucvh] [-s server_endpoint] [-e bin_extension]
|
||||
.P
|
||||
|
||||
.SH DESRIPTION
|
||||
|
@ -16,8 +16,8 @@ comes pre-configured with a specific pastebin, the
|
|||
service endpoint can be overridden.
|
||||
|
||||
Data input can be provided as an argument or via stdin.
|
||||
The data will be processed as an image, text or URL to
|
||||
be shortened based on the context.
|
||||
The data will be processed as binary or text
|
||||
based on the context.
|
||||
|
||||
The options are as follows:
|
||||
|
||||
|
@ -32,11 +32,6 @@ Use alternative pastebin server address.
|
|||
Specifes the file extension used in the upload of binary content passed to
|
||||
.B pb
|
||||
via standard input.
|
||||
.I Note:
|
||||
this attribute will not work with file uploads or URL shortening.
|
||||
.TP
|
||||
.B -u
|
||||
Shorten a URL.
|
||||
.TP
|
||||
.B -c
|
||||
Pretty color output.
|
||||
|
@ -69,9 +64,6 @@ Upload a list of files to the pastebin individually
|
|||
.B pb -s http://0x0.st scores.txt
|
||||
Upload a file to a different pastebin endpoint
|
||||
.TP
|
||||
.B pb -u 'https://tilde.team'
|
||||
Shorten the URL to tilde.team
|
||||
.TP
|
||||
.B curl -s https://some/image/file.png | pb -e "png"
|
||||
Download a binary file and re-upload it to the pastebin with an explicit binary
|
||||
type and extension.
|
||||
|
|
Loading…
Reference in New Issue