Fossil SCM
In the "fossil forum new" command, add the --user-override option. Improve the help text.
Commit
8e94450a9177caadef1288cd1f3788b6ff9a6bc3c07dc31c9bf64906868b59da
Parent
e129e114a551626…
1 file changed
+17
-13
+17
-13
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -3420,22 +3420,24 @@ | ||
| 3420 | 3420 | ** |
| 3421 | 3421 | ** Command-line access to the forum. Subcommands: |
| 3422 | 3422 | ** |
| 3423 | 3423 | ** > fossil forum new --title TITLE --content FILE ?OPTIONS? |
| 3424 | 3424 | ** |
| 3425 | -** Create a new forum thread. The text of the initial post is | |
| 3426 | -** read from FILE, or from standard input if FILE is "-". | |
| 3425 | +** Create a new forum thread. The text of the initial post is | |
| 3426 | +** read from FILE, or from standard input if FILE is "-". | |
| 3427 | 3427 | ** |
| 3428 | -** Options: | |
| 3429 | -** --content FILE Read the post content from FILE. Required. | |
| 3430 | -** --dry-run Do not commit changes. Just print the artifact. | |
| 3431 | -** --markup FORMAT The markup format of the content. FORMAT | |
| 3428 | +** Options: | |
| 3429 | +** --content FILE Read the post content from FILE. Required. | |
| 3430 | +** --date-override DATE Set the date and time of the post using | |
| 3431 | +** the format 'YYYY-MM-DD HH:MM:SS'. | |
| 3432 | +** --dry-run Do not commit. Just print the artifact. | |
| 3433 | +** --markup FORMAT The markup format of the content. FORMAT | |
| 3432 | 3434 | ** is one of "markdown" (the default), "wiki", |
| 3433 | 3435 | ** or "plaintext". |
| 3434 | -** --moderate Hold the new post pending moderation | |
| 3435 | -** --title TITLE Title of the new thread. Required. | |
| 3436 | -** -U|--user USER Post as USER instead of the default user | |
| 3436 | +** --moderate Hold the new post pending moderation | |
| 3437 | +** --title TITLE Title of the new thread. Required. | |
| 3438 | +** --user-override USER Post as USER instead of the default user | |
| 3437 | 3439 | */ |
| 3438 | 3440 | void forum_cmd(void){ |
| 3439 | 3441 | const char *zCmd; |
| 3440 | 3442 | size_t n; |
| 3441 | 3443 | if( g.argc<3 ){ |
| @@ -3445,24 +3447,25 @@ | ||
| 3445 | 3447 | n = strlen(zCmd); |
| 3446 | 3448 | if( strncmp(zCmd, "new", n)==0 ){ |
| 3447 | 3449 | const char *zTitle = find_option("title", 0, 1); |
| 3448 | 3450 | const char *zMarkup = find_option("markup", 0, 1); |
| 3449 | 3451 | const char *zFile = find_option("content", 0, 1); |
| 3452 | + const char *zDateOvrd = find_option("date-override", 0, 1); | |
| 3450 | 3453 | const int bModerate = find_option("moderate", 0, 0)!=0; |
| 3451 | 3454 | const int bDryRun = find_option("dry-run", 0, 0)!=0; |
| 3452 | 3455 | const char *zMimetype; |
| 3456 | + const char *zUserOvrd = find_option("user-override",0,1); | |
| 3453 | 3457 | char *zDate; |
| 3454 | 3458 | char *zUuid; |
| 3455 | 3459 | Blob content, x, cksum, formatCheck, errMsg; |
| 3456 | 3460 | Manifest *pPost; |
| 3457 | 3461 | int nrid; |
| 3458 | 3462 | |
| 3459 | 3463 | db_find_and_open_repository(0, 0); |
| 3460 | 3464 | verify_all_options(); |
| 3461 | 3465 | if( g.argc!=3 ){ |
| 3462 | - usage("new --title TITLE --content FILE [--markup FORMAT] " | |
| 3463 | - "[--moderate] [--user USER]"); | |
| 3466 | + usage("new --title TITLE --content FILE [OPTIONS]"); | |
| 3464 | 3467 | } |
| 3465 | 3468 | if( zTitle==0 || zTitle[0]==0 ){ |
| 3466 | 3469 | fossil_fatal("the --title option is required"); |
| 3467 | 3470 | } |
| 3468 | 3471 | if( zFile==0 ){ |
| @@ -3485,21 +3488,22 @@ | ||
| 3485 | 3488 | } |
| 3486 | 3489 | if( fossil_all_whitespace(blob_str(&content)) ){ |
| 3487 | 3490 | fossil_fatal("forum post content is empty"); |
| 3488 | 3491 | } |
| 3489 | 3492 | user_select(); |
| 3493 | + if( zUserOvrd==0 ) zUserOvrd = login_name(); | |
| 3490 | 3494 | |
| 3491 | 3495 | schema_forum(); |
| 3492 | 3496 | blob_init(&x, 0, 0); |
| 3493 | - zDate = date_in_standard_format("now"); | |
| 3497 | + zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); | |
| 3494 | 3498 | blob_appendf(&x, "D %s\n", zDate); |
| 3495 | 3499 | fossil_free(zDate); |
| 3496 | 3500 | blob_appendf(&x, "H %F\n", zTitle); |
| 3497 | 3501 | if( zMimetype ){ |
| 3498 | 3502 | blob_appendf(&x, "N %F\n", zMimetype); |
| 3499 | 3503 | } |
| 3500 | - blob_appendf(&x, "U %F\n", login_name()); | |
| 3504 | + blob_appendf(&x, "U %F\n", zUserOvrd); | |
| 3501 | 3505 | blob_appendf(&x, "W %d\n%s\n", blob_size(&content), blob_str(&content)); |
| 3502 | 3506 | blob_reset(&content); |
| 3503 | 3507 | md5sum_blob(&x, &cksum); |
| 3504 | 3508 | blob_appendf(&x, "Z %b\n", &cksum); |
| 3505 | 3509 | blob_reset(&cksum); |
| 3506 | 3510 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -3420,22 +3420,24 @@ | |
| 3420 | ** |
| 3421 | ** Command-line access to the forum. Subcommands: |
| 3422 | ** |
| 3423 | ** > fossil forum new --title TITLE --content FILE ?OPTIONS? |
| 3424 | ** |
| 3425 | ** Create a new forum thread. The text of the initial post is |
| 3426 | ** read from FILE, or from standard input if FILE is "-". |
| 3427 | ** |
| 3428 | ** Options: |
| 3429 | ** --content FILE Read the post content from FILE. Required. |
| 3430 | ** --dry-run Do not commit changes. Just print the artifact. |
| 3431 | ** --markup FORMAT The markup format of the content. FORMAT |
| 3432 | ** is one of "markdown" (the default), "wiki", |
| 3433 | ** or "plaintext". |
| 3434 | ** --moderate Hold the new post pending moderation |
| 3435 | ** --title TITLE Title of the new thread. Required. |
| 3436 | ** -U|--user USER Post as USER instead of the default user |
| 3437 | */ |
| 3438 | void forum_cmd(void){ |
| 3439 | const char *zCmd; |
| 3440 | size_t n; |
| 3441 | if( g.argc<3 ){ |
| @@ -3445,24 +3447,25 @@ | |
| 3445 | n = strlen(zCmd); |
| 3446 | if( strncmp(zCmd, "new", n)==0 ){ |
| 3447 | const char *zTitle = find_option("title", 0, 1); |
| 3448 | const char *zMarkup = find_option("markup", 0, 1); |
| 3449 | const char *zFile = find_option("content", 0, 1); |
| 3450 | const int bModerate = find_option("moderate", 0, 0)!=0; |
| 3451 | const int bDryRun = find_option("dry-run", 0, 0)!=0; |
| 3452 | const char *zMimetype; |
| 3453 | char *zDate; |
| 3454 | char *zUuid; |
| 3455 | Blob content, x, cksum, formatCheck, errMsg; |
| 3456 | Manifest *pPost; |
| 3457 | int nrid; |
| 3458 | |
| 3459 | db_find_and_open_repository(0, 0); |
| 3460 | verify_all_options(); |
| 3461 | if( g.argc!=3 ){ |
| 3462 | usage("new --title TITLE --content FILE [--markup FORMAT] " |
| 3463 | "[--moderate] [--user USER]"); |
| 3464 | } |
| 3465 | if( zTitle==0 || zTitle[0]==0 ){ |
| 3466 | fossil_fatal("the --title option is required"); |
| 3467 | } |
| 3468 | if( zFile==0 ){ |
| @@ -3485,21 +3488,22 @@ | |
| 3485 | } |
| 3486 | if( fossil_all_whitespace(blob_str(&content)) ){ |
| 3487 | fossil_fatal("forum post content is empty"); |
| 3488 | } |
| 3489 | user_select(); |
| 3490 | |
| 3491 | schema_forum(); |
| 3492 | blob_init(&x, 0, 0); |
| 3493 | zDate = date_in_standard_format("now"); |
| 3494 | blob_appendf(&x, "D %s\n", zDate); |
| 3495 | fossil_free(zDate); |
| 3496 | blob_appendf(&x, "H %F\n", zTitle); |
| 3497 | if( zMimetype ){ |
| 3498 | blob_appendf(&x, "N %F\n", zMimetype); |
| 3499 | } |
| 3500 | blob_appendf(&x, "U %F\n", login_name()); |
| 3501 | blob_appendf(&x, "W %d\n%s\n", blob_size(&content), blob_str(&content)); |
| 3502 | blob_reset(&content); |
| 3503 | md5sum_blob(&x, &cksum); |
| 3504 | blob_appendf(&x, "Z %b\n", &cksum); |
| 3505 | blob_reset(&cksum); |
| 3506 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -3420,22 +3420,24 @@ | |
| 3420 | ** |
| 3421 | ** Command-line access to the forum. Subcommands: |
| 3422 | ** |
| 3423 | ** > fossil forum new --title TITLE --content FILE ?OPTIONS? |
| 3424 | ** |
| 3425 | ** Create a new forum thread. The text of the initial post is |
| 3426 | ** read from FILE, or from standard input if FILE is "-". |
| 3427 | ** |
| 3428 | ** Options: |
| 3429 | ** --content FILE Read the post content from FILE. Required. |
| 3430 | ** --date-override DATE Set the date and time of the post using |
| 3431 | ** the format 'YYYY-MM-DD HH:MM:SS'. |
| 3432 | ** --dry-run Do not commit. Just print the artifact. |
| 3433 | ** --markup FORMAT The markup format of the content. FORMAT |
| 3434 | ** is one of "markdown" (the default), "wiki", |
| 3435 | ** or "plaintext". |
| 3436 | ** --moderate Hold the new post pending moderation |
| 3437 | ** --title TITLE Title of the new thread. Required. |
| 3438 | ** --user-override USER Post as USER instead of the default user |
| 3439 | */ |
| 3440 | void forum_cmd(void){ |
| 3441 | const char *zCmd; |
| 3442 | size_t n; |
| 3443 | if( g.argc<3 ){ |
| @@ -3445,24 +3447,25 @@ | |
| 3447 | n = strlen(zCmd); |
| 3448 | if( strncmp(zCmd, "new", n)==0 ){ |
| 3449 | const char *zTitle = find_option("title", 0, 1); |
| 3450 | const char *zMarkup = find_option("markup", 0, 1); |
| 3451 | const char *zFile = find_option("content", 0, 1); |
| 3452 | const char *zDateOvrd = find_option("date-override", 0, 1); |
| 3453 | const int bModerate = find_option("moderate", 0, 0)!=0; |
| 3454 | const int bDryRun = find_option("dry-run", 0, 0)!=0; |
| 3455 | const char *zMimetype; |
| 3456 | const char *zUserOvrd = find_option("user-override",0,1); |
| 3457 | char *zDate; |
| 3458 | char *zUuid; |
| 3459 | Blob content, x, cksum, formatCheck, errMsg; |
| 3460 | Manifest *pPost; |
| 3461 | int nrid; |
| 3462 | |
| 3463 | db_find_and_open_repository(0, 0); |
| 3464 | verify_all_options(); |
| 3465 | if( g.argc!=3 ){ |
| 3466 | usage("new --title TITLE --content FILE [OPTIONS]"); |
| 3467 | } |
| 3468 | if( zTitle==0 || zTitle[0]==0 ){ |
| 3469 | fossil_fatal("the --title option is required"); |
| 3470 | } |
| 3471 | if( zFile==0 ){ |
| @@ -3485,21 +3488,22 @@ | |
| 3488 | } |
| 3489 | if( fossil_all_whitespace(blob_str(&content)) ){ |
| 3490 | fossil_fatal("forum post content is empty"); |
| 3491 | } |
| 3492 | user_select(); |
| 3493 | if( zUserOvrd==0 ) zUserOvrd = login_name(); |
| 3494 | |
| 3495 | schema_forum(); |
| 3496 | blob_init(&x, 0, 0); |
| 3497 | zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); |
| 3498 | blob_appendf(&x, "D %s\n", zDate); |
| 3499 | fossil_free(zDate); |
| 3500 | blob_appendf(&x, "H %F\n", zTitle); |
| 3501 | if( zMimetype ){ |
| 3502 | blob_appendf(&x, "N %F\n", zMimetype); |
| 3503 | } |
| 3504 | blob_appendf(&x, "U %F\n", zUserOvrd); |
| 3505 | blob_appendf(&x, "W %d\n%s\n", blob_size(&content), blob_str(&content)); |
| 3506 | blob_reset(&content); |
| 3507 | md5sum_blob(&x, &cksum); |
| 3508 | blob_appendf(&x, "Z %b\n", &cksum); |
| 3509 | blob_reset(&cksum); |
| 3510 |