diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-07 22:00:30 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-08 20:46:59 +0900 |
commit | d0eba2546a559922a53b59de44e7946b9d6b7c84 (patch) | |
tree | 9088813cb3112ef8cb09d167d8fb619a8d7a4616 /src/background/actions | |
parent | ef6bbd117e042fecea85b2dbb8294ad60e4e8d48 (diff) |
addbookmark command
Diffstat (limited to 'src/background/actions')
-rw-r--r-- | src/background/actions/command.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/background/actions/command.js b/src/background/actions/command.js index 2f7305a..e46a97e 100644 --- a/src/background/actions/command.js +++ b/src/background/actions/command.js @@ -1,5 +1,6 @@ import actions from '../actions'; import * as tabs from '../shared/tabs'; +import * as bookmarks from '../shared/bookmarks'; import * as parsers from 'shared/commands/parsers'; import * as properties from 'shared/settings/properties'; @@ -39,6 +40,14 @@ const bufferCommand = (keywords) => { }); }; +const addBookmarkCommand = (tab, args) => { + if (!args[0]) { + return Promise.resolve(); + } + + return bookmarks.create(args[0], tab.url); +}; + const setCommand = (args) => { if (!args[0]) { return Promise.resolve(); @@ -52,7 +61,7 @@ const setCommand = (args) => { }; }; -const exec = (line, settings) => { +const exec = (tab, line, settings) => { let [name, args] = parsers.parseCommandLine(line); switch (name) { @@ -68,6 +77,8 @@ const exec = (line, settings) => { case 'b': case 'buffer': return bufferCommand(args); + case 'addbookmark': + return addBookmarkCommand(tab, args); case 'set': return setCommand(args); case '': |