Fossil SCM

In the "fossil forum new" command, add the --user-override option. Improve the help text.

drh 2026-11-05 13:36 UTC trunk
Commit 8e94450a9177caadef1288cd1f3788b6ff9a6bc3c07dc31c9bf64906868b59da
1 file changed +17 -13
+17 -13
--- src/forum.c
+++ src/forum.c
@@ -3420,22 +3420,24 @@
34203420
**
34213421
** Command-line access to the forum. Subcommands:
34223422
**
34233423
** > fossil forum new --title TITLE --content FILE ?OPTIONS?
34243424
**
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 "-".
34273427
**
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
34323434
** is one of "markdown" (the default), "wiki",
34333435
** 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
34373439
*/
34383440
void forum_cmd(void){
34393441
const char *zCmd;
34403442
size_t n;
34413443
if( g.argc<3 ){
@@ -3445,24 +3447,25 @@
34453447
n = strlen(zCmd);
34463448
if( strncmp(zCmd, "new", n)==0 ){
34473449
const char *zTitle = find_option("title", 0, 1);
34483450
const char *zMarkup = find_option("markup", 0, 1);
34493451
const char *zFile = find_option("content", 0, 1);
3452
+ const char *zDateOvrd = find_option("date-override", 0, 1);
34503453
const int bModerate = find_option("moderate", 0, 0)!=0;
34513454
const int bDryRun = find_option("dry-run", 0, 0)!=0;
34523455
const char *zMimetype;
3456
+ const char *zUserOvrd = find_option("user-override",0,1);
34533457
char *zDate;
34543458
char *zUuid;
34553459
Blob content, x, cksum, formatCheck, errMsg;
34563460
Manifest *pPost;
34573461
int nrid;
34583462
34593463
db_find_and_open_repository(0, 0);
34603464
verify_all_options();
34613465
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]");
34643467
}
34653468
if( zTitle==0 || zTitle[0]==0 ){
34663469
fossil_fatal("the --title option is required");
34673470
}
34683471
if( zFile==0 ){
@@ -3485,21 +3488,22 @@
34853488
}
34863489
if( fossil_all_whitespace(blob_str(&content)) ){
34873490
fossil_fatal("forum post content is empty");
34883491
}
34893492
user_select();
3493
+ if( zUserOvrd==0 ) zUserOvrd = login_name();
34903494
34913495
schema_forum();
34923496
blob_init(&x, 0, 0);
3493
- zDate = date_in_standard_format("now");
3497
+ zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
34943498
blob_appendf(&x, "D %s\n", zDate);
34953499
fossil_free(zDate);
34963500
blob_appendf(&x, "H %F\n", zTitle);
34973501
if( zMimetype ){
34983502
blob_appendf(&x, "N %F\n", zMimetype);
34993503
}
3500
- blob_appendf(&x, "U %F\n", login_name());
3504
+ blob_appendf(&x, "U %F\n", zUserOvrd);
35013505
blob_appendf(&x, "W %d\n%s\n", blob_size(&content), blob_str(&content));
35023506
blob_reset(&content);
35033507
md5sum_blob(&x, &cksum);
35043508
blob_appendf(&x, "Z %b\n", &cksum);
35053509
blob_reset(&cksum);
35063510
--- 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

Keyboard Shortcuts

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