Skip to content

Commit feafad8

Browse files
committed
realized I could make it the same as bazel
1 parent 42a9498 commit feafad8

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

‎packages/pyright-scip/src/MainCommand.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ checkIndexParser([], {
2727
checkIndexParser(['--cwd', 'qux'], { cwd: 'qux' });
2828
checkIndexParser(['--no-progress-bar'], { quiet: false });
2929
checkIndexParser(['--show-progress-rate-limit', '120'], { showProgressRateLimit: 120 });
30+
checkIndexParser(['--show-progress-rate-limit', '0.5'], { showProgressRateLimit: 0.5 });

‎packages/pyright-scip/src/MainCommand.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export interface EnvironmentOptions {
3030

3131
export const DEFAULT_OUTPUT_FILE = 'index.scip';
3232

33-
const parseOptionalInt = (value: string) => {
33+
const parseOptionalNum = (value: string) => {
3434
if (value === undefined) {
3535
return undefined;
3636
}
3737

3838
// parseInt takes a string and a radix
39-
const parsedValue = parseInt(value, 10);
39+
const parsedValue = parseFloat(value);
4040
if (isNaN(parsedValue)) {
4141
throw new InvalidArgumentError('Not a number.');
4242
}
@@ -60,7 +60,11 @@ export function mainCommand(
6060
.option('--snapshot-dir <path>', 'the directory to output a snapshot of the SCIP dump')
6161
.option('--no-progress-bar', '(deprecated, use "--quiet")')
6262
.option('--quiet', 'run without logging and status information', false)
63-
.option('--show-progress-rate-limit <limit>', 'number of times to show progress per minute', parseOptionalInt)
63+
.option(
64+
'--show-progress-rate-limit <limit>',
65+
'minimum number of seconds between progress messages in the output.',
66+
parseOptionalNum
67+
)
6468
.option('--environment <json-file>', 'the environment json file (experimental)')
6569
.option('--include <pattern>', 'comma-separated list of patterns to include (experimental)')
6670
.option('--exclude <pattern>', 'comma-separated list of patterns to exclude (experimental)')
@@ -81,7 +85,11 @@ export function mainCommand(
8185
.option('--no-index', 'skip indexing (use existing index.scip)')
8286
.option('--no-progress-bar', '(deprecated, use "--quiet")')
8387
.option('--quiet', 'run without logging and status information', false)
84-
.option('--show-progress-rate-limit <limit>', 'number of times to show progress per minute', parseOptionalInt)
88+
.option(
89+
'--show-progress-rate-limit <limit>',
90+
'minimum number of seconds between progress messages in the output.',
91+
parseOptionalNum
92+
)
8593
.action((dir, parsedOptions) => {
8694
snapshotAction(dir, parsedOptions as SnapshotOptions);
8795
});

‎packages/pyright-scip/src/status.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ const statusConfig = { quiet: true };
33
class Logger {
44
private lastProgressMsg: Date;
55

6-
/// control the rate to no faster than showProgressRateLimit / 60 seconds
6+
/// Minimum number of seconds between progress messages in the output.
77
public showProgressRateLimit: number;
88

99
public depth: number;
1010

11-
constructor(showProgressRateLimit = 6) {
11+
constructor(showProgressRateLimit = 1) {
1212
this.depth = 0;
1313
this.showProgressRateLimit = showProgressRateLimit;
1414
this.lastProgressMsg = new Date();
@@ -52,7 +52,7 @@ class Logger {
5252
if (
5353
this.showProgressRateLimit == 0 ||
5454
!this.lastProgressMsg ||
55-
now.getTime() - this.lastProgressMsg.getTime() > (60 / this.showProgressRateLimit) * 1000
55+
(now.getTime() - this.lastProgressMsg.getTime()) / 1000 > this.showProgressRateLimit
5656
) {
5757
this.lastProgressMsg = now;
5858
this.write_message(this.depth + 1, '- ' + msg);

0 commit comments

Comments
 (0)