Skip to content

Commit bbe7848

Browse files
Merge pull request #515
2 parents 532b85a + 711d8b8 commit bbe7848

File tree

7 files changed

+28
-51
lines changed

7 files changed

+28
-51
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ work hours!
113113
- refactor: fix existing ESLint issues, add markdown linting, and enable new rules ([#506](https://github.com/opening-hours/opening_hours.js/pull/506))
114114
- refactor: optimize simple_index.html ([#502](https://github.com/opening-hours/opening_hours.js/pull/502))
115115
- refactor: overload getStateString for better return type ([#504](https://github.com/opening-hours/opening_hours.js/pull/504))
116+
- refactor: replace deprecated `optimist` with `yargs` for command line argument parsing ([#515](https://github.com/opening-hours/opening_hours.js/pull/515))
116117

117118
- Public holiday definitions updated:
118119
- France ([#470](https://github.com/opening-hours/opening_hours.js/pull/470))

package-lock.json

Lines changed: 2 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"line-reader": "^0.4.0",
8383
"moment": "^2.30.1",
8484
"npm-check-updates": "^18.0.1",
85-
"optimist": "^0.6.1",
8685
"package-json-validator": "^0.18.0",
8786
"pinst": "^3.0.0",
8887
"rollup": "^4.44.1",
@@ -91,7 +90,8 @@
9190
"timekeeper": "^2.3.1",
9291
"typescript": "^5.8.3",
9392
"typescript-eslint": "^8.35.0",
94-
"yaml": "^2.8.0"
93+
"yaml": "^2.8.0",
94+
"yargs": "^17.7.2"
9595
},
9696
"engines": {
9797
"node": ">=12"

scripts/PH_SH_exporter.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const YAML = require('yaml');
2727
/* }}} */
2828

2929
/* Parameter handling {{{ */
30-
const optimist = require('optimist')
30+
const yargs = require('yargs')
3131
.usage('Usage: $0 export_list.conf')
3232
.describe('h', 'Display the usage')
3333
.describe('v', 'Verbose output')
3434
.describe('f', 'From year (including)')
35-
.demand('f')
35+
.demandOption('f')
3636
.describe('t', 'Until year (including)')
37-
.demand('t')
37+
.demandOption('t')
3838
.describe('p', 'Export public holidays. Can not be used together with --school-holidays.')
3939
// .default('p', true)
4040
.describe('s', 'Export school holidays. Can not be used together with --public-holidays.')
@@ -55,12 +55,13 @@ const optimist = require('optimist')
5555
.alias('r', 'state')
5656
.alias('a', 'all-locations')
5757
.string(['c', 'r', ])
58-
.alias('o', 'omit-date-hyphens');
58+
.alias('o', 'omit-date-hyphens')
59+
.help(false);
5960

60-
const argv = optimist.argv;
61+
const argv = yargs.parse();
6162

6263
if (argv.help || argv._.length === 0) {
63-
optimist.showHelp();
64+
yargs.showHelp();
6465
process.exit(0);
6566
}
6667

scripts/gen_taginfo_json.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@ const fs = require('node:fs');
2424
/* }}} */
2525

2626
/* Parameter handling {{{ */
27-
const optimist = require('optimist')
27+
const yargs = require('yargs')
2828
.usage('Usage: $0 -')
2929
.describe('h', 'Display the usage')
3030
.describe('k', 'File containing the list of supported keys')
31-
.demand('k')
31+
.demandOption('k')
3232
.describe('i', 'Template taginfo.json which is used to merge with the list of keys')
3333
.alias('h', 'help')
3434
.alias('k', 'key-file')
35-
.alias('i', 'template-file');
35+
.alias('i', 'template-file')
36+
.help(false);
3637

37-
const argv = optimist.argv;
38+
const argv = yargs.parse();
3839

3940
if (argv.help) {
40-
optimist.showHelp();
41+
yargs.showHelp();
4142
process.exit(0);
4243
}
4344
/* }}} */

scripts/interactive_testing.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// SPDX-License-Identifier: LGPL-3.0-only
66

7-
const optimist = require('optimist')
7+
const yargs = require('yargs')
88
.usage('Usage: $0 [optional parameters] [server_listening_ports]')
99
.describe('h', 'Display the usage')
1010
// .describe('v', 'Verbose output')
@@ -20,12 +20,13 @@ const optimist = require('optimist')
2020
.alias('V', 'value')
2121
.default('f', '../build/opening_hours.js')
2222
.default('l', 'en')
23-
.default('L', 'en');
23+
.default('L', 'en')
24+
.help(false);
2425

25-
const argv = optimist.argv;
26+
const argv = yargs.parse();
2627

2728
if (argv.help) {
28-
optimist.showHelp();
29+
yargs.showHelp();
2930
process.exit(0);
3031
}
3132

test/test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// preamble {{{
3737

3838
/* Parameter handling {{{ */
39-
const optimist = require('optimist')
39+
const yargs = require('yargs')
4040
.usage('Usage: $0 [optional parameters]')
4141
.describe('h', 'Display the usage')
4242
// .describe('v', 'Verbose output')
@@ -47,12 +47,13 @@ const optimist = require('optimist')
4747
.alias('f', 'library-file')
4848
.alias('l', 'locale')
4949
.default('f', './opening_hours.js')
50-
.default('l', 'en');
50+
.default('l', 'en')
51+
.help(false);
5152

52-
const argv = optimist.argv;
53+
const argv = yargs.parse();
5354

5455
if (argv.help) {
55-
optimist.showHelp();
56+
yargs.showHelp();
5657
process.exit(0);
5758
}
5859
/* }}} */

0 commit comments

Comments
 (0)