Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
markdown option parsing
Useful in combination with marked-man to ensure your man pages are always up to date by making the docs a core part of the cli's runtime. (related: package.json man).
Check out the test cases, or view the example below to get an idea of what a properly formatted options section looks like.
cli.js
:
const mdopt = require('mdopt');
const { readFileSync } = require('fs');
const md = readFileSync('path.md', {
encoding: 'utf8'
});
const argv = process.argv.slice(2)
const argv = mdopt(argv, md);
console.log(argv);
argv
is a variable that holds a minimist object that has
been populated (aliases, defaults) according to the provided markdown
file.
A sample session might look like this:
$ node cli.js
Error: Missing required option demand
$ node cli.js --demand
Error: Missing required option pghost
$ PGHOST=localhost node demo.js --demand hey hey you you
{ _: [ 'hey', 'hey', 'you', 'you' ],
f: false,
flag: false,
home: '/home/jay',
demand: true,
default: 'foo',
d: 'foo',
pghost: 'localhost' }
And finally what the spec.md
file looks like demonstrating
all available options:
spec.md
# demo -- A demonstration of the features & formatting
## SYNOPSIS
sample [flags] `<first>` `<last>` `[pet]`
## OPTIONS
### -f, --flag
This is a boolean flag as there is no values that
follow the flag. It can be accessed with $('f') or
$('flag')
### --anything ANYTHING
This flag expects a value to come after it. It can be a
number, a string, etc. The type will be auto detected
and the value of $('anything') will be that value.
### -s "VALUE", --string "VALUE"
Same as above, except that the value placeholder is in
quotes meaning that no type detection is performed, and
it is kept as a string. Give it `000123` and it will
remain `000123` vs. converting it to a number resulting
in `123`.
### --default=SOMETHING, -d SOMETHING (default=foo)
It is also possible to set default values.
### --home (default=$HOME)
And use environment variables to set those
defaults. Any default value beginning with a `$` will
be treated as an environment variable.
### --demand (required)
We can also demand that a flag should be set.
### --pghost "URI" (required, default=$PGHOST)
Combining required and using environment variables as
defaults is a good way to ensure that the value will be
set one way or another.
## AUTHORS
... Another section
## BUGS
... Another section. Add as many sections as you want.
FAQs
markdown option parsing
The npm package mdopt receives a total of 6 weekly downloads. As such, mdopt popularity was classified as not popular.
We found that mdopt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.