From: Norbert Moutarde Date: Mon, 15 Jul 2013 17:28:16 +0000 (+0200) Subject: I've added some help into alias.sql, tweaked the output (the last "|") and some other... X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=f78977cb6d4d6ccfce732860cfc936c247b29a50;p=diary-shell.git I've added some help into alias.sql, tweaked the output (the last "|") and some other little bug --- diff --git a/alias.sql b/alias.sql index 6702bab..81c7d62 100644 --- a/alias.sql +++ b/alias.sql @@ -1,14 +1,15 @@ -INSERT INTO alias (nom, command, argc, help) VALUES ('ls', 'select id,texte from raw order by date asc;', 0, 'liste les enregistrement (select by ID, between 2 date, everyone)'); -insert into alias (nom, command, argc) values ('ls', 'select * from raw where id=$1 order by date asc;', 1); -insert into alias (nom, command, argc) values ('ls', 'select * from raw where date between $1 and $2 order by date asc;', 2); -INSERT INTO alias (nom, command, argc, help) VALUES ('search', 'select id,texte from raw where texte ~ $1 order by date asc;', 1, 'search record who contains your arg (only one'); -INSERT INTO alias (nom, command, argc, help) VALUES ('rm', 'DELETE FROM raw WHERE id =$1;', 1, 'delete record by ID'); -INSERT INTO alias (nom, command, argc, help) VALUES ('alias', 'select nom from alias;', 0, 'print every alias''s name'); -insert into alias (nom, command, argc, help) values ('var', 'select nom from var', 0, 'print avery var/named var content'); -insert into alias (nom, command, argc) values ('var', 'select nom,value from var where nom=$1 order by id', 1); -insert into alias (nom, command, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1', 'list memo''s name'); -insert into alias (nom, command, argc) values ('memo', 'select distinct word from memo', 0); -insert into alias (nom, command, argc, help) values ('memo', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content'); -insert into alias (nom, command, argc, help) values ('help', 'select distinct nom from alias', 0, 'help itself (add "command to get specific help")'); -insert into alias (nom, command, argc) values ('help', 'select distinct id,nom,command from alias where nom=$1', 1); -insert into alias (nom, command, argc) values ('help', 'select id,nom,command from alias where nom=$1 and argc=$2', 1); +INSERT INTO alias (nom, cmd, argc, help) VALUES ('ls', 'select id,texte from raw order by date asc;', 0, 'list id,text of every records'); +insert into alias (nom, cmd, argc, help) values ('ls', 'select * from raw where id=$1 order by date asc;', 1, 'print id,date,text of one record'); +insert into alias (nom, cmd, argc, help) values ('ls', 'select * from raw where date between $1 and $2 order by date asc;', 2, 'liste record with date between $1 and $2'); +INSERT INTO alias (nom, cmd, argc, help) VALUES ('search', 'select id,texte from raw where texte ~ $1 order by date asc;', 1, 'search record who contains your arg (only one'); +INSERT INTO alias (nom, cmd, argc, help) VALUES ('rm', 'DELETE FROM raw WHERE id =$1;', 1, 'delete record by ID'); +INSERT INTO alias (nom, cmd, argc, help) VALUES ('alias', 'select nom from alias;', 0, 'print every alias''s name'); +insert into alias (nom, cmd, argc, help) values ('var', 'select nom from var', 0, 'print avery var'); +insert into alias (nom, cmd, argc, help) values ('var', 'select nom,value from var where nom=$1 order by id', 1, 'print named var content'); +insert into alias (nom, cmd, argc, inf, help) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 2, '1', 'list memo''s name'); +insert into alias (nom, cmd, argc, help) values ('memo', 'select distinct word from memo', 0, 'list all word with memo attached'); +insert into alias (nom, cmd, argc, help) values ('memo', 'select id,rem from memo where word=$1 order by id', 1, 'print memo content'); +insert into alias (nom, cmd, argc, help) values ('help', 'select distinct nom from alias', 0, 'help itself (add "cmd" to get specific help)'); +insert into alias (nom, cmd, argc, help) values ('help', 'select argc from alias where nom=$1 order by argc', 1, 'print id,argc of named alias'); +insert into alias (nom, cmd, argc, help) values ('help', 'select help from alias where nom=$1 and argc=$2', 2, 'print help for only one alias (as "nom" and "argc" is a key)'); +insert into alias (nom, cmd, argc, help) values ('print', 'select cmd,inf from alias where nom=$1 and argc=$2', 2, 'print SQL command of an alias (...)'); diff --git a/sqldb.cpp b/sqldb.cpp index c1573ac..c1b7363 100644 --- a/sqldb.cpp +++ b/sqldb.cpp @@ -17,7 +17,7 @@ sqlpg::sqlpg() { //conn = PQconnectStart(var.c_str()); conn = PQconnectdb(connect.c_str()); clog<<"prepare SQL statement\n"; - string cmd="select command,argc,inf from alias where ((nom = $1) and (argc = $2)) OR ((nom = $1) and (inf='1') and (argc < $2));"; + string cmd="select cmd,argc,inf from alias where ((nom = $1) and (argc = $2)) OR ((nom = $1) and (inf='1') and (argc < $2));"; clog<<"SQL statement="<