# HG changeset patch # User Paul Boddie # Date 1709594161 -3600 # Node ID 458d4d392e81dcf9ade4f5648d03450d5925c063 # Parent e0f251ba3681bbb2c0f589bb15cbcb4e8ceb71f0 Added a help operation. diff -r e0f251ba3681 -r 458d4d392e81 fsaccess/fsaccess.c --- a/fsaccess/fsaccess.c Tue Mar 05 00:15:15 2024 +0100 +++ b/fsaccess/fsaccess.c Tue Mar 05 00:16:01 2024 +0100 @@ -27,14 +27,20 @@ -/* Help message. */ +/* Help messages. */ -char help_text[] = "\ +char command_help_text[] = "\ Usage: %s [ ] ...\n\ +"; + +char options_help_text[] = "\ \n\ File permission options:\n\ \n\ -m MASK Set mode/permissions mask for new directories\n\ +"; + +char operations_help_text[] = "\ \n\ Transfer operations:\n\ \n\ @@ -51,6 +57,7 @@ Script operations:\n\ \n\ script Read operations from a script file (or stdin)\n\ +\n\ Execution operations:\n\ \n\ file Send a file to a program\n\ @@ -61,11 +68,26 @@ wait Wait for a spawned program to finish\n\ "; + + +/* Show a help message appropriate to interactive use. */ + +static int show_help(int argc, char *argv[]) +{ + (void) argc; (void) argv; + + fprintf(stderr, operations_help_text); + return 0; +} + + + /* Operations exposed by the program. */ struct operation operations[] = { {"copy-in", copy_in}, {"file", file_to_program}, + {"help", show_help}, {"jobs", show_programs}, {"ls", list_objects}, {"mkdir", make_dirs}, @@ -101,7 +123,9 @@ if (num_args < 2) { - fprintf(stderr, help_text, argv[0]); + fprintf(stderr, command_help_text, argv[0]); + fprintf(stderr, options_help_text); + fprintf(stderr, operations_help_text); return 1; }