Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions man/scount.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ scount \- A tool to count logical lines of code and other metrics
[\fB\-\-verbose\fR]
[\fB\-\-annotate\-counts\fR]
[\fB\-l\fR|\fB\-\-lines\fR]
[\fB\-\-show\-files\fR|\fB\-\-show\-all\-files\fR]
[\fB\-\-stop\-on\-error\fR]
[\fB\-\-strict\fR]
.I <PATH>
Expand Down Expand Up @@ -61,6 +62,16 @@ Compute and display only line-specific metrics.
.br
This includes logical and physical lines.
.TP
.B \-\-show\-files
Show a table of individual files in the result.
.br
For large results, a condensed view is shown.
.TP
.B \-\-show\-all\-files
Show a table of all individual files in the result.
.br
All files are listed regardless of how many there are.
.TP
.B \-\-stop\-on\-error
Stop the processing on the first encountered error,
even for non\-critical errors. Without this option (the default),
Expand Down
12 changes: 11 additions & 1 deletion src/scount/c/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ AppArgs parseArgs(int argc, char** argv) {
} else if (strcmp(argv[i], "--lines") == 0
|| strcmp(argv[i], "-l") == 0) {
args.linesOnly = true;
} else if (strcmp(argv[i], "--show-files") == 0) {
args.showFiles = true;
} else if (strcmp(argv[i], "--show-all-files") == 0) {
args.showAllFiles = true;
} else if (strcmp(argv[i], "--stop-on-error") == 0) {
args.stopOnError = true;
} else if (strcmp(argv[i], "--strict") == 0) {
Expand Down Expand Up @@ -76,7 +80,7 @@ AppArgs parseArgs(int argc, char** argv) {
}

void showUsage(void) {
logI("Usage: scount [--verbose] [--annotate-counts] [-l|--lines] [--stop-on-error] [--strict] <PATH>");
logI("Usage: scount [options] <PATH>");
}

void showVersion(AppArgs args) {
Expand Down Expand Up @@ -119,6 +123,12 @@ void showHelpText(void) {
logI(" [-l|--lines] Compute and display only line-specific metrics.");
logI(" This includes logical and physical lines.");
logI(" ");
logI(" [--show-files] Show a table of individual files in the result.");
logI(" For large results, a condensed view is shown.");
logI(" ");
logI(" [--show-all-files] Show a table of all individual files in the result.");
logI(" All files are listed without any limitation.");
logI(" ");
logI(" [--stop-on-error] Stop processing immediately when an error is encountered.");
logI(" ");
logI(" [--strict] Use strict syntax checking when parsing source code.");
Expand Down
16 changes: 9 additions & 7 deletions src/scount/c/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define MAX_DIGITS_INT64 22ULL

static const size_t BUFFER_CAPACITY_INIT = 1024;
static const size_t LARGE_RESULT_THRESHOLD = 32;
static const size_t LARGE_RESULT_THRESHOLD = 30;

static const int WIDTH_COL0 = 26; // File
static const int WIDTH_COL1 = 11; // LLC
Expand Down Expand Up @@ -557,6 +557,7 @@ static void prFileRows(PrintBuffer* buffer, const RcnCountStatistics* stats) {
const bool isLargeResult = (
stats->count.sizeProcessed > LARGE_RESULT_THRESHOLD
);
const bool checkTableSize = !buffer->showAllFileRows;
bool ellipsisRowPrinted = false;
const size_t nFiles = stats->count.size;
const size_t indexLastProcessed = getIndexLastProcessedFile(stats);
Expand All @@ -571,7 +572,7 @@ static void prFileRows(PrintBuffer* buffer, const RcnCountStatistics* stats) {
rowsPrinted >= LARGE_RESULT_THRESHOLD - 1
&& i != indexLastProcessed
);
if (isLargeResult && isInSkipRange) {
if (checkTableSize && isLargeResult && isInSkipRange) {
if (ellipsisRowPrinted) {
continue;
}
Expand Down Expand Up @@ -817,11 +818,12 @@ void printResultsMultiple(
prFileWarnings(buffer, stats);
}

prTableTop(buffer, "File");
prFileRows(buffer, stats);
prTableBottom(buffer, TABLE_BORDER_HORIZONTAL_NORMAL);

prStr(buffer, "\nSummary:\n\n");
if (buffer->showFileTable) {
prTableTop(buffer, "File");
prFileRows(buffer, stats);
prTableBottom(buffer, TABLE_BORDER_HORIZONTAL_NORMAL);
prStr(buffer, "\nSummary:\n\n");
}

prTableTop(buffer, "Language");
prSummaryRows(buffer, stats);
Expand Down
4 changes: 4 additions & 0 deletions src/scount/c/scount.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ typedef struct AppArgs {
bool readFromStdin; // True when 'inputPath' is '-' or '-.ext'
bool annotateCounts; // Option: `--annotate-counts`
bool linesOnly; // Option: `-l|--lines`
bool showFiles; // Option: `--show-files`
bool showAllFiles; // Option: `--show-all-files`
bool stopOnError; // Option: `--stop-on-error`
bool strict; // Option: `--strict`
bool verbose; // Option: `--verbose`
Expand Down Expand Up @@ -106,6 +108,8 @@ typedef struct PrintBuffer {
bool showWords;
bool showCharacters;
bool showSourceSize;
bool showFileTable;
bool showAllFileRows;
bool showWarnings;
bool fileIsStdin;
} PrintBuffer;
Expand Down
2 changes: 2 additions & 0 deletions src/scount/c/statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ ExitStatus outputStatistics(AppArgs args) {
.showWords = !args.linesOnly,
.showCharacters = !args.linesOnly,
.showSourceSize = !args.linesOnly,
.showFileTable = args.showFiles || args.showAllFiles,
.showAllFileRows = args.showAllFiles,
.fileIsStdin = args.readFromStdin
};

Expand Down
37 changes: 0 additions & 37 deletions src/scount/tests/functionality/res/expected/mixed.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions src/scount/tests/functionality/res/expected/mixedWithAllFiles.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions src/scount/tests/functionality/res/expected/mixedWithFiles.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading