Javascript argparse
package allows to enable -v, --version
option by default:
const parser = new ArgumentParser({
version: "0.0.1",
...
I can comment out the version
attribute, and enter something like this:
parser.addArgument(["-V", "--version"], {
help: "package version",
action: "version",
version: "v0.1.0",
});
Almost perfect; I'd like to import the version from package.json
, if possible.
You can get the version of the app as follows.
const packageObj = require('./package.json');
const version = packageObj.version;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.