mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
* Add command to list tags associated with a given note * Update description * Fix autocompletion to do notes instead of tags when tag-command is notetags
This commit is contained in:
parent
885858dcb4
commit
0386534b3a
@ -30,6 +30,11 @@ async function handleAutocompletionPromise(line) {
|
||||
if (metadata === undefined) {
|
||||
return line;
|
||||
}
|
||||
|
||||
if (words[0] === 'tag' && words[1] === 'notetags') {
|
||||
metadata.usage = 'tag <tag-command> <note>';
|
||||
}
|
||||
|
||||
// complete an option
|
||||
let next = words.length > 1 ? words[words.length - 1] : '';
|
||||
let l = [];
|
||||
@ -100,7 +105,7 @@ async function handleAutocompletionPromise(line) {
|
||||
}
|
||||
|
||||
if (argName == 'tag-command') {
|
||||
let c = filterList(['add', 'remove', 'list'], next);
|
||||
let c = filterList(['add', 'remove', 'list', 'notetags'], next);
|
||||
l.push(...c);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Command extends BaseCommand {
|
||||
}
|
||||
|
||||
description() {
|
||||
return _('<tag-command> can be "add", "remove" or "list" to assign or remove [tag] from [note], or to list the notes associated with [tag]. The command `tag list` can be used to list all the tags (use -l for long option).');
|
||||
return _('<tag-command> can be "add", "remove", "list", or "notetags" to assign or remove [tag] from [note], to list notes associated with [tag], or to list tags associated with [note]. The command `tag list` can be used to list all the tags (use -l for long option).');
|
||||
}
|
||||
|
||||
options() {
|
||||
@ -75,6 +75,18 @@ class Command extends BaseCommand {
|
||||
this.stdout(tag.title);
|
||||
});
|
||||
}
|
||||
} else if (command == 'notetags') {
|
||||
if (args.tag) {
|
||||
let note = await app().loadItems(BaseModel.TYPE_NOTE, args.tag);
|
||||
if (note.length < 1) throw new Error(_('Cannot find note with id "%s".', args.tag));
|
||||
if (note.length > 1) throw new Error(_('Multiple notes match the id "%s". Please be more specific', args.tag));
|
||||
let tags = await Tag.tagsByNoteId(note[0].id);
|
||||
tags.map(tag => {
|
||||
this.stdout(tag.title);
|
||||
});
|
||||
} else {
|
||||
throw new Error(_('Missing required argument: note'));
|
||||
}
|
||||
} else {
|
||||
throw new Error(_('Invalid command: "%s"', command));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user