From a2d9c2eb5c83cdae8eb50821cfa34f0ccf2dbe22 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 30 Aug 2018 16:40:06 +0200 Subject: [PATCH] added feature to remove records --- CMakeLists.txt | 2 +- README.md | 30 ++++++++++++++++++++---------- src/whyblock.cpp | 16 +++++++++++++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a88d9a..20aff84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (whyblocked - VERSION 0.3.0 + VERSION 0.4.0 LANGUAGES CXX ) diff --git a/README.md b/README.md index 573c8f3..6c93187 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,30 @@ It has a text interface and uses a SQLite-database. ## Usage +### Example + ```PLAIN $ whyblocked -This is whyblock 0.1.0. +This is whyblock 0.4.0. Type add, remove, view or details. Or just the first letter. -: v - Blocked: @baduser@social.example.com because: Is very mean -Silenced: @truebelievers.example.com because: Annoying instance -: d -Which user? -@baduser@social.example.com -@baduser@social.example.com is blocked, because: Is very mean +Type quit or q to quit the program. +: add +User or instance: @tastytea@soc.ialis.me +Blocked(b) or silenced(s): b +Reason: Too nice +Add receipt? [y/n] y +URL: https://tastytea.de/ +Add receipt? [y/n] n +: view + Blocked: @tastytea@soc.ialis.me because: Too nice +: details +User or instance: @tastytea@soc.ialis.me +@tastytea@soc.ialis.me is blocked, because: Too nice Receipts: - https:///social.example.com/@baduser/123456789012345678 -: q + https://tastytea.de/ +: remove +User or instance: @tastytea@soc.ialis.me +: quit ``` ## Install diff --git a/src/whyblock.cpp b/src/whyblock.cpp index 16ec311..552ae8c 100644 --- a/src/whyblock.cpp +++ b/src/whyblock.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { string user, reason; int blocked = -1; - cout << "User or Instance: "; + cout << "User or instance: "; cin >> user; while (blocked == -1) { @@ -113,7 +113,17 @@ int main(int argc, char *argv[]) case 'r': case 'R': { - cout << "REMOVE\n"; + string user; + cout << "User or instance: "; + cin >> user; + + sqlite::execute rm_blocks(con, "DELETE FROM blocks WHERE user = ?;"); + sqlite::execute rm_urls(con, "DELETE FROM urls WHERE user = ?;"); + rm_blocks % user; + rm_urls % user; + rm_blocks(); + rm_urls(); + break; } case 'v': @@ -139,7 +149,7 @@ int main(int argc, char *argv[]) case 'd': case 'D': { - cout << "Which user?\n"; + cout << "User or instance: "; cin >> answer; { sqlite::query q(con, "SELECT * FROM blocks WHERE user = \'" + answer + "\';");