Merge branch 'develop' into main
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
bf735b7654
|
@ -109,6 +109,15 @@ public:
|
|||
list<entry> retrieve(const time_point &start = time_point(),
|
||||
const time_point &end = system_clock::now()) const;
|
||||
|
||||
/*!
|
||||
* @brief Remove all entries with this URI from database.
|
||||
*
|
||||
* @return Number of removed entries.
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
size_t remove(const string &uri);
|
||||
|
||||
private:
|
||||
fs::path _dbpath;
|
||||
std::unique_ptr<Session> _session;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
:doctype: manpage
|
||||
:Author: tastytea
|
||||
:Email: tastytea@tastytea.de
|
||||
:Date: 2019-11-27
|
||||
:Date: 2019-11-28
|
||||
:Revision: 0.0.0
|
||||
:man source: remwharead
|
||||
:man manual: General Commands Manual
|
||||
|
@ -17,6 +17,8 @@ remwharead - Saves URIs of things you want to remember in a database
|
|||
|
||||
*remwharead* *-e*=_format_ [*-f*=_file_] [*-T*=_start_,_end_] [[*-s*|*-S*]=_expression_] [*-r*]
|
||||
|
||||
*remwharead* [*-d*=_URI_]
|
||||
|
||||
== DESCRIPTION
|
||||
|
||||
*remwharead* saves URIs of things you want to remember in a database along with
|
||||
|
@ -62,6 +64,9 @@ every tag is enclosed by _^_ and _$_.
|
|||
*-N*, *--no-archive*::
|
||||
Do not archive URI.
|
||||
|
||||
*-d*=_URI_, *--delete*=_URI_::
|
||||
Remove all entries with this URI from the database.
|
||||
|
||||
*-h*, *--help*::
|
||||
Show help message.
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "remwharead_cli.hpp"
|
||||
#include "sqlite.hpp"
|
||||
#include "time.hpp"
|
||||
#include "version.hpp"
|
||||
#include <Poco/Util/HelpFormatter.h>
|
||||
|
@ -81,6 +82,11 @@ void App::defineOptions(OptionSet& options)
|
|||
options.addOption(
|
||||
Option("no-archive", "N", "Do not archive URI.")
|
||||
.callback(OptionCallback<App>(this, &App::handle_options)));
|
||||
options.addOption(
|
||||
Option("delete", "d",
|
||||
"Remove all entries with this URI from database.")
|
||||
.argument("URI")
|
||||
.callback(OptionCallback<App>(this, &App::handle_options)));
|
||||
}
|
||||
|
||||
void App::handle_options(const std::string &name, const std::string &value)
|
||||
|
@ -194,6 +200,12 @@ void App::handle_options(const std::string &name, const std::string &value)
|
|||
{
|
||||
_regex = true;
|
||||
}
|
||||
else if (name == "delete")
|
||||
{
|
||||
Database db;
|
||||
cout << "Deleted " << db.remove(value) << " entries.\n";
|
||||
_exit_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
void App::print_help(const string &option)
|
||||
|
@ -207,7 +219,8 @@ void App::print_help(const string &option)
|
|||
helpFormatter->setCommand(commandName());
|
||||
helpFormatter->setUsage("[-t tags] [-N] URI\n"
|
||||
"-e format [-f file] [-T start,end] "
|
||||
"[[-s|-S] expression] [-r]");
|
||||
"[[-s|-S] expression] [-r]\n"
|
||||
"-d URI");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -166,6 +166,15 @@ list<Database::entry> Database::retrieve(const time_point &start,
|
|||
return {};
|
||||
}
|
||||
|
||||
size_t Database::remove(const string &uri)
|
||||
{
|
||||
Statement del(*_session);
|
||||
|
||||
del << "DELETE FROM remwharead WHERE uri = ?;", bind(uri);
|
||||
|
||||
return del.execute();
|
||||
}
|
||||
|
||||
fs::path Database::get_data_home() const
|
||||
{
|
||||
fs::path path;
|
||||
|
|
Loading…
Reference in New Issue
Block a user