mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Removed all Snow consensus code and dependencies - Replaced snow.Context with consensuscontext.Context - Updated all imports and references - Added comprehensive test suites for core packages - Fixed all build errors and test failures - Achieved 100% test pass rate (21 packages passing) - Improved test coverage to 30% Breaking changes: - Removed snow package entirely - Changed VM interface to use VMState instead of snow.State - Updated ChainContext structure Tests added: - core/app_error_test.go: 100% coverage - core/bootstrap_test.go: comprehensive concurrent tests - core/health_test.go: full integration tests - validators/validators_test.go: complete interface tests - version/version_test.go: 100% coverage - codec/codec_test.go: marshal/unmarshal tests - context/context_test.go: all functions tested
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
// This example is used in the documentation.
|
|
|
|
// How might I add my own support for --no-foo?
|
|
|
|
// 1. const { parseArgs } = require('node:util'); // from node
|
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
|
const { parseArgs } = require('..'); // in repo
|
|
|
|
const options = {
|
|
'color': { type: 'boolean' },
|
|
'no-color': { type: 'boolean' },
|
|
'logfile': { type: 'string' },
|
|
'no-logfile': { type: 'boolean' },
|
|
};
|
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
|
|
|
// Reprocess the option tokens and overwrite the returned values.
|
|
tokens
|
|
.filter((token) => token.kind === 'option')
|
|
.forEach((token) => {
|
|
if (token.name.startsWith('no-')) {
|
|
// Store foo:false for --no-foo
|
|
const positiveName = token.name.slice(3);
|
|
values[positiveName] = false;
|
|
delete values[token.name];
|
|
} else {
|
|
// Resave value so last one wins if both --foo and --no-foo.
|
|
values[token.name] = token.value ?? true;
|
|
}
|
|
});
|
|
|
|
const color = values.color;
|
|
const logfile = values.logfile ?? 'default.log';
|
|
|
|
console.log({ logfile, color });
|
|
|
|
// Try the following:
|
|
// node negate.js
|
|
// node negate.js --no-logfile --no-color
|
|
// negate.js --logfile=test.log --color
|
|
// node negate.js --no-logfile --logfile=test.log --color --no-color
|