-
Notifications
You must be signed in to change notification settings - Fork 0
/
blag.fish
executable file
·48 lines (44 loc) · 1.72 KB
/
blag.fish
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
#!/usr/bin/fish
# https://interrupt.memfault.com/blog/building-a-cli-for-firmware-projects
function blag
set scriptdir (dirname (status --current-filename))
# test for argument count and bail if none provided
if test (count $argv) -eq 0
echo "error: insufficient arguments" 1>&2
blag help
return 1
end
switch $argv[1]
case help
echo
echo "usage:"
echo " help: display help/usage"
echo " index: open local index.html in firefox"
echo " live: open production fouric.github.io in firefox"
echo " jay: open jay's gitlab site in firefox"
echo " repo: open the github repo location in firefox"
echo " compose <title>: start composing a post with the given title"
echo ""
echo "to re-generate the pages, load :blag and then run (blag:generate)"
case index
firefox $scriptdir/index.html
case live
firefox "https://fouric.github.io/"
case jay
firefox "https://gitlab.com/jaynky/last-lambda"
case repo
firefox "https://github.com/fouric/fouric.github.io"
case compose
if test (count $argv) -eq 1
echo "error: need title" 1>&2
return 1
end
cp $scriptdir/post-content-template $scriptdir/post-contents/(date +%Y-%m-%d)-$argv[2]
sed -i (echo -s 's/EPOCH/' (date +%s) '/') $scriptdir/post-contents/(date +%Y-%m-%d)-$argv[2]
e $scriptdir/post-contents/(date +%Y-%m-%d)-$argv[2]
case '*'
echo "error: unrecognized option: " $argv[1] 1>&2
blag help
end
end
blag $argv