-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimg
More file actions
executable file
·44 lines (42 loc) · 899 Bytes
/
img
File metadata and controls
executable file
·44 lines (42 loc) · 899 Bytes
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
#!/bin/execlineb -W
# `cdon` wrapper to upload and edit images
#
# usage:
# (account) mdon img \
# -f(file) [-d(description)] | -i(id) -d(description)
elgetopt d:i:f:
ifelse { s6-test ! -v ELGETOPT_f -a ! -v ELGETOPT_i }
{
foreground { error mdon: img: fatal: must supply image }
exit 100
}
ifelse { s6-test -v ELGETOPT_f -a -v ELGETOPT_i }
{
foreground { error mdon: img: fatal: supplying image by file and ID }
exit 100
}
ifelse { s6-test -v ELGETOPT_i -a ! -v ELGETOPT_d }
{
foreground { error mdon: img: fatal: supplied image ID without new description }
exit 100
}
importas -uD "" description ELGETOPT_d
elgetpositionals
emptyenv -P
ifelse { s6-test -v ELGETOPT_f }
{
importas -iu file ELGETOPT_f
cdon
-umedia
--
-XPOST
-Ffile=@${file}
-Fdescription=${description}
${@}
}
importas -iu id ELGETOPT_i
cdon
-umedia/${id}
--
-XPUT
-ddescription=${description}