Fossil SCM

changed fossil ticket fieldlist to fossil ticket list fields and added fossil ticket list reports

wolfgang 2010-10-07 09:11 wolfgangTicketCmd
Commit 3f06f272cd51f094a6c9ceca4177ce1e3a0e47bc
2 files changed +38 -6 +24 -9
+38 -6
--- src/report.c
+++ src/report.c
@@ -942,10 +942,41 @@
942942
sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2);
943943
sqlite3_set_authorizer(g.db, 0, 0);
944944
cgi_set_content_type("text/plain");
945945
}
946946
}
947
+
948
+/*
949
+** report number for full table ticket export
950
+*/
951
+static const char zFullTicketRptRn[] = "0";
952
+
953
+/*
954
+** report title for full table ticket export
955
+*/
956
+static const char zFullTicketRptTitle[] = "full ticket export";
957
+
958
+/*
959
+** show all reports, which can be used for ticket show.
960
+** Output is written to stdout as tab delimited table
961
+*/
962
+void rpt_list_reports(void){
963
+ Stmt q;
964
+ char const aRptOutFrmt[] = "%s\t%s\n";
965
+
966
+ printf("Available reports:\n");
967
+ printf(aRptOutFrmt,"report number","report title");
968
+ printf(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
969
+ db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
970
+ while( db_step(&q)==SQLITE_ROW ){
971
+ const char *zRn = db_column_text(&q, 0);
972
+ const char *zTitle = db_column_text(&q, 1);
973
+
974
+ printf(aRptOutFrmt,zRn,zTitle);
975
+ }
976
+ db_finalize(&q);
977
+}
947978
948979
/*
949980
** user defined separator used by ticket show command
950981
*/
951982
static const char *zSep = 0;
@@ -1028,22 +1059,22 @@
10281059
const char *zFilter,
10291060
tTktShowEncoding enc
10301061
){
10311062
Stmt q;
10321063
char *zSql;
1033
- char *zTitle;
1034
- char *zOwner;
1035
- char *zClrKey;
1064
+ const char *zTitle;
1065
+ const char *zOwner;
1066
+ const char *zClrKey;
10361067
char *zErr1 = 0;
10371068
char *zErr2 = 0;
10381069
int count = 0;
10391070
int rn;
10401071
1041
- if (!zRep) {
1042
- zTitle = "tickets";
1072
+ if (!zRep || !strcmp(zRep,zFullTicketRptRn) || !strcmp(zRep,zFullTicketRptTitle) ){
1073
+ zTitle = zFullTicketRptTitle;
10431074
zSql = "SELECT * FROM ticket";
1044
- zOwner = (char*)g.zLogin;
1075
+ zOwner = g.zLogin;
10451076
zClrKey = "";
10461077
}else{
10471078
rn = atoi(zRep);
10481079
if( rn ){
10491080
db_prepare(&q,
@@ -1052,10 +1083,11 @@
10521083
db_prepare(&q,
10531084
"SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep);
10541085
}
10551086
if( db_step(&q)!=SQLITE_ROW ){
10561087
db_finalize(&q);
1088
+ rpt_list_reports();
10571089
fossil_fatal("unkown report format(%s)!",zRep);
10581090
}
10591091
zTitle = db_column_malloc(&q, 0);
10601092
zSql = db_column_malloc(&q, 1);
10611093
zOwner = db_column_malloc(&q, 2);
10621094
--- src/report.c
+++ src/report.c
@@ -942,10 +942,41 @@
942 sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2);
943 sqlite3_set_authorizer(g.db, 0, 0);
944 cgi_set_content_type("text/plain");
945 }
946 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947
948 /*
949 ** user defined separator used by ticket show command
950 */
951 static const char *zSep = 0;
@@ -1028,22 +1059,22 @@
1028 const char *zFilter,
1029 tTktShowEncoding enc
1030 ){
1031 Stmt q;
1032 char *zSql;
1033 char *zTitle;
1034 char *zOwner;
1035 char *zClrKey;
1036 char *zErr1 = 0;
1037 char *zErr2 = 0;
1038 int count = 0;
1039 int rn;
1040
1041 if (!zRep) {
1042 zTitle = "tickets";
1043 zSql = "SELECT * FROM ticket";
1044 zOwner = (char*)g.zLogin;
1045 zClrKey = "";
1046 }else{
1047 rn = atoi(zRep);
1048 if( rn ){
1049 db_prepare(&q,
@@ -1052,10 +1083,11 @@
1052 db_prepare(&q,
1053 "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep);
1054 }
1055 if( db_step(&q)!=SQLITE_ROW ){
1056 db_finalize(&q);
 
1057 fossil_fatal("unkown report format(%s)!",zRep);
1058 }
1059 zTitle = db_column_malloc(&q, 0);
1060 zSql = db_column_malloc(&q, 1);
1061 zOwner = db_column_malloc(&q, 2);
1062
--- src/report.c
+++ src/report.c
@@ -942,10 +942,41 @@
942 sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2);
943 sqlite3_set_authorizer(g.db, 0, 0);
944 cgi_set_content_type("text/plain");
945 }
946 }
947
948 /*
949 ** report number for full table ticket export
950 */
951 static const char zFullTicketRptRn[] = "0";
952
953 /*
954 ** report title for full table ticket export
955 */
956 static const char zFullTicketRptTitle[] = "full ticket export";
957
958 /*
959 ** show all reports, which can be used for ticket show.
960 ** Output is written to stdout as tab delimited table
961 */
962 void rpt_list_reports(void){
963 Stmt q;
964 char const aRptOutFrmt[] = "%s\t%s\n";
965
966 printf("Available reports:\n");
967 printf(aRptOutFrmt,"report number","report title");
968 printf(aRptOutFrmt,zFullTicketRptRn,zFullTicketRptTitle);
969 db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
970 while( db_step(&q)==SQLITE_ROW ){
971 const char *zRn = db_column_text(&q, 0);
972 const char *zTitle = db_column_text(&q, 1);
973
974 printf(aRptOutFrmt,zRn,zTitle);
975 }
976 db_finalize(&q);
977 }
978
979 /*
980 ** user defined separator used by ticket show command
981 */
982 static const char *zSep = 0;
@@ -1028,22 +1059,22 @@
1059 const char *zFilter,
1060 tTktShowEncoding enc
1061 ){
1062 Stmt q;
1063 char *zSql;
1064 const char *zTitle;
1065 const char *zOwner;
1066 const char *zClrKey;
1067 char *zErr1 = 0;
1068 char *zErr2 = 0;
1069 int count = 0;
1070 int rn;
1071
1072 if (!zRep || !strcmp(zRep,zFullTicketRptRn) || !strcmp(zRep,zFullTicketRptTitle) ){
1073 zTitle = zFullTicketRptTitle;
1074 zSql = "SELECT * FROM ticket";
1075 zOwner = g.zLogin;
1076 zClrKey = "";
1077 }else{
1078 rn = atoi(zRep);
1079 if( rn ){
1080 db_prepare(&q,
@@ -1052,10 +1083,11 @@
1083 db_prepare(&q,
1084 "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep);
1085 }
1086 if( db_step(&q)!=SQLITE_ROW ){
1087 db_finalize(&q);
1088 rpt_list_reports();
1089 fossil_fatal("unkown report format(%s)!",zRep);
1090 }
1091 zTitle = db_column_malloc(&q, 0);
1092 zSql = db_column_malloc(&q, 1);
1093 zOwner = db_column_malloc(&q, 2);
1094
+24 -9
--- src/tkt.c
+++ src/tkt.c
@@ -863,14 +863,18 @@
863863
**
864864
** Instead of the report title its possible to use the report
865865
** number. Using the special report number 0 list all columns,
866866
** defined in the ticket table.
867867
**
868
-** %fossil ticket fieldlist
868
+** %fossil ticket list fields
869869
**
870870
** list all fields, defined for ticket in the fossil repository
871871
**
872
+** %fossil ticket list reports
873
+**
874
+** list all ticket reports, defined in the fossil repository
875
+**
872876
** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
873877
** %fossil ticket change TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
874878
**
875879
** change ticket identified by TICKETUUID and set the value of
876880
** field FIELD to VALUE. Valid field descriptions are:
@@ -910,18 +914,29 @@
910914
}else{
911915
n = strlen(g.argv[2]);
912916
if( n==1 && g.argv[2][0]=='s' ){
913917
/* set/show cannot be distinguished, so show the usage */
914918
usage("add|fieldlist|set|show");
915
- }else if( strncmp(g.argv[2],"fieldlist",n)==0 ){
916
- /* simply show all field names */
917
- int i;
918
-
919
- /* read all available ticket fields */
920
- getAllTicketFields();
921
- for(i=0; i<nField; i++){
922
- printf("%s\n",azField[i]);
919
+ }else if( strncmp(g.argv[2],"list",n)==0 ){
920
+ if( g.argc==3 ){
921
+ usage("list fields|reports");
922
+ }else{
923
+ n = strlen(g.argv[3]);
924
+ if( !strncmp(g.argv[3],"fields",n) ){
925
+ /* simply show all field names */
926
+ int i;
927
+
928
+ /* read all available ticket fields */
929
+ getAllTicketFields();
930
+ for(i=0; i<nField; i++){
931
+ printf("%s\n",azField[i]);
932
+ }
933
+ }else if( !strncmp(g.argv[3],"reports",n) ){
934
+ rpt_list_reports();
935
+ }else{
936
+ fossil_fatal("unknown ticket list option '%s'!",g.argv[3]);
937
+ }
923938
}
924939
}else{
925940
/* add a new ticket or set fields on existing tickets */
926941
tTktShowEncoding tktEncoding;
927942
928943
--- src/tkt.c
+++ src/tkt.c
@@ -863,14 +863,18 @@
863 **
864 ** Instead of the report title its possible to use the report
865 ** number. Using the special report number 0 list all columns,
866 ** defined in the ticket table.
867 **
868 ** %fossil ticket fieldlist
869 **
870 ** list all fields, defined for ticket in the fossil repository
871 **
 
 
 
 
872 ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
873 ** %fossil ticket change TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
874 **
875 ** change ticket identified by TICKETUUID and set the value of
876 ** field FIELD to VALUE. Valid field descriptions are:
@@ -910,18 +914,29 @@
910 }else{
911 n = strlen(g.argv[2]);
912 if( n==1 && g.argv[2][0]=='s' ){
913 /* set/show cannot be distinguished, so show the usage */
914 usage("add|fieldlist|set|show");
915 }else if( strncmp(g.argv[2],"fieldlist",n)==0 ){
916 /* simply show all field names */
917 int i;
918
919 /* read all available ticket fields */
920 getAllTicketFields();
921 for(i=0; i<nField; i++){
922 printf("%s\n",azField[i]);
 
 
 
 
 
 
 
 
 
 
 
923 }
924 }else{
925 /* add a new ticket or set fields on existing tickets */
926 tTktShowEncoding tktEncoding;
927
928
--- src/tkt.c
+++ src/tkt.c
@@ -863,14 +863,18 @@
863 **
864 ** Instead of the report title its possible to use the report
865 ** number. Using the special report number 0 list all columns,
866 ** defined in the ticket table.
867 **
868 ** %fossil ticket list fields
869 **
870 ** list all fields, defined for ticket in the fossil repository
871 **
872 ** %fossil ticket list reports
873 **
874 ** list all ticket reports, defined in the fossil repository
875 **
876 ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
877 ** %fossil ticket change TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote?
878 **
879 ** change ticket identified by TICKETUUID and set the value of
880 ** field FIELD to VALUE. Valid field descriptions are:
@@ -910,18 +914,29 @@
914 }else{
915 n = strlen(g.argv[2]);
916 if( n==1 && g.argv[2][0]=='s' ){
917 /* set/show cannot be distinguished, so show the usage */
918 usage("add|fieldlist|set|show");
919 }else if( strncmp(g.argv[2],"list",n)==0 ){
920 if( g.argc==3 ){
921 usage("list fields|reports");
922 }else{
923 n = strlen(g.argv[3]);
924 if( !strncmp(g.argv[3],"fields",n) ){
925 /* simply show all field names */
926 int i;
927
928 /* read all available ticket fields */
929 getAllTicketFields();
930 for(i=0; i<nField; i++){
931 printf("%s\n",azField[i]);
932 }
933 }else if( !strncmp(g.argv[3],"reports",n) ){
934 rpt_list_reports();
935 }else{
936 fossil_fatal("unknown ticket list option '%s'!",g.argv[3]);
937 }
938 }
939 }else{
940 /* add a new ticket or set fields on existing tickets */
941 tTktShowEncoding tktEncoding;
942
943

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button