Added option to not archive page.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
a1b31cc121
commit
8e75e7bfbf
|
@ -52,6 +52,9 @@ Search in tags. Format: _tag1 AND tag2 OR tag3_. See _SEARCH EXPRESSIONS_.
|
|||
*--search-all* _expression_::
|
||||
Search in tags, title, description and full text.
|
||||
|
||||
*-N*, *--no-archive*::
|
||||
Do not archive URI.
|
||||
|
||||
*-h*, *--help*::
|
||||
Show help message.
|
||||
|
||||
|
|
|
@ -56,7 +56,12 @@ int main(const int argc, const char *argv[])
|
|||
cerr << "Error: Could not fetch page.\n";
|
||||
return 4;
|
||||
}
|
||||
db.store({opts.uri, uri.archive(), system_clock::now(), opts.tags,
|
||||
string archive_uri;
|
||||
if (opts.archive)
|
||||
{
|
||||
archive_uri = uri.archive();
|
||||
}
|
||||
db.store({opts.uri, archive_uri, system_clock::now(), opts.tags,
|
||||
page.title, page.description, page.fulltext});
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,7 @@ const options parse_options(const int argc, const char *argv[])
|
|||
{
|
||||
string tags;
|
||||
string format;
|
||||
string file;
|
||||
string span;
|
||||
string search_tags;
|
||||
string search_all;
|
||||
options opts;
|
||||
|
||||
try
|
||||
|
@ -49,18 +46,20 @@ const options parse_options(const int argc, const char *argv[])
|
|||
op.add<popl::Value<string>>
|
||||
("e", "export", "Export to format.", "", &format);
|
||||
op.add<popl::Value<string>>
|
||||
("f", "file", "Save output to file.", "", &file);
|
||||
("f", "file", "Save output to file.", "", &opts.file);
|
||||
op.add<popl::Value<string>>
|
||||
("S", "span", "Only export entries between YYYY-MM-DD,YYYY-MM-DD.",
|
||||
"", &span);
|
||||
op.add<popl::Value<string>>
|
||||
("s", "search-tags",
|
||||
"Search in tags. Format: tag1 AND tag2 OR tag3.",
|
||||
"", &search_tags);
|
||||
"", &opts.search_tags);
|
||||
op.add<popl::Value<string>>
|
||||
("", "search-all",
|
||||
"Search in tags, title, description and full text.",
|
||||
"", &search_all);
|
||||
"", &opts.search_all);
|
||||
auto option_noarchive = op.add<popl::Switch>
|
||||
("N", "no-archive", "Do not archive URI.");
|
||||
auto option_help = op.add<popl::Switch>
|
||||
("h", "help", "Show this help message.");
|
||||
auto option_version = op.add<popl::Switch>
|
||||
|
@ -88,6 +87,11 @@ const options parse_options(const int argc, const char *argv[])
|
|||
return options(0);
|
||||
}
|
||||
|
||||
if (option_noarchive->is_set())
|
||||
{
|
||||
opts.archive = false;
|
||||
}
|
||||
|
||||
if (!tags.empty())
|
||||
{
|
||||
size_t pos_end = 0;
|
||||
|
@ -119,8 +123,6 @@ const options parse_options(const int argc, const char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
opts.file = file;
|
||||
|
||||
if (!span.empty())
|
||||
{
|
||||
size_t pos = span.find(',');
|
||||
|
@ -140,10 +142,6 @@ const options parse_options(const int argc, const char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
opts.search_tags = search_tags;
|
||||
|
||||
opts.search_all = search_all;
|
||||
|
||||
if (op.non_option_args().size() > 0)
|
||||
{
|
||||
opts.uri = op.non_option_args().front();
|
||||
|
|
|
@ -41,6 +41,7 @@ typedef struct options
|
|||
string uri;
|
||||
string search_tags;
|
||||
string search_all;
|
||||
bool archive = true;
|
||||
uint8_t status_code = 0;
|
||||
|
||||
options();
|
||||
|
|
Loading…
Reference in New Issue