AutoYADM commit: 2025-04-23 14:30:05
This commit is contained in:
parent
ef22c23678
commit
d31c2a02a6
2 changed files with 51 additions and 48 deletions
|
@ -1,11 +1,4 @@
|
||||||
complete -c jrnl -s h -l help -d 'Print help'
|
complete -c jrnl -s h -l help -d 'Print help'
|
||||||
complete -c jrnl -s e -l edit-template -d 'Edit the journal entry template'
|
complete -c jrnl -s e -l edit-template -d 'Edit the journal entry template'
|
||||||
complete -c jrnl -s d -l dir -d 'Set the journal directory' -r
|
complete -c jrnl -s d -l dir -d 'Set the journal directory' -r
|
||||||
function __jrnl_dir
|
|
||||||
if set -q jrnl_directory
|
|
||||||
echo $jrnl_directory
|
|
||||||
else
|
|
||||||
echo ~/jrnl
|
|
||||||
end
|
|
||||||
end
|
|
||||||
complete -c jrnl -s t -l template -d 'Set the template file' -r
|
complete -c jrnl -s t -l template -d 'Set the template file' -r
|
||||||
|
|
|
@ -1,39 +1,41 @@
|
||||||
function jrnl --description 'Lightweight journaling tool'
|
function jrnl --description 'Lightweight journaling tool'
|
||||||
argparse h/help d/dir=? t/template=? e/edit-template -- $argv
|
argparse h/help d/dir= t/template= e/edit-template -- $argv
|
||||||
if set -q _flag_h
|
if set -q _flag_h
|
||||||
echo jrnl: a lightweight journaling tool
|
echo (set_color -o)jrnl: a lightweight journaling tool(set_color normal)
|
||||||
echo
|
echo
|
||||||
echo Call jrnl without options to get started.
|
echo Call jrnl without options to get started.
|
||||||
echo
|
echo
|
||||||
echo Usage:
|
echo (set_color -o)Usage:(set_color normal)
|
||||||
echo \tOpen today\'s entry:
|
echo (set_color -o)\tOpen today\'s entry:(set_color normal)
|
||||||
echo \t\> jrnl
|
echo \t\> jrnl
|
||||||
echo \tEdit the template:
|
echo (set_color -o)\tEdit the template:(set_color normal)
|
||||||
echo \t\> jrnl -e
|
echo \t\> jrnl -e
|
||||||
echo \t\> jrnl --edit-template
|
echo \t\> jrnl --edit-template
|
||||||
echo \tSet the journal directory "(~/jrnl)" by default:
|
echo (set_color -o)\tSet the journal directory "(~/jrnl)" by default:(set_color normal)
|
||||||
echo \t\> set -Ug jrnl_directory path/to/journal
|
echo \t\> set -Ug jrnl_directory path/to/journal
|
||||||
echo \t\> jrnl -d=path
|
echo \t\> jrnl -d path
|
||||||
echo \t\> jrnl --dir=path
|
echo \t\> jrnl --dir path
|
||||||
echo \tSet the template file "(relative to journal directory)":
|
echo (set_color -o)\tSet the template file:(set_color normal)
|
||||||
echo \t\> set -Ug jrnl_template template_file
|
echo \t\> set -Ug jrnl_template template_file
|
||||||
echo \t\> jrnl -t=template_file.md
|
echo \t\> jrnl -t template_file.md
|
||||||
echo \t\> jrnl --template=template_file.md
|
echo \t\> jrnl --template template_file.md
|
||||||
echo \tShow this help menu:
|
echo (set_color -i)\tIf the variable or option resolves to a real file,(set_color normal)
|
||||||
|
echo (set_color -i)\tit will be used as the template. Otherwise, the(set_color normal)
|
||||||
|
echo (set_color -i)\tjrnl directory is searched for the file name.(set_color normal)
|
||||||
|
echo (set_color -o)\tShow this help menu:(set_color normal)
|
||||||
echo \t\> jrnl -h
|
echo \t\> jrnl -h
|
||||||
echo \t\> jrnl --help
|
echo \t\> jrnl --help
|
||||||
echo Template file:
|
echo (set_color -o)Template file:(set_color normal)
|
||||||
echo \tThe template file is a Markdown file inside the
|
echo \t"\$jrnl_directory/template.md" is its default location.
|
||||||
echo \tjournal directory, called \'template.md\' by default.
|
|
||||||
echo \tMarkdown comments are always skipped.
|
echo \tMarkdown comments are always skipped.
|
||||||
echo \tExtra newlines at the file end are trimmed.
|
echo \tExtra newlines at the file end are trimmed.
|
||||||
echo \tThe literals '\'%{date}\'' and '\'%{date_long}\''
|
echo \tThe literals '\'%{date}\'' and '\'%{date_long}\''
|
||||||
echo \tare substituted for date values.
|
echo \tare substituted for date values.
|
||||||
echo Author:
|
echo (set_color -o)Author:(set_color normal)
|
||||||
echo \tDaniel Fichtinger '<daniel@ficd.ca>'
|
echo \tDaniel Fichtinger '<'(set_color -u)daniel@ficd.ca(set_color normal)'>'
|
||||||
echo URL:
|
echo (set_color -o)URL:(set_color normal)
|
||||||
echo \thttps://git.sr.ht/~ficd/jrnl.fish
|
echo (set_color -u)\thttps://git.sr.ht/~ficd/jrnl.fish(set_color normal)
|
||||||
echo License:
|
echo (set_color -o)License:(set_color normal)
|
||||||
echo \tMIT '(c)' Daniel Fichtinger 2025
|
echo \tMIT '(c)' Daniel Fichtinger 2025
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -52,13 +54,20 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
|
|
||||||
set -f template $jdir/template.md
|
set -f template $jdir/template.md
|
||||||
if set -ql _flag_template[1]
|
if set -ql _flag_template[1]
|
||||||
set template $jdir/$_flag_template[1]
|
set template (path resolve $_flag_template[1])
|
||||||
else if set -q jrnl_template
|
else if set -q jrnl_template
|
||||||
set template $jdir/$jrnl_template
|
set template $jrnl_template
|
||||||
end
|
end
|
||||||
|
set -f template_base (path basename $template)
|
||||||
|
|
||||||
if not test -f $template
|
if not test -f $template
|
||||||
set -l prompt "There is no template, create one now? (y/n): "
|
# first check if template exists in jdir
|
||||||
|
set -l candidate (fd -F -1 "$template_base" "$jdir")
|
||||||
|
if test -n "$candidate"
|
||||||
|
set template (path resolve $candidate)
|
||||||
|
else
|
||||||
|
set template $jdir/$template_base
|
||||||
|
set -l prompt "There is no template at $template, create one now? (y/n): "
|
||||||
while read --nchars 1 -l response --prompt-str="$prompt" or return 1
|
while read --nchars 1 -l response --prompt-str="$prompt" or return 1
|
||||||
printf "\033[1A\033[2K"
|
printf "\033[1A\033[2K"
|
||||||
switch $response
|
switch $response
|
||||||
|
@ -76,7 +85,8 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
set -q _flag_e; and return 0
|
set -q _flag_e; and return 0
|
||||||
break
|
break
|
||||||
case n N
|
case n N
|
||||||
break
|
return 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue