aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bookmarks/builtins.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/bookmarks/builtins.cpp b/src/bookmarks/builtins.cpp
index 8881038..259bfa6 100644
--- a/src/bookmarks/builtins.cpp
+++ b/src/bookmarks/builtins.cpp
@@ -16,13 +16,16 @@
int builtins::bookmarks(const std::string &progname, std::vector<std::string>::const_iterator beginargs, std::vector<std::string>::const_iterator endargs)
{
- args::ArgumentParser parser("bookmarks");
+ args::ArgumentParser parser("bookmarks",
+ "If an output location is not specified, this command will append imported bookmarks to the browser's bookmarks.\n"
+ "If an output location is specified, this command will load all XBEL-format bookmarks, then all JSON-format bookmarks, and write them to the output location."
+ );
parser.Prog(progname);
args::HelpFlag help(parser, "help", "Display this help message and exit.", { 'h', "help" });
- args::ValueFlag<std::string> save(parser, "file, stdout", "Export the bookmarks as (defaults to bookmark path)", { 'e', "export" });
- args::ValueFlagList<std::string> import_xbel(parser, "bookmarks.xbel", "Import xbel bookmarks", { 'x', "import-xbel" });
- args::ValueFlagList<std::string> import_json(parser, "bookmarks.json", "Import json bookmarks", { 'j', "import-json" });
+ args::ValueFlag<std::string> save(parser, "file, stdout", "Output location.", { 'e', "export" });
+ args::ValueFlagList<std::string> import_xbel(parser, "bookmarks.xbel", "Import xbel format.", { 'x', "import-xbel" });
+ args::ValueFlagList<std::string> import_json(parser, "bookmarks.json", "Import json format.", { 'j', "import-json" });
try {
parser.ParseArgs(beginargs, endargs);
@@ -37,6 +40,16 @@ int builtins::bookmarks(const std::string &progname, std::vector<std::string>::c
auto *model = new BookmarkModel;
+ // implicit bookmarks.path import
+ if(!save) {
+ Configuration conf;
+ QFile f(conf.value<QString>("bookmarks.path").value());
+ if(f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ BookmarkFormat<XbelFormat>(&f) >> model;
+ f.close();
+ }
+ }
+
for(const auto &i : args::get(import_xbel)) {
QFile f(QString::fromStdString(i));
if(f.open(QIODevice::ReadOnly | QIODevice::Text)) {