jschlatow / taskopen

Tool for taking notes and open urls with taskwarrior
GNU General Public License v2.0
368 stars 32 forks source link

Action order in config file is not taken into account #172

Closed oolonek closed 1 week ago

oolonek commented 1 week ago

I am willing to set the default editor for a .md file to be VSCode.

However I can't replicate https://github.com/jschlatow/taskopen/issues/149

Here is my taskopen configuration file (I have place the markdown actions first)

[General]
taskbin=task
taskargs
no_annotation_hook="addnote $ID"
task_attributes="priority,project,tags,description"
--sort:"urgency-,annot"
--active-tasks:"+PENDING,+WAITING"
EDITOR=subl -w
path_ext=/usr/local/share/taskopen/scripts
[Actions]
markdown.target=annotations
markdown.regex=".*md"
markdown.labelregex=".*"
markdown.command="code $FILE"
markdown.filtercommand=""
markdown.inlinecommand=""
notes.target=annotations
notes.labelregex=".*"
notes.regex="^Notes(\\..*)?"
notes.command="""editnote ~/Notes/tasknotes/$UUID$LAST_MATCH "$TASK_DESCRIPTION" $UUID"""
notes.modes="batch,any,normal"
url.target=annotations
url.labelregex=".*"
url.regex="((?:www|http).*)"
url.command="open $LAST_MATCH"
url.modes="batch,any,normal"
files.target=annotations
files.labelregex=".*"
files.regex="^[\\.\\/~]+.*\\.(.*)"
files.command="open $FILE"
files.modes="batch,any,normal"

Here is the output of taskopen diagnostics

(base) ➜  ~ taskopen diagnostics
Environment
  Platform:       Mac OSX
  Taskopen:       v2.0.2-1-g215782d
  Taskwarrior:    3.1.0
  Configuration:  /Users/pma/.taskopenrc
Current configuration
  Binaries and paths:
    taskbin            = task
    taskargs           =
    editor             = subl -w
    path_ext           = /usr/local/share/taskopen/scripts
  General:
    debug              = false
    no_annotation_hook = addnote $ID
    task_attributes    = priority,project,tags,description
  Action groups:
  Subcommands:
    default            = normal
  Actions:
    files
      .target          = annotations
      .regex           = ^[\.\/~]+.*\.(.*)
      .labelregex      = .*
      .command         = open $FILE
      .modes           = batch,any,normal
    notes
      .target          = annotations
      .regex           = ^Notes(\..*)?
      .labelregex      = .*
      .command         = editnote ~/Notes/tasknotes/$UUID$LAST_MATCH "$TASK_DES
                         CRIPTION" $UUID
      .modes           = batch,any,normal
    url
      .target          = annotations
      .regex           = ((?:www|http).*)
      .labelregex      = .*
      .command         = open $LAST_MATCH
      .modes           = batch,any,normal
    markdown
      .target          = annotations
      .regex           = .*md
      .labelregex      = .*
      .command         = code $FILE
      .modes           = batch,any,normal

Indeed opening in debug mode indicates precedence of the default open command

(base) ➜  ~ taskopen 14 --debug
Executing: task rc.verbose=blank,label,edit rc.json.array=on rc.gc=off  context show
Executing: task rc.verbose=blank,label,edit rc.json.array=on rc.gc=off   14 +PENDING,+WAITING export
Please select one or multiple actions:
 1) notes: Notes
    ("test_task") -- 14
    command: editnote ~/Notes/tasknotes/$UUID$LAST_MATCH "$TASK_DESCRIPTION" $UUID
 2) files: ~/.test.md
    ("test_task") -- 14
    command: open $FILE

What am I doing wrong here ?

jschlatow commented 1 week ago

@oolonek The order of action definitions in your config file does not have any effect. However, you may add an alias in order to define a precedence.

[CLI]
alias.default = "normal --include markdown,files,notes,url"
default = default

Alternatively, you may also just use the any mode (taskopen any 14) to let taskopen present all matching actions for interactive selection.

oolonek commented 1 week ago

Thanks a bunch @jschlatow.

Pasting working config file on my side for the record.

[General]
taskbin=task
taskargs
no_annotation_hook="addnote $ID"
task_attributes="priority,project,tags,description"
--sort:"urgency-,annot"
--active-tasks:"+PENDING,+WAITING"
EDITOR=subl -w
path_ext=/usr/local/share/taskopen/scripts
[Actions]
markdown.target=annotations
markdown.regex="^.*\\.(md|markdown)$"
markdown.labelregex=".*"
markdown.command="code $FILE"
markdown.filtercommand=""
markdown.inlinecommand=""
notes.target=annotations
notes.labelregex=".*"
notes.regex="^Notes(\\..*)?"
notes.command="""editnote ~/Notes/tasknotes/$UUID$LAST_MATCH "$TASK_DESCRIPTION" $UUID"""
notes.modes="batch,any,normal"
url.target=annotations
url.labelregex=".*"
url.regex="((?:www|http).*)"
url.command="open $LAST_MATCH"
url.modes="batch,any,normal"
files.target=annotations
files.labelregex=".*"
files.regex="^[\\.\\/~]+.*\\.(.*)"
files.command="open $FILE"
files.modes="batch,any,normal"
[CLI]
alias.default = "normal --include markdown,files,notes,url"
default = default

My initial markdown.regex="*.md" was not OK.