Fossil SCM
fossil ticket show may use report name instead of report number
Commit
63d91f0b87b0f68a014c1072e3c2c6d69a8975eb
Parent
1e1512f51053fa9…
2 files changed
+11
-5
+6
-4
+11
-5
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -998,26 +998,32 @@ | ||
| 998 | 998 | /* |
| 999 | 999 | ** Generate a report. The rn query parameter is the report number. |
| 1000 | 1000 | ** The output is written to stdout as flat file. The zFilter paramater |
| 1001 | 1001 | ** is a full WHERE-condition. |
| 1002 | 1002 | */ |
| 1003 | -void rptshow( int rn, const char *zSep, const char *zFilter ){ | |
| 1003 | +void rptshow( const char *zRep, const char *zSep, const char *zFilter ){ | |
| 1004 | 1004 | Stmt q; |
| 1005 | 1005 | char *zSql; |
| 1006 | 1006 | char *zTitle; |
| 1007 | 1007 | char *zOwner; |
| 1008 | 1008 | char *zClrKey; |
| 1009 | 1009 | char *zErr1 = 0; |
| 1010 | 1010 | char *zErr2 = 0; |
| 1011 | 1011 | int count = 0; |
| 1012 | + int rn; | |
| 1012 | 1013 | |
| 1013 | - /* view_add_functions(tabs); */ | |
| 1014 | - db_prepare(&q, | |
| 1015 | - "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); | |
| 1014 | + rn = atoi(zRep); | |
| 1015 | + if( rn ){ | |
| 1016 | + db_prepare(&q, | |
| 1017 | + "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); | |
| 1018 | + }else{ | |
| 1019 | + db_prepare(&q, | |
| 1020 | + "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep); | |
| 1021 | + } | |
| 1016 | 1022 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1017 | 1023 | db_finalize(&q); |
| 1018 | - fossil_fatal("unkown report format(%d)!",rn); | |
| 1024 | + fossil_fatal("unkown report format(%s)!",zRep); | |
| 1019 | 1025 | } |
| 1020 | 1026 | zTitle = db_column_malloc(&q, 0); |
| 1021 | 1027 | zSql = db_column_malloc(&q, 1); |
| 1022 | 1028 | zOwner = db_column_malloc(&q, 2); |
| 1023 | 1029 | zClrKey = db_column_malloc(&q, 3); |
| 1024 | 1030 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -998,26 +998,32 @@ | |
| 998 | /* |
| 999 | ** Generate a report. The rn query parameter is the report number. |
| 1000 | ** The output is written to stdout as flat file. The zFilter paramater |
| 1001 | ** is a full WHERE-condition. |
| 1002 | */ |
| 1003 | void rptshow( int rn, const char *zSep, const char *zFilter ){ |
| 1004 | Stmt q; |
| 1005 | char *zSql; |
| 1006 | char *zTitle; |
| 1007 | char *zOwner; |
| 1008 | char *zClrKey; |
| 1009 | char *zErr1 = 0; |
| 1010 | char *zErr2 = 0; |
| 1011 | int count = 0; |
| 1012 | |
| 1013 | /* view_add_functions(tabs); */ |
| 1014 | db_prepare(&q, |
| 1015 | "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); |
| 1016 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1017 | db_finalize(&q); |
| 1018 | fossil_fatal("unkown report format(%d)!",rn); |
| 1019 | } |
| 1020 | zTitle = db_column_malloc(&q, 0); |
| 1021 | zSql = db_column_malloc(&q, 1); |
| 1022 | zOwner = db_column_malloc(&q, 2); |
| 1023 | zClrKey = db_column_malloc(&q, 3); |
| 1024 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -998,26 +998,32 @@ | |
| 998 | /* |
| 999 | ** Generate a report. The rn query parameter is the report number. |
| 1000 | ** The output is written to stdout as flat file. The zFilter paramater |
| 1001 | ** is a full WHERE-condition. |
| 1002 | */ |
| 1003 | void rptshow( const char *zRep, const char *zSep, const char *zFilter ){ |
| 1004 | Stmt q; |
| 1005 | char *zSql; |
| 1006 | char *zTitle; |
| 1007 | char *zOwner; |
| 1008 | char *zClrKey; |
| 1009 | char *zErr1 = 0; |
| 1010 | char *zErr2 = 0; |
| 1011 | int count = 0; |
| 1012 | int rn; |
| 1013 | |
| 1014 | rn = atoi(zRep); |
| 1015 | if( rn ){ |
| 1016 | db_prepare(&q, |
| 1017 | "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn); |
| 1018 | }else{ |
| 1019 | db_prepare(&q, |
| 1020 | "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE title='%s'", zRep); |
| 1021 | } |
| 1022 | if( db_step(&q)!=SQLITE_ROW ){ |
| 1023 | db_finalize(&q); |
| 1024 | fossil_fatal("unkown report format(%s)!",zRep); |
| 1025 | } |
| 1026 | zTitle = db_column_malloc(&q, 0); |
| 1027 | zSql = db_column_malloc(&q, 1); |
| 1028 | zOwner = db_column_malloc(&q, 2); |
| 1029 | zClrKey = db_column_malloc(&q, 3); |
| 1030 |
+6
-4
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -837,20 +837,22 @@ | ||
| 837 | 837 | ** COMMAND: ticket |
| 838 | 838 | ** Usage: %fossil ticket SUBCOMMAND ... |
| 839 | 839 | ** |
| 840 | 840 | ** Run various subcommands to control tickets |
| 841 | 841 | ** |
| 842 | -** %fossil ticket show REPORTNR ?TICKETFILTER? ?-l|--limit LIMITCHAR? | |
| 842 | +** %fossil ticket show (REPORTNR|REPORTTITLE) ?TICKETFILTER? ?-l|--limit LIMITCHAR? | |
| 843 | 843 | ** |
| 844 | 844 | ** Run the the ticket report, identified by the report number |
| 845 | 845 | ** used in the gui. The data is written as flat file on stdout, |
| 846 | 846 | ** using "," as separator. The seperator "," can be changed using |
| 847 | 847 | ** the -l or --limit option. |
| 848 | 848 | ** If TICKETFILTER is given on the commandline, the query is |
| 849 | 849 | ** limited with a new WHERE-condition. |
| 850 | 850 | ** example: Report lists a column # with the uuid |
| 851 | 851 | ** TICKETFILTER may be [#]='uuuuuuuuu' |
| 852 | +** Instead of the report number its possible to use the report | |
| 853 | +** title (please quote the string, if it contains whitespace). | |
| 852 | 854 | ** |
| 853 | 855 | ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ? |
| 854 | 856 | ** |
| 855 | 857 | ** change ticket identified by TICKETUUID and set the value of |
| 856 | 858 | ** field FIELD to VALUE. Valid field descriptions are: |
| @@ -890,21 +892,21 @@ | ||
| 890 | 892 | usage("ticket show|set|add"); |
| 891 | 893 | }else if( strncmp(g.argv[2],"show",n)==0 ){ |
| 892 | 894 | if( g.argc==3 ){ |
| 893 | 895 | usage("ticket show REPORTNR"); |
| 894 | 896 | }else{ |
| 895 | - int rn; | |
| 897 | + const char *zRep = 0; | |
| 896 | 898 | const char *zSep = 0; |
| 897 | 899 | const char *zFilterUuid = 0; |
| 898 | 900 | |
| 899 | 901 | zSep = find_option("limit","l",1); |
| 900 | - rn = atoi(g.argv[3]); | |
| 902 | + zRep = g.argv[3]; | |
| 901 | 903 | if( g.argc>4 ){ |
| 902 | 904 | zFilterUuid = g.argv[4]; |
| 903 | 905 | } |
| 904 | 906 | |
| 905 | - rptshow( rn, zSep, zFilterUuid ); | |
| 907 | + rptshow( zRep, zSep, zFilterUuid ); | |
| 906 | 908 | |
| 907 | 909 | } |
| 908 | 910 | }else{ |
| 909 | 911 | enum { set,add,err } eCmd = err; |
| 910 | 912 | int i; |
| 911 | 913 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -837,20 +837,22 @@ | |
| 837 | ** COMMAND: ticket |
| 838 | ** Usage: %fossil ticket SUBCOMMAND ... |
| 839 | ** |
| 840 | ** Run various subcommands to control tickets |
| 841 | ** |
| 842 | ** %fossil ticket show REPORTNR ?TICKETFILTER? ?-l|--limit LIMITCHAR? |
| 843 | ** |
| 844 | ** Run the the ticket report, identified by the report number |
| 845 | ** used in the gui. The data is written as flat file on stdout, |
| 846 | ** using "," as separator. The seperator "," can be changed using |
| 847 | ** the -l or --limit option. |
| 848 | ** If TICKETFILTER is given on the commandline, the query is |
| 849 | ** limited with a new WHERE-condition. |
| 850 | ** example: Report lists a column # with the uuid |
| 851 | ** TICKETFILTER may be [#]='uuuuuuuuu' |
| 852 | ** |
| 853 | ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ? |
| 854 | ** |
| 855 | ** change ticket identified by TICKETUUID and set the value of |
| 856 | ** field FIELD to VALUE. Valid field descriptions are: |
| @@ -890,21 +892,21 @@ | |
| 890 | usage("ticket show|set|add"); |
| 891 | }else if( strncmp(g.argv[2],"show",n)==0 ){ |
| 892 | if( g.argc==3 ){ |
| 893 | usage("ticket show REPORTNR"); |
| 894 | }else{ |
| 895 | int rn; |
| 896 | const char *zSep = 0; |
| 897 | const char *zFilterUuid = 0; |
| 898 | |
| 899 | zSep = find_option("limit","l",1); |
| 900 | rn = atoi(g.argv[3]); |
| 901 | if( g.argc>4 ){ |
| 902 | zFilterUuid = g.argv[4]; |
| 903 | } |
| 904 | |
| 905 | rptshow( rn, zSep, zFilterUuid ); |
| 906 | |
| 907 | } |
| 908 | }else{ |
| 909 | enum { set,add,err } eCmd = err; |
| 910 | int i; |
| 911 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -837,20 +837,22 @@ | |
| 837 | ** COMMAND: ticket |
| 838 | ** Usage: %fossil ticket SUBCOMMAND ... |
| 839 | ** |
| 840 | ** Run various subcommands to control tickets |
| 841 | ** |
| 842 | ** %fossil ticket show (REPORTNR|REPORTTITLE) ?TICKETFILTER? ?-l|--limit LIMITCHAR? |
| 843 | ** |
| 844 | ** Run the the ticket report, identified by the report number |
| 845 | ** used in the gui. The data is written as flat file on stdout, |
| 846 | ** using "," as separator. The seperator "," can be changed using |
| 847 | ** the -l or --limit option. |
| 848 | ** If TICKETFILTER is given on the commandline, the query is |
| 849 | ** limited with a new WHERE-condition. |
| 850 | ** example: Report lists a column # with the uuid |
| 851 | ** TICKETFILTER may be [#]='uuuuuuuuu' |
| 852 | ** Instead of the report number its possible to use the report |
| 853 | ** title (please quote the string, if it contains whitespace). |
| 854 | ** |
| 855 | ** %fossil ticket set TICKETUUID FIELD VALUE ?FIELD VALUE ... ? |
| 856 | ** |
| 857 | ** change ticket identified by TICKETUUID and set the value of |
| 858 | ** field FIELD to VALUE. Valid field descriptions are: |
| @@ -890,21 +892,21 @@ | |
| 892 | usage("ticket show|set|add"); |
| 893 | }else if( strncmp(g.argv[2],"show",n)==0 ){ |
| 894 | if( g.argc==3 ){ |
| 895 | usage("ticket show REPORTNR"); |
| 896 | }else{ |
| 897 | const char *zRep = 0; |
| 898 | const char *zSep = 0; |
| 899 | const char *zFilterUuid = 0; |
| 900 | |
| 901 | zSep = find_option("limit","l",1); |
| 902 | zRep = g.argv[3]; |
| 903 | if( g.argc>4 ){ |
| 904 | zFilterUuid = g.argv[4]; |
| 905 | } |
| 906 | |
| 907 | rptshow( zRep, zSep, zFilterUuid ); |
| 908 | |
| 909 | } |
| 910 | }else{ |
| 911 | enum { set,add,err } eCmd = err; |
| 912 | int i; |
| 913 |