]> git.nothing2do.fr Git - diary-shell.git/commitdiff
help subsystem is nom SQL'ed !
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sun, 14 Jul 2013 09:25:33 +0000 (11:25 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sun, 14 Jul 2013 09:25:33 +0000 (11:25 +0200)
alias.sql
main.cpp
sqldb.cpp
tables1.sql

index 4237b802ce1263d6993846005b76b891b5406b78..e79e4c30e326e5f610a46f578dc6a045a4bbd714 100644 (file)
--- a/alias.sql
+++ b/alias.sql
@@ -1,11 +1,13 @@
-INSERT INTO alias (nom, command, argc) VALUES ('ls', 'select id,texte from raw order by date asc;', 0);
+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) VALUES ('search', 'select id,texte from raw where texte ~ $1 order by date asc;', 1);
-INSERT INTO alias (nom, command, argc) VALUES ('rm', 'DELETE FROM raw WHERE id =$1;', 1);
-INSERT INTO alias (nom, command, argc) VALUES ('alias', 'select nom from alias;', 0);
-insert into alias (nom, command, argc) values ('var', 'select nom from var', 0);
-insert into alias (nom, command, argc) values ('var', 'select id,nom,value from var where nom=$1 order by id', 1);
-insert into alias (nom, command, argc, inf) values ('memo', 'insert into memo (word, rem) values ($1, $2);', 1, '1');
+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/record new one/');
 insert into alias (nom, command, argc) values ('memo', 'select distinct word from memo', 0);
-insert into alias (nom, command, argc) values ('mem', 'select id,rem from memo where word=$1 order by id', 1);
+insert into alias (nom, command, argc, help) values ('mem', '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);
index a4494e4203b649e752e9c2d9e2beccd316f9897c..c66d4a855e633e3d57827e2df2a1bc7bec41a26d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -12,15 +12,6 @@ string date(string a)//transform any date format (in help) to "YYYY-MM-DD HH:MM:
     ss>>y>>"-">>m>>"-">>d>>" ">>h>>":">>m>>":">>s>>".">>x;
     return ss.str();*/
 }
-void help()
-{
-
-    cout<<"command in c++ : value, print, status, help, alias (-/+list/+add), ! SQL...\n";
-    cout<<"command in SQL : \n";
-}
-
-
-
 int main(int argc, char *argv[])
 {
     cout << "Début du programme '" << argv[0] << "'. Nombre de paramètres reçus : " << argc  << endl;
@@ -41,7 +32,7 @@ do{
     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") help();
+    //else if (words[0]=="help") diary.help(); now  into SQL
     else if (words[0]=="status") diary.status();
 
     else if (words[0]=="value") diary.var();
index b5c4851375e6256926eb17b8eb33dc3bc6439177..4b5aed5a9917d52fa03d0d31312e295308c996e8 100644 (file)
--- a/sqldb.cpp
+++ b/sqldb.cpp
@@ -286,10 +286,11 @@ bool sqlpg::alias(vector<string> a){
         length[argc]=t.size();
         binary[argc]=0;
     }
+    clog<<"if(inf=1) finish\n";
     for(int k=0; k<(argc+inf); k++){
         clog<<"value["<<k<<"]="<<value[k]<<" length="<<length[k]<<"\n";
     }
-    clog<<"if(inf=1) finish\n";
+
 
 
 
index 32ed9eeaa1535825721b8703c428ec7833331f77..b3d2affc6346511b4b1ef3db8ac589b8cc17f14e 100755 (executable)
@@ -9,10 +9,11 @@ word text
 create table IF NOT EXISTS alias(
 id serial primary key,
 cmd text,
+help text,
 argc integer,
 nom text,
 inf bit DEFAULT 0,
-CONSTRAINT uc_aliasID UNIQUE (nom, argc)
+CONSTRAINT uc_aliasID UNIQUE (nom, argc, inf)
 );
 
 create table IF NOT EXISTS raw (