Fossil SCM
changed fossil ticket fieldlist to fossil ticket list fields and added fossil ticket list reports
Commit
3f06f272cd51f094a6c9ceca4177ce1e3a0e47bc
Parent
3c6f67fc811cfcb…
2 files changed
+38
-6
+24
-9
+38
-6
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -942,10 +942,41 @@ | ||
| 942 | 942 | sqlite3_exec(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 943 | 943 | sqlite3_set_authorizer(g.db, 0, 0); |
| 944 | 944 | cgi_set_content_type("text/plain"); |
| 945 | 945 | } |
| 946 | 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 | +} | |
| 947 | 978 | |
| 948 | 979 | /* |
| 949 | 980 | ** user defined separator used by ticket show command |
| 950 | 981 | */ |
| 951 | 982 | static const char *zSep = 0; |
| @@ -1028,22 +1059,22 @@ | ||
| 1028 | 1059 | const char *zFilter, |
| 1029 | 1060 | tTktShowEncoding enc |
| 1030 | 1061 | ){ |
| 1031 | 1062 | Stmt q; |
| 1032 | 1063 | char *zSql; |
| 1033 | - char *zTitle; | |
| 1034 | - char *zOwner; | |
| 1035 | - char *zClrKey; | |
| 1064 | + const char *zTitle; | |
| 1065 | + const char *zOwner; | |
| 1066 | + const char *zClrKey; | |
| 1036 | 1067 | char *zErr1 = 0; |
| 1037 | 1068 | char *zErr2 = 0; |
| 1038 | 1069 | int count = 0; |
| 1039 | 1070 | int rn; |
| 1040 | 1071 | |
| 1041 | - if (!zRep) { | |
| 1042 | - zTitle = "tickets"; | |
| 1072 | + if (!zRep || !strcmp(zRep,zFullTicketRptRn) || !strcmp(zRep,zFullTicketRptTitle) ){ | |
| 1073 | + zTitle = zFullTicketRptTitle; | |
| 1043 | 1074 | zSql = "SELECT * FROM ticket"; |
| 1044 | - zOwner = (char*)g.zLogin; | |
| 1075 | + zOwner = g.zLogin; | |
| 1045 | 1076 | zClrKey = ""; |
| 1046 | 1077 | }else{ |
| 1047 | 1078 | rn = atoi(zRep); |
| 1048 | 1079 | if( rn ){ |
| 1049 | 1080 | db_prepare(&q, |
| @@ -1052,10 +1083,11 @@ | ||
| 1052 | 1083 | db_prepare(&q, |
| 1053 | 1084 | "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep); |
| 1054 | 1085 | } |
| 1055 | 1086 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1056 | 1087 | db_finalize(&q); |
| 1088 | + rpt_list_reports(); | |
| 1057 | 1089 | fossil_fatal("unkown report format(%s)!",zRep); |
| 1058 | 1090 | } |
| 1059 | 1091 | zTitle = db_column_malloc(&q, 0); |
| 1060 | 1092 | zSql = db_column_malloc(&q, 1); |
| 1061 | 1093 | zOwner = db_column_malloc(&q, 2); |
| 1062 | 1094 |
| --- 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 @@ | ||
| 863 | 863 | ** |
| 864 | 864 | ** Instead of the report title its possible to use the report |
| 865 | 865 | ** number. Using the special report number 0 list all columns, |
| 866 | 866 | ** defined in the ticket table. |
| 867 | 867 | ** |
| 868 | -** %fossil ticket fieldlist | |
| 868 | +** %fossil ticket list fields | |
| 869 | 869 | ** |
| 870 | 870 | ** list all fields, defined for ticket in the fossil repository |
| 871 | 871 | ** |
| 872 | +** %fossil ticket list reports | |
| 873 | +** | |
| 874 | +** list all ticket reports, defined in the fossil repository | |
| 875 | +** | |
| 872 | 876 | ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote? |
| 873 | 877 | ** %fossil ticket change TICKETUUID FIELD VALUE ?FIELD VALUE .. ? ?-q|--quote? |
| 874 | 878 | ** |
| 875 | 879 | ** change ticket identified by TICKETUUID and set the value of |
| 876 | 880 | ** field FIELD to VALUE. Valid field descriptions are: |
| @@ -910,18 +914,29 @@ | ||
| 910 | 914 | }else{ |
| 911 | 915 | n = strlen(g.argv[2]); |
| 912 | 916 | if( n==1 && g.argv[2][0]=='s' ){ |
| 913 | 917 | /* set/show cannot be distinguished, so show the usage */ |
| 914 | 918 | 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 | + } | |
| 923 | 938 | } |
| 924 | 939 | }else{ |
| 925 | 940 | /* add a new ticket or set fields on existing tickets */ |
| 926 | 941 | tTktShowEncoding tktEncoding; |
| 927 | 942 | |
| 928 | 943 |
| --- 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 |