aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2016-05-12 12:46:04 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2016-05-12 12:46:04 +0200
commitea940218791cd59d3726158365ca61dc24a91030 (patch)
treeab58543589af733b98e3a499fcf9e08a311c7022
parent5e59a460d01538d89fc1bdd11a4e30a2c1b669dd (diff)
downloadmark-ea940218791cd59d3726158365ca61dc24a91030.tar.gz
mark-ea940218791cd59d3726158365ca61dc24a91030.zip
[WIP] wrap __mark_<functions> in main mark function
-rw-r--r--functions/mark.fish34
1 files changed, 32 insertions, 2 deletions
diff --git a/functions/mark.fish b/functions/mark.fish
index ba8f42e..39e1b16 100644
--- a/functions/mark.fish
+++ b/functions/mark.fish
@@ -282,13 +282,13 @@ function __mark_set --description 'mark a day in a store'
# correct year sub-block
set is_year false
for l in $marks
- if begin test $is_year= false
+ if begin test $is_year = false
and string match -q -r "^$year:\$" $l
end
set year_found true
end
- if test $is_year= true
+ if test $is_year = true
if test $m -ne $month
echo $l >> $mark_store.new
else
@@ -312,3 +312,33 @@ function __mark_set --description 'mark a day in a store'
mv $mark_store.new $mark_store
end
+
+function mark
+ for i in (seq 2 (count $argv))
+ if string match -q -- "-d=*" "$argv[$i]"
+ set day (string replace -- "-d=" "" $argv[$i])
+ else if string match -q -- "-m=*" "$argv[$i]"
+ set month (string replace -- "-m=" "" $argv[$i])
+ else if string match -q -- "-y=*" "$argv[$i]"
+ set year (string replace -- "-y=" "" $argv[$i])
+ else if string match -q -- "-s=*" "$argv[$i]"
+ set mark_store (string replace -- "-s=" "" "$argv[$i]")
+ else if string match -q -- "-z=*" "$argv[$i]"
+ set sign (string replace -- "-z=" "" "$argv[$i]")
+ else if string match -q -- "-r=*" "$argv[$i]"
+ set range (string replace -- "-r=" "" "$argv[$i]")
+ else
+ echo unrecognised option: $argv[$i] >&2
+ return 1
+ end
+ end
+
+ switch $argv[1]
+ case "set" "s"
+ __mark_set $argv[2..-1]
+ case "get" "g"
+ __mark_get $argv[2..-1]
+ case "month" "m"
+ __mark_print_month $argv[2..-1]
+ end
+end