Compare commits
2 Commits
1f15d53c32
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b356b557c2 | |||
| efcf39b890 |
@@ -28,10 +28,10 @@ cat <<EOF | $FVJ --add-task "Respond to referee report" "yesterday" --collection
|
||||
- [x] Report 1: Answer prepared
|
||||
- [ ] Report 2: Write response, revise manuscript
|
||||
EOF
|
||||
echo "Chinese" | $FVJ --add-task "Reserve dinner table" "next Sunday"
|
||||
echo "for 5 pax" | $FVJ --add-task "Reserve dinner table" "next Sunday"
|
||||
cat <<EOF | $FVJ --add-jour "Demo Coding"
|
||||
### Demo code
|
||||
Our demo now contains a script that self-generets the demo.
|
||||
Our demo now contains a script that generates this demo.
|
||||
It's located in \`./scripts/\`
|
||||
There are some upcoming steps:
|
||||
|
||||
|
||||
@@ -3,39 +3,43 @@
|
||||
# If `delta` is specified using `-v`, then the priority value is increased by
|
||||
# `delta.` If `delta` is unspecified (or equal to 0), then the completeness
|
||||
# status is toggled.
|
||||
|
||||
@include "lib/awk/icalendar.awk"
|
||||
|
||||
BEGIN {
|
||||
FS=":";
|
||||
zulu = strftime("%Y%m%dT%H%M%SZ", systime(), 1);
|
||||
delta = delta + 0; # cast as integer
|
||||
}
|
||||
{ gsub("\r", "") }
|
||||
/^END:VTODO/ && inside {
|
||||
# Print sequence and last-modified, if not yet printed
|
||||
if (!seq) print "SEQUENCE:1";
|
||||
if (!lm) print "LAST-MODIFIED:" zulu;
|
||||
if (!seq) print_cr("SEQUENCE:1");
|
||||
if (!lm) print_cr("LAST-MODIFIED:" zulu);
|
||||
|
||||
# Print priority
|
||||
prio = prio ? prio + delta : 0 + delta;
|
||||
prio = prio < 0 ? 0 : prio;
|
||||
prio = prio > 9 ? 9 : prio;
|
||||
print "PRIORITY:" prio;
|
||||
print_cr("PRIORITY:" prio);
|
||||
|
||||
# Print status (toggle if needed)
|
||||
bit_status = status == "COMPLETED" ? 1 : 0;
|
||||
bit_toggle = delta ? 0 : 1;
|
||||
percent = xor(bit_status, bit_toggle) ? 100 : 0;
|
||||
status = xor(bit_status, bit_toggle) ? "COMPLETED" : "NEEDS-ACTION";
|
||||
print "STATUS:" status
|
||||
print "PERCENT-COMPLETE:" percent
|
||||
print_cr("STATUS:" status)
|
||||
print_cr("PERCENT-COMPLETE:" percent)
|
||||
|
||||
# print rest
|
||||
inside = "";
|
||||
print $0;
|
||||
print_cr($0);
|
||||
next
|
||||
}
|
||||
/^BEGIN:VTODO/ { inside = 1; print; next }
|
||||
/^SEQUENCE/ && inside { seq = 1; print "SEQUENCE:" $2+1; next }
|
||||
/^LAST-MODIFIED/ && inside { lm = 1; print "LAST-MODIFIED:" zulu; next }
|
||||
/^BEGIN:VTODO/ { inside = 1; print_cr($0); next }
|
||||
/^SEQUENCE/ && inside { seq = 1; print_cr("SEQUENCE:" $2+1); next }
|
||||
/^LAST-MODIFIED/ && inside { lm = 1; print_cr("LAST-MODIFIED:" zulu); next }
|
||||
/^PRIORITY:/ && inside { prio = $2; next }
|
||||
/^STATUS/ && inside { status = $2; next }
|
||||
/^PERCENT-COMPLETE/ && inside { next } # ignore, we take STATUS:COMPLETED as reference
|
||||
{ print }
|
||||
{ print_cr($0) }
|
||||
|
||||
@@ -15,21 +15,21 @@ function write_attachment( line, aline, fl) {
|
||||
fl = 1
|
||||
while (getline aline <file) {
|
||||
line = line aline
|
||||
if (fl && length(line) >= 73) {
|
||||
print substr(line, 1, 73)
|
||||
line = substr(line, 74)
|
||||
if (fl && length(line) >= 72) {
|
||||
print substr(line, 1, 72)"\r"
|
||||
line = substr(line, 73)
|
||||
fl = 0
|
||||
}
|
||||
while (length(line) >= 72) {
|
||||
print " "substr(line, 1, 72)
|
||||
line = substr(line, 73)
|
||||
while (length(line) >= 71) {
|
||||
print " "substr(line, 1, 71)"\r"
|
||||
line = substr(line, 72)
|
||||
}
|
||||
}
|
||||
if (line)
|
||||
print " "line
|
||||
print " "line"\r"
|
||||
}
|
||||
|
||||
# AWK program
|
||||
|
||||
/^END:(VTODO|VJOURNAL)$/ { write_attachment() }
|
||||
/^END:(VTODO|VJOURNAL)/ { write_attachment() }
|
||||
{ print }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
BEGIN { FS="[:;]" }
|
||||
{ gsub("\r", "") }
|
||||
/^END:(VTODO|VJOURNAL)$/ { ins = 0; exit }
|
||||
/^[^ ]/ && a { a = 0 }
|
||||
/^ / && a && p { print substr($0, 2); }
|
||||
|
||||
@@ -34,6 +34,7 @@ function att_info(i, str, cnt, k, info) {
|
||||
}
|
||||
|
||||
BEGIN { FS="[:;]"; OFS="\t" }
|
||||
{ gsub("\r", "") }
|
||||
/^END:(VTODO|VJOURNAL)$/ { ins = 0; exit }
|
||||
l && !r { att_info(i, l); l = "" }
|
||||
/^ / && r { l = l substr($0, 2); r = cont_reading($0) }
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
## @assign id: Attachment number to remove
|
||||
|
||||
BEGIN { FS="[:;]" }
|
||||
/^END:(VTODO|VJOURNAL)$/ { ins = 0 }
|
||||
/^END:(VTODO|VJOURNAL)/ { ins = 0 }
|
||||
/^[^ ]/ && a { a = 0 }
|
||||
/^ / && a { next }
|
||||
/^ATTACH/ && ins { i++; }
|
||||
/^ATTACH/ && ins && i == id { a = 1; next }
|
||||
/^BEGIN:(VTODO|VJOURNAL)$/ { ins = 1 }
|
||||
/^BEGIN:(VTODO|VJOURNAL)/ { ins = 1 }
|
||||
{ print }
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# print content of field `field`
|
||||
BEGIN { FS = ":"; regex = "^" field; }
|
||||
BEGINFILE { type = ""; line = ""; }
|
||||
{ gsub("\r", "") }
|
||||
/^BEGIN:(VJOURNAL|VTODO)/ { type = $2 }
|
||||
/^END:/ && $2 == type { nextfile }
|
||||
$0 ~ regex { line = $0; next; }
|
||||
|
||||
@@ -81,6 +81,8 @@ BEGINFILE {
|
||||
delete c;
|
||||
}
|
||||
|
||||
{ gsub("\r", "") }
|
||||
|
||||
/^BEGIN:(VJOURNAL|VTODO)/ {
|
||||
type = $2
|
||||
}
|
||||
|
||||
@@ -37,33 +37,33 @@ END {
|
||||
}
|
||||
|
||||
# print ical
|
||||
print "BEGIN:VCALENDAR";
|
||||
print "VERSION:2.0";
|
||||
print "CALSCALE:GREGORIAN";
|
||||
print "PRODID:-//fzf-vjour//awk//EN";
|
||||
print "BEGIN:" type;
|
||||
print "DTSTAMP:" zulu;
|
||||
print "UID:" uid;
|
||||
print "CLASS:PRIVATE";
|
||||
print "CREATED:" zulu;
|
||||
print "SEQUENCE:1";
|
||||
print "LAST-MODIFIED:" zulu;
|
||||
print_cr("BEGIN:VCALENDAR")
|
||||
print_cr("VERSION:2.0")
|
||||
print_cr("CALSCALE:GREGORIAN")
|
||||
print_cr("PRODID:-//fzf-vjour//awk//EN")
|
||||
print_cr("BEGIN:" type)
|
||||
print_cr("DTSTAMP:" zulu)
|
||||
print_cr("UID:" uid)
|
||||
print_cr("CLASS:PRIVATE")
|
||||
print_cr("CREATED:" zulu)
|
||||
print_cr("SEQUENCE:1")
|
||||
print_cr("LAST-MODIFIED:" zulu)
|
||||
if (type == "VTODO")
|
||||
{
|
||||
print "STATUS:NEEDS-ACTION";
|
||||
print "PERCENT-COMPLETE:0";
|
||||
print_cr("STATUS:NEEDS-ACTION")
|
||||
print_cr("PERCENT-COMPLETE:0")
|
||||
if (due)
|
||||
print "DUE;VALUE=DATE:" due;
|
||||
print_cr("DUE;VALUE=DATE:" due)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "STATUS:FINAL";
|
||||
print_cr("STATUS:FINAL")
|
||||
if (start)
|
||||
print "DTSTART;VALUE=DATE:" start;
|
||||
print_cr("DTSTART;VALUE=DATE:" start)
|
||||
}
|
||||
if (summary) print_fold("SUMMARY:", summary);
|
||||
if (categories) print_fold("CATEGORIES:", categories);
|
||||
if (desc) print_fold("DESCRIPTION:", desc);
|
||||
print "END:" type;
|
||||
print "END:VCALENDAR"
|
||||
print_cr("END:" type)
|
||||
print_cr("END:VCALENDAR")
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ due && type == "VJOURNAL" { print "Notes and journal entries do not have
|
||||
/^SEQUENCE/ && type { seq = $2; next; } # store sequence number and skip
|
||||
/^END:/ && type == $2 {
|
||||
seq = seq ? seq + 1 : 1;
|
||||
print "SEQUENCE:" seq;
|
||||
print "LAST-MODIFIED:" zulu;
|
||||
if (due) print "DUE;VALUE=DATE:" due;
|
||||
print_cr("SEQUENCE:" seq);
|
||||
print_cr("LAST-MODIFIED:" zulu);
|
||||
if (due) print_cr("DUE;VALUE=DATE:" due);
|
||||
print_fold("SUMMARY:", summary);
|
||||
print_fold("CATEGORIES:", categories);
|
||||
print_fold("DESCRIPTION:", desc);
|
||||
|
||||
@@ -33,6 +33,14 @@ function escape_but_commas(str)
|
||||
return str
|
||||
}
|
||||
|
||||
# Print line using \r\n ending, as required by the RFC
|
||||
#
|
||||
# @input str: String
|
||||
function print_cr(str)
|
||||
{
|
||||
print str "\r"
|
||||
}
|
||||
|
||||
# Print property with its content and fold according to the iCalendar
|
||||
# specification.
|
||||
#
|
||||
@@ -41,16 +49,16 @@ function escape_but_commas(str)
|
||||
# @input content: Escaped content
|
||||
function print_fold(nameparam, content, i, s)
|
||||
{
|
||||
i = 74 - length(nameparam)
|
||||
i = 73 - length(nameparam)
|
||||
s = substr(content, 1, i)
|
||||
print nameparam s
|
||||
s = substr(content, i+1, 73)
|
||||
i = i + 73
|
||||
print_cr(nameparam s)
|
||||
s = substr(content, i+1, 72)
|
||||
i = i + 72
|
||||
while (s)
|
||||
{
|
||||
print " " s
|
||||
s = substr(content, i+1, 73)
|
||||
i = i + 73
|
||||
print_cr(" " s)
|
||||
s = substr(content, i+1, 72)
|
||||
i = i + 72
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user