Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 00d23a2 in mainline


Ignore:
Timestamp:
2017-12-22T13:43:27Z (4 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master
Children:
e23b87b
Parents:
b10a434
git-author:
Petr Mánek <petr.manek@…> (2017-12-22 13:43:20)
git-committer:
Petr Mánek <petr.manek@…> (2017-12-22 13:43:27)
Message:

tmon: finalize usage string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/main.c

    rb10a434 r00d23a2  
    3838#include "commands.h"
    3939
    40 #define NAME "tmon"
     40#define NAME   "tmon"
     41#define INDENT "      "
    4142
    42 typedef struct {
     43typedef struct tmon_cmd {
    4344        const char *name;
    4445        const char *description;
    4546        int (*action)(int, char **);
    46 } usb_diag_cmd_t;
     47} tmon_cmd_t;
    4748
    48 static usb_diag_cmd_t commands[] = {
     49static tmon_cmd_t commands[] = {
    4950        {
    5051                .name = "list",
     
    5455        {
    5556                .name = "test-intr-in",
    56                 .description = "Read from interrupt in endpoints as fast as possible.",
     57                .description = "Read from interrupt endpoint as fast as possible.",
    5758                .action = tmon_burst_intr_in,
    5859        },
    5960        {
    6061                .name = "test-intr-out",
    61                 .description = "Write to interrupt out endpoints as fast as possible.",
     62                .description = "Write to interrupt endpoint as fast as possible.",
    6263                .action = tmon_burst_intr_out,
    6364        },
    6465        {
    6566                .name = "test-bulk-in",
    66                 .description = "Read from bulk in endpoints as fast as possible.",
     67                .description = "Read from bulk endpoint as fast as possible.",
    6768                .action = tmon_burst_bulk_in,
    6869        },
    6970        {
    7071                .name = "test-bulk-out",
    71                 .description = "Write to bulk out endpoints as fast as possible.",
     72                .description = "Write to bulk endpoint as fast as possible.",
    7273                .action = tmon_burst_bulk_out,
    7374        },
    7475        {
    7576                .name = "test-isoch-in",
    76                 .description = "Read from isochronous in endpoints as fast as possible.",
     77                .description = "Read from isochronous endpoint as fast as possible.",
    7778                .action = tmon_burst_isoch_in,
    7879        },
    7980        {
    8081                .name = "test-isoch-out",
    81                 .description = "Write to isochronouse out endpoints as fast as possible.",
     82                .description = "Write to isochronous endpoint as fast as possible.",
    8283                .action = tmon_burst_isoch_out,
    8384        },
     85        { /* NULL-terminated */ }
     86};
     87
     88typedef struct tmon_opt {
     89        const char *long_name;
     90        char short_name;
     91        const char *description;
     92} tmon_opt_t;
     93
     94static tmon_opt_t options[] = {
    8495        {
    85                 .name = NULL
    86         }
     96                .long_name = "cycles",
     97                .short_name = 'n',
     98                .description = "Set the number of read/write cycles."
     99        },
     100        {
     101                .long_name = "size",
     102                .short_name = 's',
     103                .description = "Set the data size transferred in a single cycle."
     104        },
     105        { /* NULL-terminated */ }
    87106};
    88107
    89108static void print_usage(char *app_name)
    90109{
    91         printf(NAME ": benchmark USB diagnostic device\n\n");
     110        puts(NAME ": benchmark USB diagnostic device\n\n");
     111        printf("Usage: %s command [device] [options]\n\n", app_name);
    92112
    93         printf("Usage: %s command [device] [options]\n", app_name);
    94         printf("Available commands:\n");
    95113        for (int i = 0; commands[i].name; ++i) {
    96                 printf("      %s - %s\n", commands[i].name, commands[i].description);
     114                printf(INDENT "%s - %s\n", commands[i].name, commands[i].description);
    97115        }
    98116
    99         // TODO: Print options.
     117        puts("\n");
     118        for (int i = 0; options[i].long_name; ++i) {
     119                printf(INDENT "-%c --%s\n" INDENT INDENT "%s\n", options[i].short_name, options[i].long_name, options[i].description);
     120        }
    100121
    101         printf("\nIf no device is specified, the first device is used provided that no other device is connected.\n\n");
     122        puts("\nIf no device is specified, the first device is used provided that it is the only one connected. Otherwise, the command fails.\n\n");
    102123}
    103124
     
    105126{
    106127        // Find a command to execute.
    107         usb_diag_cmd_t *cmd = NULL;
     128        tmon_cmd_t *cmd = NULL;
    108129        for (int i = 0; argc > 1 && commands[i].name; ++i) {
    109130                if (str_cmp(argv[1], commands[i].name) == 0) {
Note: See TracChangeset for help on using the changeset viewer.