From: Norbert Moutarde Date: Tue, 23 Jul 2013 13:26:46 +0000 (+0200) Subject: I've cleaned my main X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=94e040533f8fb293d412cd20a5c899ea0372c952;p=diary-shell I've cleaned my main --- diff --git a/alias.sql b/alias.sql index b6702a7..9852214 100644 --- a/alias.sql +++ b/alias.sql @@ -1,4 +1,4 @@ -insert into alias (nom, cmd, argc, help) values ('tables', 'select tablename from pg_tables', 0, 'list table (every table...)'); +insert into alias (nom, cmd, argc, help) values ('tables', 'select tablename from pg_tables where tableowner=current_user', 0, 'list table (every table...)'); 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'); @@ -16,3 +16,4 @@ insert into alias (nom, cmd, argc, help) values ('help', 'select argc from 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 (...)'); insert into alias (nom, cmd, argc, inf, help) values ('default', 'INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);', 2 , '1', 'default command'); +insert into alias (nom, cmd, argc, inf, help) values ('aliasadd', 'insert into alias (nom, argc, cmd) values ( $1, $2, $3 );', 3, '1', 'add alias (with form : aliasadd "name" "argc" "SQL")'); diff --git a/main.cpp b/main.cpp index e80db55..23a1b99 100644 --- a/main.cpp +++ b/main.cpp @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) int hm; diary.getvar(); do{ - clog<<"again\n"; + clog<<"======================again=================================\n"; hm=diary.hmRecord(); cout<> buf) words.push_back(buf); if(words.size()==0)break;//quit - else if (words[0]=="w") diary.exec(words); else if (words[0]=="p") diary.print(); - //else if (words[0]=="help") diary.help(); now into SQL else if (words[0]=="status") diary.status(); - else if (words[0]=="con") diary.printvar(); - else if ((words[0]=="alias")&&(words.size()>1)) { - if (words[1]=="add") { - string cmd=""; - for (int a=3; a::iterator it; it = words.begin(); - it = words.insert ( it , "default"); + it = words.insert (it, "now"); + it = words.insert (it, "default"); diary.alias(words);*/ diary.insert(words); } diff --git a/sqldb.cpp b/sqldb.cpp index 327f0aa..6aeb730 100644 --- a/sqldb.cpp +++ b/sqldb.cpp @@ -285,14 +285,9 @@ bool sqlpg::alias(vector a){ binary[inf-inf]=0; } clog<<"if(inf!=0) finish\n"; - for(int k=0; k<(argc+inf); k++){ + for(int k=0; k<(argc); k++){ clog<<"value["< (a, b) ); }; - clog<<"value.size="<