-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-readme
executable file
·115 lines (75 loc) · 2.87 KB
/
generate-readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /bin/sh
exit_no_default() {
echo "Please, set the valid default site name in sites.json" >&2
exit 1
}
JOIN_FUNC="def join(str): reduce .[1:][] as \$item (.[0]|tostring; . + str + (\$item|tostring))"
DEFAULT="$(jq -r "${JOIN_FUNC}; .default|if type==\"array\" then join(\", \") else . end" sites.json)"
SITES_TEXT="$(jq -r "$(cat sites_to_help_text.jq)" sites.json | sed 's/^/ /')"
echo "${SITES_TEXT}" | grep -q ' (default)' || exit_no_default
cat <<EOF_
========
pomfload
========
.. image:: https://travis-ci.org/hcpl/pomfload.svg
:target: https://travis-ci.org/hcpl/pomfload
.. code-block::
Usage: pomfload [-u|-f|-p] [-t|-S SUFFIX] [-s SITE]... FILE...
Options:
-h Show this help message and exit
-s SITE Specify the site name to upload, can be used
multiple times to upload to multiple sites
(default sites: ${DEFAULT})
-S SUFFIX Upload as files with the specified SUFFIX
-t Upload as text files (equivalent to -S txt)
-u Output URL
-f Output filename only
-p Output the same way as the server responses
-v Increase verbosity, can be specified multiple times
-q Decrease verbosity, can be specified multiple times
Supported sites:
EOF_
echo "${SITES_TEXT}"
cat <<'EOF_'
Requirements
------------
* POSIX-compatible shell
* Packages wth essential Unix tools, such as |coreutils|_, |sed| or
their alternatives.
* |curl|_
* |jq|_ (``pomfload`` is compatible with jq 1.3 and above)
.. |coreutils| replace:: ``coreutils``
.. _coreutils: https://gnu.org/s/coreutils
.. |sed| replace:: ``sed``
.. |curl| replace:: ``curl``
.. _curl: https://curl.haxx.se/
.. |jq| replace:: ``jq``
.. _jq: https://stedolan.github.io/jq/
Installation
------------
``pomfload`` is a standalone script, so downloading a single file is
enough for usage:
.. code-block:: sh
# Short link
curl -o pomfload git.io/vX7Wd
# Exact location (these two links point to the same file)
curl -O https://raw.githubusercontent.com/hcpl/pomfload/master/pomfload
After that give the script execute permissions and place it somewhere
in your ``$PATH``.
Customization
-------------
If you want to have your set of available sites, clone the whole repo,
add or remove sites in ``sites.json`` and then execute:
.. code-block::
./generate-script > pomfload
That's all! *(at least, it should be that easy)*
How to Contribute
-----------------
Notes for ``sites.json``:
* Give some reasonable aliases (often one alias is sufficient).
* And make sure it can actually download (of course :) ).
Patches, suggestions and comments are welcome!
Credits
-------
* `Shizmob <https://github.com/Shizmob>`_'s `original pomfload <https://gist.github.com/Shizmob/7984374>`_
EOF_