6ce8e2a49e047984065d64c16b34219c8587d2ad markd Fri Mar 7 13:37:21 2025 -0800 change tabFmt to require input file and generate help message if no arguments are given diff --git src/utils/tabFmt/tabFmt.c src/utils/tabFmt/tabFmt.c index 05bc22275eb..f7c3a488a24 100644 --- src/utils/tabFmt/tabFmt.c +++ src/utils/tabFmt/tabFmt.c @@ -1,27 +1,27 @@ /* tabFmt - Format a tab-seperated file for human readability. */ #include "common.h" #include "linefile.h" #include "options.h" void usage() /* Explain usage and exit. */ { errAbort( "tabFmt - Format a tab-seperated file for human readability\n" "Usage:\n" - " tabFmt [options] [inFile] [outFile]\n" + " tabFmt [options] inFile [outFile]\n" "\n" "Options:\n" " -right - right-justify\n" " -numRight - right-justify numeric appearing columns (text header allowed)\n" " -passNoTab - pass through lines with no tabs without including them in the\n" " formatting\n" " -h,-help - help\n" ); } /* Command line validation table. */ static struct optionSpec optionSpecs[] = { {"right", OPTION_BOOLEAN}, {"numRight", OPTION_BOOLEAN}, {"passNoTab", OPTION_BOOLEAN}, @@ -250,25 +250,24 @@ FILE *outFh = mustOpen(outFile, "w"); writeLines(ti, lines, outFh); carefulClose(&outFh); slFreeList(&lines); tblInfoFree(&ti); } int main(int argc, char **argv) /* Process command line. */ { optionInit(&argc, argv, optionSpecs); if (optionExists("h") || optionExists("help")) usage(); -if (argc > 3) +if ((argc < 2) || (argc > 3)) usage(); clRight = optionExists("right"); clNumRight = optionExists("numRight"); clPassNoTab = optionExists("passNoTab"); -tabFmt(((argc >= 2) ? argv[1] : "stdin"), - ((argc >= 3) ? argv[2] : "stdout")); +tabFmt(argv[1], ((argc >= 3) ? argv[2] : "stdout")); return 0; }