@openclaw/matrix 2026.8.1-beta.2 → 2026.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-config-BZWN9tGS.js → account-config-CRsKoMqJ.js} +1 -1
- package/dist/{account-selection-CWuhuFn1.js → account-selection-C8nnBTxi.js} +63 -27
- package/dist/{accounts-BCzyubQt.js → accounts-fC57n-Jo.js} +3 -4
- package/dist/api.js +7 -7
- package/dist/{approval-handler.runtime-CJXCUdRg.js → approval-handler.runtime-BBjFZw1t.js} +9 -6
- package/dist/{approval-ids-7rf7etWE.js → approval-ids-DTIdXV-m.js} +1 -1
- package/dist/{approval-reaction-auth-wBwbEDpZ.js → approval-reaction-auth-BDONXxnF.js} +2 -2
- package/dist/{channel-VSrHgTON.js → channel-BkEcVUs_.js} +249 -24
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-pOOL0uT_.js → channel.runtime-CTLSBFsP.js} +26 -16
- package/dist/{channel.setup-PpxRP9Du.js → channel.setup-CSacbORr.js} +11 -12
- package/dist/{cli-CkTfKC_c.js → cli-DRVtgrq5.js} +15 -14
- package/dist/{cli-metadata-B1d1aGM5.js → cli-metadata-Ddx_y4Os.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-sJesKQmp.js → client-CZ_JvrO0.js} +2 -2
- package/dist/{client-bootstrap-BFwT_2VT.js → client-bootstrap-D8irSL2i.js} +1 -1
- package/dist/{client-CeGw0G5S.js → client-kSi51NKp.js} +86 -62
- package/dist/{config-update-Bor_Pjsv.js → config-update-DC0fWBxc.js} +2 -3
- package/dist/contract-api.js +2 -2
- package/dist/{crypto-runtime-Bnz3zEcS.js → crypto-runtime-C4WDYxlP.js} +1 -1
- package/dist/{directory-live-Bvg2wAnR.js → directory-live-DKr0w35b.js} +3 -3
- package/dist/doctor-contract-api.js +9 -3
- package/dist/{draft-stream-BRi7PRRS.js → draft-stream-0CEpNrBk.js} +1 -1
- package/dist/{encryption-guidance-DmLY8NiO.js → encryption-guidance-D4ZdAqzM.js} +1 -1
- package/dist/event-helpers-XRfAbOIh.js +46 -0
- package/dist/helper-api.js +1 -1
- package/dist/{http-client-CycYxU9-.js → http-client-D8o8b9u6.js} +3 -47
- package/dist/{idb-persistence-BM0P27Zg.js → idb-persistence-DfgW720p.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{messages-BW0s-6Y9.js → messages-DaGRt-tu.js} +183 -27
- package/dist/{monitor-Ddfc-vjX.js → monitor-CLPbPcR9.js} +225 -173
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-Bxpr1FFy.js +2 -0
- package/dist/{profile-update-BkgWYDIp.js → profile-update-zXVCMg7y.js} +2 -2
- package/dist/{reaction-events-nfUbFLdV.js → reaction-events-CjVUiqcY.js} +5 -5
- package/dist/{resolve-targets-BJAPY4Vb.js → resolve-targets-qG6gceps.js} +2 -2
- package/dist/{resolver.runtime-LWJELYq5.js → resolver.runtime-zX3TR3TN.js} +1 -1
- package/dist/{room-info-BXQA7y10.js → room-info-yheP1mod.js} +55 -1
- package/dist/runtime-api.js +2 -2
- package/dist/{sdk-DjaQFCHc.js → sdk-TZYyo0XQ.js} +74 -29
- package/dist/{send-ZDLU4JTk.js → send-BL_iH5Ox.js} +55 -35
- package/dist/session-binding-contract-api.js +2 -3
- package/dist/{setup-bootstrap-BaXkhgJg.js → setup-bootstrap-D8M7FmcO.js} +3 -3
- package/dist/{setup-core-DQn6b5vi.js → setup-core-r6L0nno-.js} +5 -5
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-DlhJdrNI.js → setup-surface-g174ElFO.js} +14 -14
- package/dist/subagent-hooks-CMoZaARG.js +48 -0
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/{target-ids-B-5aQxwn.js → target-ids-Nwx7cMVE.js} +11 -1
- package/dist/{thread-binding-api-DRbBZlhS.js → thread-binding-api-CzkeLZCU.js} +1 -1
- package/dist/thread-binding-api.js +1 -1
- package/dist/{thread-bindings-CcHZP3w2.js → thread-bindings-ERWNousC.js} +13 -9
- package/dist/thread-bindings-runtime.js +1 -1
- package/dist/{thread-bindings-shared-CKnY4LSd.js → thread-bindings-shared-oNPiyMWY.js} +1 -6
- package/dist/{tool-actions.runtime-DmdRL0bN.js → tool-actions.runtime-DcBCSwY4.js} +57 -65
- package/dist/{verification-C7ig-bQE.js → verification-4vsW_WSn.js} +2 -2
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +29 -3
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +23 -14
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/RELEASING.md +6 -2
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js +33 -14
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/index.d.ts +14 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +41 -42
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.d.ts +16 -4
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +25 -9
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +23 -7
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
- package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +1 -0
- package/node_modules/markdown-it/README.md +18 -294
- package/node_modules/markdown-it/bin/markdown-it.mjs +2 -2
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +2972 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +14 -0
- package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js +4412 -0
- package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -0
- package/node_modules/markdown-it/dist/markdown-it.d.cts +19 -0
- package/node_modules/markdown-it/dist/markdown-it.d.mts +979 -0
- package/node_modules/markdown-it/dist/{index.cjs.js → markdown-it.mjs} +1437 -1466
- package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/argparse/README.md +46 -41
- package/node_modules/markdown-it/node_modules/argparse/lib/_colorize.js +72 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/argparse.d.ts +292 -0
- package/node_modules/markdown-it/node_modules/argparse/{argparse.js → lib/argparse.js} +1124 -1027
- package/node_modules/markdown-it/node_modules/argparse/lib/difflib.js +190 -0
- package/node_modules/markdown-it/node_modules/argparse/lib/sub.js +4 -4
- package/node_modules/markdown-it/node_modules/argparse/lib/textwrap.js +28 -28
- package/node_modules/markdown-it/node_modules/argparse/package.json +17 -10
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts +8 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js +46 -0
- package/node_modules/markdown-it/node_modules/entities/dist/decode-codepoint.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.d.ts +28 -45
- package/node_modules/markdown-it/node_modules/entities/dist/decode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/decode.js +189 -141
- package/node_modules/markdown-it/node_modules/entities/dist/decode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/encode.d.ts +4 -2
- package/node_modules/markdown-it/node_modules/entities/dist/encode.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js +90 -0
- package/node_modules/markdown-it/node_modules/entities/dist/encode.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib → dist}/escape.d.ts +15 -10
- package/node_modules/markdown-it/node_modules/entities/dist/escape.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js +132 -0
- package/node_modules/markdown-it/node_modules/entities/dist/escape.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts +5 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js +12 -0
- package/node_modules/markdown-it/node_modules/entities/dist/generated/encode-html.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/{lib/esm → dist}/index.d.ts +14 -21
- package/node_modules/markdown-it/node_modules/entities/dist/index.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js +91 -0
- package/node_modules/markdown-it/node_modules/entities/dist/index.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js +18 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js +17 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts +33 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.d.ts.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js +93 -0
- package/node_modules/markdown-it/node_modules/entities/dist/internal/encode-shared.js.map +1 -0
- package/node_modules/markdown-it/node_modules/entities/package.json +63 -70
- package/node_modules/markdown-it/node_modules/entities/readme.md +54 -45
- package/node_modules/markdown-it/node_modules/entities/src/decode-codepoint.ts +50 -0
- package/node_modules/markdown-it/node_modules/entities/src/decode.ts +671 -0
- package/node_modules/markdown-it/node_modules/entities/src/encode.ts +95 -0
- package/node_modules/markdown-it/node_modules/entities/src/escape.ts +160 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-html.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
- package/node_modules/markdown-it/node_modules/entities/src/generated/encode-html.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/index.ts +162 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/bin-trie-flags.ts +16 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/decode-shared.ts +18 -0
- package/node_modules/markdown-it/node_modules/entities/src/internal/encode-shared.ts +123 -0
- package/node_modules/markdown-it/node_modules/linkify-it/README.md +49 -86
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js +636 -825
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.cjs.js.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.d.ts +236 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs +538 -0
- package/node_modules/markdown-it/node_modules/linkify-it/build/index.mjs.map +1 -0
- package/node_modules/markdown-it/node_modules/linkify-it/package.json +23 -20
- package/node_modules/markdown-it/node_modules/uc.micro/README.md +18 -1
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.cjs.js +13 -18
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.d.ts +6 -0
- package/node_modules/markdown-it/node_modules/uc.micro/build/index.mjs +8 -0
- package/node_modules/markdown-it/node_modules/uc.micro/package.json +12 -17
- package/node_modules/markdown-it/package.json +48 -30
- package/node_modules/matrix-js-sdk/CHANGELOG.md +33 -0
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +0 -5
- package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/auth.d.ts +0 -5
- package/node_modules/matrix-js-sdk/lib/@types/auth.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/auth.js +0 -11
- package/node_modules/matrix-js-sdk/lib/@types/auth.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/beacon.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/beacon.js +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/beacon.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/crypto.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/crypto.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +3 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/event.js +1 -0
- package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/extensible_events.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/media.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/partials.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/partials.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/requests.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/requests.js +0 -5
- package/node_modules/matrix-js-sdk/lib/@types/requests.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/search.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/search.js +0 -3
- package/node_modules/matrix-js-sdk/lib/@types/search.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/spaces.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/spaces.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/synapse.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/synapse.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/threepids.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/@types/type-guards.d.ts +43 -0
- package/node_modules/matrix-js-sdk/lib/@types/type-guards.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/@types/type-guards.js +104 -0
- package/node_modules/matrix-js-sdk/lib/@types/type-guards.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/NamespacedValue.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/ReEmitter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js +0 -2
- package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/autodiscovery.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/autodiscovery.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/browser-index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/browser-index.js +3 -1
- package/node_modules/matrix-js-sdk/lib/browser-index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/client.d.ts +21 -20
- package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/client.js +38 -94
- package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js +1 -4
- package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/content-helpers.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/base.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/base.js +0 -9
- package/node_modules/matrix-js-sdk/lib/crypto/store/base.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js +2 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js +0 -2
- package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.d.ts +13 -6
- package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/verification.d.ts +23 -5
- package/node_modules/matrix-js-sdk/lib/crypto-api/verification.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.d.ts +16 -0
- package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/embedded.js +19 -11
- package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/errors.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/feature.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/feature.js +0 -3
- package/node_modules/matrix-js-sdk/lib/feature.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter-component.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter-component.js +2 -5
- package/node_modules/matrix-js-sdk/lib/filter-component.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/filter.js +0 -4
- package/node_modules/matrix-js-sdk/lib/filter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/errors.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/index.d.ts +1 -7
- package/node_modules/matrix-js-sdk/lib/http-api/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/index.js +0 -15
- package/node_modules/matrix-js-sdk/lib/http-api/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts +0 -9
- package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js +0 -2
- package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +0 -3
- package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/interactive-auth.js +5 -6
- package/node_modules/matrix-js-sdk/lib/interactive-auth.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/logger.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/logger.js +0 -2
- package/node_modules/matrix-js-sdk/lib/logger.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts +3 -3
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +5 -5
- package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts +18 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +56 -4
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.d.ts +14 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +20 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +9 -6
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.d.ts +6 -3
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js +7 -4
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts +19 -6
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +11 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts +0 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +0 -1
- package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/beacon.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/device.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-context.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js +3 -3
- package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event-timeline.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/event.js +0 -6
- package/node_modules/matrix-js-sdk/lib/models/event.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/poll.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/poll.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/read-receipt.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/read-receipt.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/related-relations.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations-container.d.ts +10 -0
- package/node_modules/matrix-js-sdk/lib/models/relations-container.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations-container.js +39 -17
- package/node_modules/matrix-js-sdk/lib/models/relations-container.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations.js +1 -1
- package/node_modules/matrix-js-sdk/lib/models/relations.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-member.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-receipts.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-state.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-state.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room-summary.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/room.js +9 -9
- package/node_modules/matrix-js-sdk/lib/models/room.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/search-result.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/thread.d.ts +5 -2
- package/node_modules/matrix-js-sdk/lib/models/thread.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/thread.js +36 -3
- package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/models/user.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.d.ts +133 -0
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.js +193 -0
- package/node_modules/matrix-js-sdk/lib/oauth/authorize.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/discover.d.ts +58 -0
- package/node_modules/matrix-js-sdk/lib/oauth/discover.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/discover.js +35 -0
- package/node_modules/matrix-js-sdk/lib/oauth/discover.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/error.d.ts +19 -0
- package/node_modules/matrix-js-sdk/lib/oauth/error.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/error.js +36 -0
- package/node_modules/matrix-js-sdk/lib/oauth/error.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts +87 -0
- package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/index.js +236 -0
- package/node_modules/matrix-js-sdk/lib/oauth/index.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/register.d.ts +136 -0
- package/node_modules/matrix-js-sdk/lib/oauth/register.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/register.js +73 -0
- package/node_modules/matrix-js-sdk/lib/oauth/register.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts +21 -0
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js +68 -0
- package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/pollingCachedValue.d.ts +77 -0
- package/node_modules/matrix-js-sdk/lib/pollingCachedValue.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/pollingCachedValue.js +160 -0
- package/node_modules/matrix-js-sdk/lib/pollingCachedValue.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/pushprocessor.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js +0 -1
- package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.d.ts +7 -7
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js +13 -14
- package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousError.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -1
- package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/room-hierarchy.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.d.ts +9 -0
- package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.js +38 -0
- package/node_modules/matrix-js-sdk/lib/rtcTransportsCachedValue.js.map +1 -0
- package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js +11 -13
- package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js +0 -2
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +23 -4
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +62 -21
- package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js +1 -0
- package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.d.ts +17 -4
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js +21 -4
- package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js +0 -2
- package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +0 -3
- package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/scheduler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/scheduler.js +0 -3
- package/node_modules/matrix-js-sdk/lib/scheduler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/secret-storage.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js +6 -0
- package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sliding-sync.js +3 -0
- package/node_modules/matrix-js-sdk/lib/sliding-sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js +1 -0
- package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.js +0 -2
- package/node_modules/matrix-js-sdk/lib/store/indexeddb.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/memory.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/memory.js +7 -9
- package/node_modules/matrix-js-sdk/lib/store/memory.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/store/stub.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.js +1 -5
- package/node_modules/matrix-js-sdk/lib/sync-accumulator.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.js +1 -1
- package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/testing.d.ts +2 -10
- package/node_modules/matrix-js-sdk/lib/testing.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/testing.js +4 -19
- package/node_modules/matrix-js-sdk/lib/testing.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/timeline-window.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/timeline-window.js +0 -1
- package/node_modules/matrix-js-sdk/lib/timeline-window.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js +0 -1
- package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils.d.ts +1 -1
- package/node_modules/matrix-js-sdk/lib/utils.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/utils.js +1 -0
- package/node_modules/matrix-js-sdk/lib/utils.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/call.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/call.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js +0 -5
- package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.d.ts.map +1 -1
- package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.d.ts +8 -0
- package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.d.ts.map +1 -0
- package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.js +34 -0
- package/node_modules/matrix-js-sdk/lib/wellKnownCachedValue.js.map +1 -0
- package/node_modules/matrix-js-sdk/node_modules/content-type/README.md +2 -0
- package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/matrix-js-sdk/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/content-type/package.json +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/dist/api.js +227 -131
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/dist/api.min.js +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.d.ts +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.js +142 -97
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/ClientWidgetApi.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.d.ts +15 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.js +61 -19
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/WidgetApi.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.d.ts +15 -11
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.js +19 -13
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/driver/WidgetDriver.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/index.d.ts +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/index.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.d.ts +2 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js +2 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/ApiVersion.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.d.ts +5 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.js +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/Capabilities.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.d.ts +24 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.js +6 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/RtcTransportsAction.js.map +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/SendEventAction.d.ts +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/SendEventAction.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.d.ts +5 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/lib/interfaces/WidgetApiAction.js.map +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/package.json +1 -1
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/ClientWidgetApi.ts +37 -14
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/WidgetApi.ts +69 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/driver/WidgetDriver.ts +19 -12
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/index.ts +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/ApiVersion.ts +2 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/Capabilities.ts +4 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/RtcTransportsAction.ts +44 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/SendEventAction.ts +1 -0
- package/node_modules/matrix-js-sdk/node_modules/matrix-widget-api/src/interfaces/WidgetApiAction.ts +5 -0
- package/node_modules/matrix-js-sdk/package.json +10 -12
- package/node_modules/matrix-js-sdk/src/@types/PushRules.ts +0 -5
- package/node_modules/matrix-js-sdk/src/@types/auth.ts +0 -12
- package/node_modules/matrix-js-sdk/src/@types/beacon.ts +1 -1
- package/node_modules/matrix-js-sdk/src/@types/crypto.ts +2 -6
- package/node_modules/matrix-js-sdk/src/@types/event.ts +3 -0
- package/node_modules/matrix-js-sdk/src/@types/extensible_events.ts +5 -6
- package/node_modules/matrix-js-sdk/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -1
- package/node_modules/matrix-js-sdk/src/@types/media.ts +1 -1
- package/node_modules/matrix-js-sdk/src/@types/partials.ts +0 -2
- package/node_modules/matrix-js-sdk/src/@types/requests.ts +0 -5
- package/node_modules/matrix-js-sdk/src/@types/search.ts +0 -2
- package/node_modules/matrix-js-sdk/src/@types/spaces.ts +0 -2
- package/node_modules/matrix-js-sdk/src/@types/synapse.ts +0 -2
- package/node_modules/matrix-js-sdk/src/@types/threepids.ts +2 -2
- package/node_modules/matrix-js-sdk/src/@types/type-guards.ts +126 -0
- package/node_modules/matrix-js-sdk/src/ToDeviceMessageQueue.ts +0 -2
- package/node_modules/matrix-js-sdk/src/autodiscovery.ts +2 -2
- package/node_modules/matrix-js-sdk/src/browser-index.ts +4 -4
- package/node_modules/matrix-js-sdk/src/client.ts +79 -130
- package/node_modules/matrix-js-sdk/src/common-crypto/key-passphrase.ts +1 -2
- package/node_modules/matrix-js-sdk/src/crypto/store/base.ts +1 -8
- package/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store-backend.ts +3 -2
- package/node_modules/matrix-js-sdk/src/crypto/store/indexeddb-crypto-store.ts +1 -3
- package/node_modules/matrix-js-sdk/src/crypto/store/localStorage-crypto-store.ts +0 -1
- package/node_modules/matrix-js-sdk/src/crypto/store/memory-crypto-store.ts +1 -1
- package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +1 -1
- package/node_modules/matrix-js-sdk/src/crypto-api/keybackup.ts +14 -7
- package/node_modules/matrix-js-sdk/src/crypto-api/verification.ts +23 -5
- package/node_modules/matrix-js-sdk/src/embedded.ts +34 -16
- package/node_modules/matrix-js-sdk/src/feature.ts +0 -3
- package/node_modules/matrix-js-sdk/src/filter-component.ts +1 -2
- package/node_modules/matrix-js-sdk/src/filter.ts +0 -3
- package/node_modules/matrix-js-sdk/src/http-api/fetch.ts +1 -1
- package/node_modules/matrix-js-sdk/src/http-api/index.ts +1 -23
- package/node_modules/matrix-js-sdk/src/http-api/interface.ts +0 -12
- package/node_modules/matrix-js-sdk/src/http-api/refresh.ts +0 -1
- package/node_modules/matrix-js-sdk/src/interactive-auth.ts +4 -4
- package/node_modules/matrix-js-sdk/src/logger.ts +0 -2
- package/node_modules/matrix-js-sdk/src/matrix.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/CallMembership.ts +5 -5
- package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +73 -6
- package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager.ts +21 -2
- package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +9 -6
- package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManagerActionScheduler.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/RTCEncryptionManager.ts +2 -2
- package/node_modules/matrix-js-sdk/src/matrixrtc/ToDeviceKeyTransport.ts +3 -3
- package/node_modules/matrix-js-sdk/src/matrixrtc/index.ts +1 -1
- package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/rtc.ts +19 -8
- package/node_modules/matrix-js-sdk/src/matrixrtc/types.ts +24 -7
- package/node_modules/matrix-js-sdk/src/matrixrtc/utils.ts +0 -2
- package/node_modules/matrix-js-sdk/src/models/event-timeline-set.ts +3 -3
- package/node_modules/matrix-js-sdk/src/models/event.ts +7 -13
- package/node_modules/matrix-js-sdk/src/models/invites-ignorer.ts +1 -1
- package/node_modules/matrix-js-sdk/src/models/poll.ts +1 -1
- package/node_modules/matrix-js-sdk/src/models/read-receipt.ts +1 -1
- package/node_modules/matrix-js-sdk/src/models/relations-container.ts +55 -19
- package/node_modules/matrix-js-sdk/src/models/relations.ts +1 -1
- package/node_modules/matrix-js-sdk/src/models/room-state.ts +0 -3
- package/node_modules/matrix-js-sdk/src/models/room.ts +15 -15
- package/node_modules/matrix-js-sdk/src/models/thread.ts +51 -6
- package/node_modules/matrix-js-sdk/src/oauth/authorize.ts +274 -0
- package/node_modules/matrix-js-sdk/src/oauth/discover.ts +102 -0
- package/node_modules/matrix-js-sdk/src/{oidc → oauth}/error.ts +8 -7
- package/node_modules/matrix-js-sdk/src/oauth/index.ts +297 -0
- package/node_modules/matrix-js-sdk/src/oauth/register.ts +166 -0
- package/node_modules/matrix-js-sdk/src/oauth/tokenRefresher.ts +77 -0
- package/node_modules/matrix-js-sdk/src/pollingCachedValue.ts +184 -0
- package/node_modules/matrix-js-sdk/src/pushprocessor.ts +3 -3
- package/node_modules/matrix-js-sdk/src/realtime-callbacks.ts +0 -1
- package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +1 -2
- package/node_modules/matrix-js-sdk/src/rendezvous/MSC4108SignInWithQR.ts +14 -16
- package/node_modules/matrix-js-sdk/src/rendezvous/index.ts +2 -2
- package/node_modules/matrix-js-sdk/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -1
- package/node_modules/matrix-js-sdk/src/rtcTransportsCachedValue.ts +40 -0
- package/node_modules/matrix-js-sdk/src/rust-crypto/DehydratedDeviceManager.ts +14 -13
- package/node_modules/matrix-js-sdk/src/rust-crypto/OutgoingRequestProcessor.ts +0 -1
- package/node_modules/matrix-js-sdk/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
- package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +67 -33
- package/node_modules/matrix-js-sdk/src/rust-crypto/device-converter.ts +1 -0
- package/node_modules/matrix-js-sdk/src/rust-crypto/index.ts +32 -23
- package/node_modules/matrix-js-sdk/src/rust-crypto/libolm_migration.ts +1 -3
- package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +3 -6
- package/node_modules/matrix-js-sdk/src/scheduler.ts +0 -3
- package/node_modules/matrix-js-sdk/src/sliding-sync-sdk.ts +4 -1
- package/node_modules/matrix-js-sdk/src/sliding-sync.ts +3 -1
- package/node_modules/matrix-js-sdk/src/store/indexeddb-local-backend.ts +1 -1
- package/node_modules/matrix-js-sdk/src/store/indexeddb-store-worker.ts +1 -0
- package/node_modules/matrix-js-sdk/src/store/indexeddb.ts +0 -2
- package/node_modules/matrix-js-sdk/src/store/memory.ts +7 -9
- package/node_modules/matrix-js-sdk/src/sync-accumulator.ts +1 -3
- package/node_modules/matrix-js-sdk/src/sync.ts +5 -6
- package/node_modules/matrix-js-sdk/src/testing.ts +3 -22
- package/node_modules/matrix-js-sdk/src/timeline-window.ts +0 -1
- package/node_modules/matrix-js-sdk/src/utils/internal/deriveKeys.ts +0 -1
- package/node_modules/matrix-js-sdk/src/utils.ts +3 -2
- package/node_modules/matrix-js-sdk/src/webrtc/call.ts +6 -6
- package/node_modules/matrix-js-sdk/src/webrtc/callEventTypes.ts +0 -5
- package/node_modules/matrix-js-sdk/src/webrtc/groupCall.ts +7 -7
- package/node_modules/matrix-js-sdk/src/webrtc/mediaHandler.ts +1 -1
- package/node_modules/matrix-js-sdk/src/webrtc/stats/callStatsReportGatherer.ts +2 -2
- package/node_modules/matrix-js-sdk/src/webrtc/stats/transportStatsBuilder.ts +1 -1
- package/node_modules/matrix-js-sdk/src/wellKnownCachedValue.ts +34 -0
- package/node_modules/music-metadata/LICENSE.txt +9 -9
- package/node_modules/music-metadata/README.md +878 -878
- package/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
- package/node_modules/music-metadata/lib/ParseError.js +1 -1
- package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
- package/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
- package/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
- package/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
- package/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
- package/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
- package/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
- package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
- package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
- package/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
- package/node_modules/music-metadata/node_modules/content-type/README.md +2 -0
- package/node_modules/music-metadata/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/music-metadata/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/music-metadata/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/music-metadata/node_modules/content-type/package.json +1 -1
- package/node_modules/music-metadata/node_modules/file-type/package.json +1 -1
- package/node_modules/music-metadata/node_modules/file-type/readme.md +3 -0
- package/node_modules/music-metadata/node_modules/file-type/source/detectors/zip.js +6 -1
- package/node_modules/music-metadata/node_modules/file-type/source/index.d.ts +3 -0
- package/node_modules/music-metadata/node_modules/file-type/source/index.js +25 -13
- package/node_modules/music-metadata/package.json +156 -156
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/openclaw.plugin.json +23 -1
- package/package.json +10 -10
- package/dist/env-auth-MVS-Vv41.js +0 -64
- package/dist/media-text-JudlYOSc.js +0 -146
- package/dist/probe.runtime-Dr91B_X3.js +0 -2
- package/dist/route-DY6at4qJ.js +0 -161
- package/dist/runtime-api-BGO16Fu8.js +0 -21
- package/dist/subagent-hooks-dkPAF6Et.js +0 -143
- package/dist/timeout-abort-signal-DMrgRFIy.js +0 -2
- package/node_modules/markdown-it/dist/index.cjs.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.js +0 -3975
- package/node_modules/markdown-it/dist/markdown-it.js.map +0 -1
- package/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
- package/node_modules/markdown-it/dist/markdown-it.min.js.map +0 -1
- package/node_modules/markdown-it/index.mjs +0 -1
- package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
- package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
- package/node_modules/markdown-it/lib/common/utils.mjs +0 -324
- package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
- package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
- package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
- package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
- package/node_modules/markdown-it/lib/index.mjs +0 -565
- package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
- package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
- package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
- package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
- package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
- package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
- package/node_modules/markdown-it/lib/renderer.mjs +0 -322
- package/node_modules/markdown-it/lib/ruler.mjs +0 -340
- package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
- package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -80
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -85
- package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -48
- package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
- package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
- package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
- package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
- package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
- package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
- package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
- package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
- package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
- package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
- package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -83
- package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
- package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
- package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
- package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
- package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
- package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -154
- package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
- package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
- package/node_modules/markdown-it/lib/token.mjs +0 -191
- package/node_modules/markdown-it/node_modules/argparse/CHANGELOG.md +0 -216
- package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts +0 -211
- package/node_modules/markdown-it/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js +0 -536
- package/node_modules/markdown-it/node_modules/entities/lib/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/node_modules/markdown-it/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts +0 -22
- package/node_modules/markdown-it/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js +0 -77
- package/node_modules/markdown-it/node_modules/entities/lib/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js +0 -122
- package/node_modules/markdown-it/node_modules/entities/lib/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/node_modules/markdown-it/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js +0 -69
- package/node_modules/markdown-it/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js +0 -116
- package/node_modules/markdown-it/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/node_modules/markdown-it/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js +0 -99
- package/node_modules/markdown-it/node_modules/entities/lib/esm/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/esm/package.json +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/node_modules/markdown-it/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/node_modules/markdown-it/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts +0 -96
- package/node_modules/markdown-it/node_modules/entities/lib/index.d.ts.map +0 -1
- package/node_modules/markdown-it/node_modules/entities/lib/index.js +0 -126
- package/node_modules/markdown-it/node_modules/entities/lib/index.js.map +0 -1
- package/node_modules/markdown-it/node_modules/linkify-it/index.mjs +0 -646
- package/node_modules/markdown-it/node_modules/linkify-it/lib/re.mjs +0 -193
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/P/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/S/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
- package/node_modules/markdown-it/node_modules/uc.micro/index.mjs +0 -8
- package/node_modules/markdown-it/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.d.ts +0 -157
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.js +0 -365
- package/node_modules/matrix-js-sdk/lib/oidc/authorize.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.d.ts +0 -22
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.js +0 -65
- package/node_modules/matrix-js-sdk/lib/oidc/discovery.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/error.d.ts +0 -18
- package/node_modules/matrix-js-sdk/lib/oidc/error.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/error.js +0 -35
- package/node_modules/matrix-js-sdk/lib/oidc/error.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/index.d.ts +0 -16
- package/node_modules/matrix-js-sdk/lib/oidc/index.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/index.js +0 -30
- package/node_modules/matrix-js-sdk/lib/oidc/index.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/register.d.ts +0 -70
- package/node_modules/matrix-js-sdk/lib/oidc/register.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/register.js +0 -134
- package/node_modules/matrix-js-sdk/lib/oidc/register.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.d.ts +0 -91
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js +0 -173
- package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/validate.d.ts +0 -78
- package/node_modules/matrix-js-sdk/lib/oidc/validate.d.ts.map +0 -1
- package/node_modules/matrix-js-sdk/lib/oidc/validate.js +0 -181
- package/node_modules/matrix-js-sdk/lib/oidc/validate.js.map +0 -1
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/LICENSE +0 -21
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/README.md +0 -134
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/index.d.ts +0 -23
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/index.js +0 -62
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/cjs/package.json +0 -1
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/esm/index.d.ts +0 -23
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/build/esm/index.js +0 -57
- package/node_modules/matrix-js-sdk/node_modules/jwt-decode/package.json +0 -81
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/LICENSE +0 -202
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/README.md +0 -87
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.js +0 -3751
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.js.map +0 -7
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.min.js +0 -2
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/browser/oidc-client-ts.min.js.map +0 -7
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js +0 -3671
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js.map +0 -7
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/esm/package.json +0 -4
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/types/oidc-client-ts.d.ts +0 -2003
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/types/tsdoc-metadata.json +0 -11
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js +0 -3719
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/dist/umd/oidc-client-ts.js.map +0 -7
- package/node_modules/matrix-js-sdk/node_modules/oidc-client-ts/package.json +0 -75
- package/node_modules/matrix-js-sdk/src/oidc/authorize.ts +0 -431
- package/node_modules/matrix-js-sdk/src/oidc/discovery.ts +0 -67
- package/node_modules/matrix-js-sdk/src/oidc/index.ts +0 -33
- package/node_modules/matrix-js-sdk/src/oidc/register.ts +0 -168
- package/node_modules/matrix-js-sdk/src/oidc/tokenRefresher.ts +0 -184
- package/node_modules/matrix-js-sdk/src/oidc/validate.ts +0 -265
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Port of python's argparse module, version 3.
|
|
2
|
-
// https://github.com/python/cpython/blob/v3.
|
|
1
|
+
// Port of python's argparse module, version 3.14.6:
|
|
2
|
+
// https://github.com/python/cpython/blob/v3.14.6/Lib/argparse.py
|
|
3
3
|
|
|
4
4
|
'use strict'
|
|
5
5
|
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
* 'integers', metavar='int', nargs='+', type=int,
|
|
25
25
|
* help='an integer to be summed')
|
|
26
26
|
* parser.add_argument(
|
|
27
|
-
* '--log',
|
|
27
|
+
* '--log',
|
|
28
28
|
* help='the file where the sum should be written')
|
|
29
29
|
* args = parser.parse_args()
|
|
30
|
-
* args.log
|
|
31
|
-
*
|
|
30
|
+
* with (open(args.log, 'w') if args.log is not None
|
|
31
|
+
* else contextlib.nullcontext(sys.stdout)) as log:
|
|
32
|
+
* log.write('%s' % sum(args.integers))
|
|
32
33
|
*
|
|
33
34
|
* The module contains the following public classes:
|
|
34
35
|
*
|
|
@@ -84,51 +85,51 @@ const _UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'
|
|
|
84
85
|
const assert = require('assert')
|
|
85
86
|
const util = require('util')
|
|
86
87
|
const fs = require('fs')
|
|
87
|
-
const sub = require('./
|
|
88
|
+
const sub = require('./sub')
|
|
88
89
|
const path = require('path')
|
|
89
90
|
const repr = util.inspect
|
|
90
91
|
|
|
91
|
-
function get_argv() {
|
|
92
|
+
function get_argv () {
|
|
92
93
|
// omit first argument (which is assumed to be interpreter - `node`, `coffee`, `ts-node`, etc.)
|
|
93
94
|
return process.argv.slice(1)
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
function get_terminal_size() {
|
|
97
|
+
function get_terminal_size () {
|
|
97
98
|
return {
|
|
98
99
|
columns: +process.env.COLUMNS || process.stdout.columns || 80
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
function hasattr(object, name) {
|
|
103
|
+
function hasattr (object, name) {
|
|
103
104
|
return Object.prototype.hasOwnProperty.call(object, name)
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
function getattr(object, name, value) {
|
|
107
|
+
function getattr (object, name, value) {
|
|
107
108
|
return hasattr(object, name) ? object[name] : value
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
function setattr(object, name, value) {
|
|
111
|
+
function setattr (object, name, value) {
|
|
111
112
|
object[name] = value
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
function setdefault(object, name, value) {
|
|
115
|
+
function setdefault (object, name, value) {
|
|
115
116
|
if (!hasattr(object, name)) object[name] = value
|
|
116
117
|
return object[name]
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
function delattr(object, name) {
|
|
120
|
+
function delattr (object, name) {
|
|
120
121
|
delete object[name]
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
function range(from, to, step=1) {
|
|
124
|
+
function range (from, to, step = 1) {
|
|
124
125
|
// range(10) is equivalent to range(0, 10)
|
|
125
|
-
if (arguments.length === 1) [
|
|
126
|
+
if (arguments.length === 1) [to, from] = [from, 0]
|
|
126
127
|
if (typeof from !== 'number' || typeof to !== 'number' || typeof step !== 'number') {
|
|
127
128
|
throw new TypeError('argument cannot be interpreted as an integer')
|
|
128
129
|
}
|
|
129
130
|
if (step === 0) throw new TypeError('range() arg 3 must not be zero')
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
const result = []
|
|
132
133
|
if (step > 0) {
|
|
133
134
|
for (let i = from; i < to; i += step) result.push(i)
|
|
134
135
|
} else {
|
|
@@ -137,13 +138,13 @@ function range(from, to, step=1) {
|
|
|
137
138
|
return result
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
function splitlines(str, keepends = false) {
|
|
141
|
+
function splitlines (str, keepends = false) {
|
|
141
142
|
let result
|
|
142
143
|
if (!keepends) {
|
|
143
144
|
result = str.split(/\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/)
|
|
144
145
|
} else {
|
|
145
146
|
result = []
|
|
146
|
-
|
|
147
|
+
const parts = str.split(/(\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029])/)
|
|
147
148
|
for (let i = 0; i < parts.length; i += 2) {
|
|
148
149
|
result.push(parts[i] + (i + 1 < parts.length ? parts[i + 1] : ''))
|
|
149
150
|
}
|
|
@@ -152,30 +153,29 @@ function splitlines(str, keepends = false) {
|
|
|
152
153
|
return result
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
function _string_lstrip(string, prefix_chars) {
|
|
156
|
+
function _string_lstrip (string, prefix_chars) {
|
|
156
157
|
let idx = 0
|
|
157
158
|
while (idx < string.length && prefix_chars.includes(string[idx])) idx++
|
|
158
159
|
return idx ? string.slice(idx) : string
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
function _string_split(string, sep, maxsplit) {
|
|
162
|
+
function _string_split (string, sep, maxsplit) {
|
|
162
163
|
let result = string.split(sep)
|
|
163
164
|
if (result.length > maxsplit) {
|
|
164
|
-
result = result.slice(0, maxsplit).concat([
|
|
165
|
+
result = result.slice(0, maxsplit).concat([result.slice(maxsplit).join(sep)])
|
|
165
166
|
}
|
|
166
167
|
return result
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
function
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
if (array1[i] !== array2[i]) return false
|
|
170
|
+
function _string_to_number (string) {
|
|
171
|
+
if (typeof string === 'string' && !/(?:^|\D)_|_(?:\D|$)/.test(string)) {
|
|
172
|
+
string = string.replace(/_/g, '')
|
|
173
173
|
}
|
|
174
|
-
return
|
|
174
|
+
return Number(string)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function _array_remove(array, item) {
|
|
178
|
-
|
|
177
|
+
function _array_remove (array, item) {
|
|
178
|
+
const idx = array.indexOf(item)
|
|
179
179
|
if (idx === -1) throw new TypeError(sub('%r not in list', item))
|
|
180
180
|
array.splice(idx, 1)
|
|
181
181
|
}
|
|
@@ -183,11 +183,13 @@ function _array_remove(array, item) {
|
|
|
183
183
|
// normalize choices to array;
|
|
184
184
|
// this isn't required in python because `in` and `map` operators work with anything,
|
|
185
185
|
// but in js dealing with multiple types here is too clunky
|
|
186
|
-
function _choices_to_array(choices) {
|
|
186
|
+
function _choices_to_array (choices) {
|
|
187
187
|
if (choices === undefined) {
|
|
188
188
|
return []
|
|
189
189
|
} else if (Array.isArray(choices)) {
|
|
190
190
|
return choices
|
|
191
|
+
} else if (choices instanceof Map) {
|
|
192
|
+
return Array.from(choices.keys())
|
|
191
193
|
} else if (choices !== null && typeof choices[Symbol.iterator] === 'function') {
|
|
192
194
|
return Array.from(choices)
|
|
193
195
|
} else if (typeof choices === 'object' && choices !== null) {
|
|
@@ -198,10 +200,10 @@ function _choices_to_array(choices) {
|
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
// decorator that allows a class to be called without new
|
|
201
|
-
function _callable(cls) {
|
|
202
|
-
|
|
203
|
+
function _callable (cls) {
|
|
204
|
+
const result = { // object is needed for inferred class name
|
|
203
205
|
[cls.name]: function (...args) {
|
|
204
|
-
|
|
206
|
+
const this_class = new.target === result || !new.target
|
|
205
207
|
return Reflect.construct(cls, args, this_class ? cls : new.target)
|
|
206
208
|
}
|
|
207
209
|
}
|
|
@@ -211,45 +213,11 @@ function _callable(cls) {
|
|
|
211
213
|
return result[cls.name]
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
function _alias(object, from, to) {
|
|
215
|
-
try {
|
|
216
|
-
let name = object.constructor.name
|
|
217
|
-
Object.defineProperty(object, from, {
|
|
218
|
-
value: util.deprecate(object[to], sub('%s.%s() is renamed to %s.%s()',
|
|
219
|
-
name, from, name, to)),
|
|
220
|
-
enumerable: false
|
|
221
|
-
})
|
|
222
|
-
} catch {}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// decorator that allows snake_case class methods to be called with camelCase and vice versa
|
|
226
|
-
function _camelcase_alias(_class) {
|
|
227
|
-
for (let name of Object.getOwnPropertyNames(_class.prototype)) {
|
|
228
|
-
let camelcase = name.replace(/\w_[a-z]/g, s => s[0] + s[2].toUpperCase())
|
|
229
|
-
if (camelcase !== name) _alias(_class.prototype, camelcase, name)
|
|
230
|
-
}
|
|
231
|
-
return _class
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function _to_legacy_name(key) {
|
|
235
|
-
key = key.replace(/\w_[a-z]/g, s => s[0] + s[2].toUpperCase())
|
|
236
|
-
if (key === 'default') key = 'defaultValue'
|
|
237
|
-
if (key === 'const') key = 'constant'
|
|
238
|
-
return key
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function _to_new_name(key) {
|
|
242
|
-
if (key === 'defaultValue') key = 'default'
|
|
243
|
-
if (key === 'constant') key = 'const'
|
|
244
|
-
key = key.replace(/[A-Z]/g, c => '_' + c.toLowerCase())
|
|
245
|
-
return key
|
|
246
|
-
}
|
|
247
|
-
|
|
248
216
|
// parse options
|
|
249
|
-
|
|
250
|
-
function _parse_opts(args, descriptor) {
|
|
251
|
-
function get_name() {
|
|
252
|
-
|
|
217
|
+
const no_default = Symbol('no_default_value')
|
|
218
|
+
function _parse_opts (args, descriptor) {
|
|
219
|
+
function get_name () {
|
|
220
|
+
const stack = new Error().stack.split('\n')
|
|
253
221
|
.map(x => x.match(/^ at (.*) \(.*\)$/))
|
|
254
222
|
.filter(Boolean)
|
|
255
223
|
.map(m => m[1])
|
|
@@ -262,63 +230,23 @@ function _parse_opts(args, descriptor) {
|
|
|
262
230
|
|
|
263
231
|
args = Array.from(args)
|
|
264
232
|
let kwargs = {}
|
|
265
|
-
|
|
266
|
-
|
|
233
|
+
const result = []
|
|
234
|
+
const last_opt = args.length && args[args.length - 1]
|
|
267
235
|
|
|
268
236
|
if (typeof last_opt === 'object' && last_opt !== null && !Array.isArray(last_opt) &&
|
|
269
237
|
(!last_opt.constructor || last_opt.constructor.name === 'Object')) {
|
|
270
238
|
kwargs = Object.assign({}, args.pop())
|
|
271
239
|
}
|
|
272
240
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
let old_name = _to_legacy_name(key)
|
|
277
|
-
if (old_name !== key && (old_name in kwargs)) {
|
|
278
|
-
if (key in kwargs) {
|
|
279
|
-
// default and defaultValue specified at the same time, happens often in old tests
|
|
280
|
-
//throw new TypeError(sub('%s() got multiple values for argument %r', get_name(), key))
|
|
281
|
-
} else {
|
|
282
|
-
kwargs[key] = kwargs[old_name]
|
|
283
|
-
}
|
|
284
|
-
renames.push([ old_name, key ])
|
|
285
|
-
delete kwargs[old_name]
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (renames.length) {
|
|
289
|
-
let name = get_name()
|
|
290
|
-
deprecate('camelcase_' + name, sub('%s(): following options are renamed: %s',
|
|
291
|
-
name, renames.map(([ a, b ]) => sub('%r -> %r', a, b))))
|
|
292
|
-
}
|
|
293
|
-
// end
|
|
294
|
-
|
|
295
|
-
let missing_positionals = []
|
|
296
|
-
let positional_count = args.length
|
|
241
|
+
const missing_positionals = []
|
|
242
|
+
const positional_count = args.length
|
|
243
|
+
let keyword_only = false
|
|
297
244
|
|
|
298
|
-
for (
|
|
299
|
-
if (key
|
|
245
|
+
for (const [key, def] of Object.entries(descriptor)) {
|
|
246
|
+
if (key === '*') {
|
|
247
|
+
keyword_only = true
|
|
248
|
+
} else if (key[0] === '*') {
|
|
300
249
|
if (key.length > 0 && key[1] === '*') {
|
|
301
|
-
// LEGACY (v1 compatibility): camelcase
|
|
302
|
-
let renames = []
|
|
303
|
-
for (let key of Object.keys(kwargs)) {
|
|
304
|
-
let new_name = _to_new_name(key)
|
|
305
|
-
if (new_name !== key && (key in kwargs)) {
|
|
306
|
-
if (new_name in kwargs) {
|
|
307
|
-
// default and defaultValue specified at the same time, happens often in old tests
|
|
308
|
-
//throw new TypeError(sub('%s() got multiple values for argument %r', get_name(), new_name))
|
|
309
|
-
} else {
|
|
310
|
-
kwargs[new_name] = kwargs[key]
|
|
311
|
-
}
|
|
312
|
-
renames.push([ key, new_name ])
|
|
313
|
-
delete kwargs[key]
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (renames.length) {
|
|
317
|
-
let name = get_name()
|
|
318
|
-
deprecate('camelcase_' + name, sub('%s(): following options are renamed: %s',
|
|
319
|
-
name, renames.map(([ a, b ]) => sub('%r -> %r', a, b))))
|
|
320
|
-
}
|
|
321
|
-
// end
|
|
322
250
|
result.push(kwargs)
|
|
323
251
|
kwargs = {}
|
|
324
252
|
} else {
|
|
@@ -330,7 +258,7 @@ function _parse_opts(args, descriptor) {
|
|
|
330
258
|
} else if (key in kwargs) {
|
|
331
259
|
result.push(kwargs[key])
|
|
332
260
|
delete kwargs[key]
|
|
333
|
-
} else if (args.length > 0) {
|
|
261
|
+
} else if (args.length > 0 && !keyword_only) {
|
|
334
262
|
result.push(args.shift())
|
|
335
263
|
} else if (def !== no_default) {
|
|
336
264
|
result.push(def)
|
|
@@ -345,8 +273,12 @@ function _parse_opts(args, descriptor) {
|
|
|
345
273
|
}
|
|
346
274
|
|
|
347
275
|
if (args.length) {
|
|
348
|
-
|
|
349
|
-
|
|
276
|
+
const entries = Object.entries(descriptor)
|
|
277
|
+
const marker = entries.findIndex(([k]) => k === '*')
|
|
278
|
+
const positional_entries = (marker === -1 ? entries : entries.slice(0, marker))
|
|
279
|
+
.filter(([k]) => k[0] !== '*')
|
|
280
|
+
const from = positional_entries.filter(([, v]) => v !== no_default).length
|
|
281
|
+
const to = positional_entries.length
|
|
350
282
|
throw new TypeError(sub('%s() takes %s positional argument%s but %s %s given',
|
|
351
283
|
get_name(),
|
|
352
284
|
from === to ? sub('from %s to %s', from, to) : to,
|
|
@@ -356,9 +288,9 @@ function _parse_opts(args, descriptor) {
|
|
|
356
288
|
}
|
|
357
289
|
|
|
358
290
|
if (missing_positionals.length) {
|
|
359
|
-
|
|
291
|
+
const strs = missing_positionals.map(repr)
|
|
360
292
|
if (strs.length > 1) strs[strs.length - 1] = 'and ' + strs[strs.length - 1]
|
|
361
|
-
|
|
293
|
+
const str_joined = strs.join(strs.length === 2 ? '' : ', ')
|
|
362
294
|
throw new TypeError(sub('%s() missing %i required positional argument%s: %s',
|
|
363
295
|
get_name(), strs.length, strs.length === 1 ? '' : 's', str_joined))
|
|
364
296
|
}
|
|
@@ -366,17 +298,10 @@ function _parse_opts(args, descriptor) {
|
|
|
366
298
|
return result
|
|
367
299
|
}
|
|
368
300
|
|
|
369
|
-
let _deprecations = {}
|
|
370
|
-
function deprecate(id, string) {
|
|
371
|
-
_deprecations[id] = _deprecations[id] || util.deprecate(() => {}, string)
|
|
372
|
-
_deprecations[id]()
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
301
|
// =============================
|
|
377
302
|
// Utility functions and classes
|
|
378
303
|
// =============================
|
|
379
|
-
function _AttributeHolder(cls = Object) {
|
|
304
|
+
function _AttributeHolder (cls = Object) {
|
|
380
305
|
/*
|
|
381
306
|
* Abstract base class that provides __repr__.
|
|
382
307
|
*
|
|
@@ -387,14 +312,14 @@ function _AttributeHolder(cls = Object) {
|
|
|
387
312
|
*/
|
|
388
313
|
|
|
389
314
|
return class _AttributeHolder extends cls {
|
|
390
|
-
[util.inspect.custom]() {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
for (
|
|
315
|
+
[util.inspect.custom] () {
|
|
316
|
+
const type_name = this.constructor.name
|
|
317
|
+
const arg_strings = []
|
|
318
|
+
const star_args = {}
|
|
319
|
+
for (const arg of this._get_args()) {
|
|
395
320
|
arg_strings.push(repr(arg))
|
|
396
321
|
}
|
|
397
|
-
for (
|
|
322
|
+
for (const [name, value] of this._get_kwargs()) {
|
|
398
323
|
if (/^[a-z_][a-z0-9_$]*$/i.test(name)) {
|
|
399
324
|
arg_strings.push(sub('%s=%r', name, value))
|
|
400
325
|
} else {
|
|
@@ -407,33 +332,37 @@ function _AttributeHolder(cls = Object) {
|
|
|
407
332
|
return sub('%s(%s)', type_name, arg_strings.join(', '))
|
|
408
333
|
}
|
|
409
334
|
|
|
410
|
-
toString() {
|
|
335
|
+
toString () {
|
|
411
336
|
return this[util.inspect.custom]()
|
|
412
337
|
}
|
|
413
338
|
|
|
414
|
-
_get_kwargs() {
|
|
339
|
+
_get_kwargs () {
|
|
415
340
|
return Object.entries(this)
|
|
416
341
|
}
|
|
417
342
|
|
|
418
|
-
_get_args() {
|
|
343
|
+
_get_args () {
|
|
419
344
|
return []
|
|
420
345
|
}
|
|
421
346
|
}
|
|
422
347
|
}
|
|
423
348
|
|
|
424
349
|
|
|
425
|
-
function _copy_items(items) {
|
|
426
|
-
if (items === undefined) {
|
|
350
|
+
function _copy_items (items) {
|
|
351
|
+
if (items === undefined || items === null) {
|
|
427
352
|
return []
|
|
428
353
|
}
|
|
429
354
|
return items.slice(0)
|
|
430
355
|
}
|
|
431
356
|
|
|
357
|
+
function _identity (value) {
|
|
358
|
+
return value
|
|
359
|
+
}
|
|
360
|
+
|
|
432
361
|
|
|
433
362
|
// ===============
|
|
434
363
|
// Formatting Help
|
|
435
364
|
// ===============
|
|
436
|
-
const HelpFormatter =
|
|
365
|
+
const HelpFormatter = _callable(class HelpFormatter {
|
|
437
366
|
/*
|
|
438
367
|
* Formatter for generating usage messages and argument help strings.
|
|
439
368
|
*
|
|
@@ -441,17 +370,19 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
441
370
|
* provided by the class are considered an implementation detail.
|
|
442
371
|
*/
|
|
443
372
|
|
|
444
|
-
constructor() {
|
|
373
|
+
constructor () {
|
|
445
374
|
let [
|
|
446
375
|
prog,
|
|
447
376
|
indent_increment,
|
|
448
377
|
max_help_position,
|
|
449
|
-
width
|
|
378
|
+
width,
|
|
379
|
+
color
|
|
450
380
|
] = _parse_opts(arguments, {
|
|
451
381
|
prog: no_default,
|
|
452
382
|
indent_increment: 2,
|
|
453
383
|
max_help_position: 24,
|
|
454
|
-
width: undefined
|
|
384
|
+
width: undefined,
|
|
385
|
+
color: true
|
|
455
386
|
})
|
|
456
387
|
|
|
457
388
|
// default setting for width
|
|
@@ -460,6 +391,7 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
460
391
|
width -= 2
|
|
461
392
|
}
|
|
462
393
|
|
|
394
|
+
this._set_color(color)
|
|
463
395
|
this._prog = prog
|
|
464
396
|
this._indent_increment = indent_increment
|
|
465
397
|
this._max_help_position = Math.min(max_help_position,
|
|
@@ -477,64 +409,80 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
477
409
|
this._long_break_matcher = /\n\n\n+/g
|
|
478
410
|
}
|
|
479
411
|
|
|
412
|
+
_set_color (color) {
|
|
413
|
+
const { can_colorize, decolor, get_theme } = require('./_colorize')
|
|
414
|
+
|
|
415
|
+
if (color && can_colorize()) {
|
|
416
|
+
this._theme = get_theme({ force_color: true }).argparse
|
|
417
|
+
this._decolor = decolor
|
|
418
|
+
} else {
|
|
419
|
+
this._theme = get_theme({ force_no_color: true }).argparse
|
|
420
|
+
this._decolor = _identity
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
480
424
|
// ===============================
|
|
481
425
|
// Section and indentation methods
|
|
482
426
|
// ===============================
|
|
483
|
-
_indent() {
|
|
427
|
+
_indent () {
|
|
484
428
|
this._current_indent += this._indent_increment
|
|
485
429
|
this._level += 1
|
|
486
430
|
}
|
|
487
431
|
|
|
488
|
-
_dedent() {
|
|
432
|
+
_dedent () {
|
|
489
433
|
this._current_indent -= this._indent_increment
|
|
490
434
|
assert(this._current_indent >= 0, 'Indent decreased below 0.')
|
|
491
435
|
this._level -= 1
|
|
492
436
|
}
|
|
493
437
|
|
|
494
|
-
_add_item(func, args) {
|
|
495
|
-
this._current_section.items.push([
|
|
438
|
+
_add_item (func, args) {
|
|
439
|
+
this._current_section.items.push([func, args])
|
|
496
440
|
}
|
|
497
441
|
|
|
498
442
|
// ========================
|
|
499
443
|
// Message building methods
|
|
500
444
|
// ========================
|
|
501
|
-
start_section(heading) {
|
|
445
|
+
start_section (heading) {
|
|
502
446
|
this._indent()
|
|
503
|
-
|
|
447
|
+
const section = this._Section(this, this._current_section, heading)
|
|
504
448
|
this._add_item(section.format_help.bind(section), [])
|
|
505
449
|
this._current_section = section
|
|
506
450
|
}
|
|
507
451
|
|
|
508
|
-
end_section() {
|
|
452
|
+
end_section () {
|
|
509
453
|
this._current_section = this._current_section.parent
|
|
510
454
|
this._dedent()
|
|
511
455
|
}
|
|
512
456
|
|
|
513
|
-
add_text(text) {
|
|
457
|
+
add_text (text) {
|
|
514
458
|
if (text !== SUPPRESS && text !== undefined) {
|
|
515
459
|
this._add_item(this._format_text.bind(this), [text])
|
|
516
460
|
}
|
|
517
461
|
}
|
|
518
462
|
|
|
519
|
-
add_usage(usage, actions, groups, prefix = undefined) {
|
|
463
|
+
add_usage (usage, actions, groups, prefix = undefined) {
|
|
520
464
|
if (usage !== SUPPRESS) {
|
|
521
|
-
|
|
465
|
+
const args = [usage, actions, groups, prefix]
|
|
522
466
|
this._add_item(this._format_usage.bind(this), args)
|
|
523
467
|
}
|
|
524
468
|
}
|
|
525
469
|
|
|
526
|
-
add_argument(action) {
|
|
470
|
+
add_argument (action) {
|
|
527
471
|
if (action.help !== SUPPRESS) {
|
|
528
472
|
|
|
529
473
|
// find all invocations
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
474
|
+
const get_invocation = action => this._decolor(this._format_action_invocation(action))
|
|
475
|
+
const invocation_lengths = [
|
|
476
|
+
get_invocation(action).length + this._current_indent
|
|
477
|
+
]
|
|
478
|
+
for (const subaction of this._iter_indented_subactions(action)) {
|
|
479
|
+
invocation_lengths.push(
|
|
480
|
+
get_invocation(subaction).length + this._current_indent
|
|
481
|
+
)
|
|
533
482
|
}
|
|
534
483
|
|
|
535
484
|
// update the maximum item length
|
|
536
|
-
|
|
537
|
-
let action_length = invocation_length + this._current_indent
|
|
485
|
+
const action_length = Math.max(...invocation_lengths)
|
|
538
486
|
this._action_max_length = Math.max(this._action_max_length,
|
|
539
487
|
action_length)
|
|
540
488
|
|
|
@@ -543,8 +491,8 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
543
491
|
}
|
|
544
492
|
}
|
|
545
493
|
|
|
546
|
-
add_arguments(actions) {
|
|
547
|
-
for (
|
|
494
|
+
add_arguments (actions) {
|
|
495
|
+
for (const action of actions) {
|
|
548
496
|
this.add_argument(action)
|
|
549
497
|
}
|
|
550
498
|
}
|
|
@@ -552,7 +500,7 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
552
500
|
// =======================
|
|
553
501
|
// Help-formatting methods
|
|
554
502
|
// =======================
|
|
555
|
-
format_help() {
|
|
503
|
+
format_help () {
|
|
556
504
|
let help = this._root_section.format_help()
|
|
557
505
|
if (help) {
|
|
558
506
|
help = help.replace(this._long_break_matcher, '\n\n')
|
|
@@ -561,79 +509,69 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
561
509
|
return help
|
|
562
510
|
}
|
|
563
511
|
|
|
564
|
-
_join_parts(part_strings) {
|
|
512
|
+
_join_parts (part_strings) {
|
|
565
513
|
return part_strings.filter(part => part && part !== SUPPRESS).join('')
|
|
566
514
|
}
|
|
567
515
|
|
|
568
|
-
_format_usage(usage, actions, groups, prefix) {
|
|
516
|
+
_format_usage (usage, actions, groups, prefix) {
|
|
517
|
+
const t = this._theme
|
|
518
|
+
|
|
569
519
|
if (prefix === undefined) {
|
|
570
520
|
prefix = 'usage: '
|
|
571
521
|
}
|
|
572
522
|
|
|
573
523
|
// if usage is specified, use that
|
|
574
524
|
if (usage !== undefined) {
|
|
575
|
-
usage = sub(usage, {
|
|
525
|
+
usage = t.prog_extra + sub(usage, {
|
|
526
|
+
prog: t.prog + this._prog + t.reset + t.prog_extra
|
|
527
|
+
}) + t.reset
|
|
576
528
|
|
|
577
529
|
// if no optionals or positionals are available, usage is just prog
|
|
578
530
|
} else if (usage === undefined && !actions.length) {
|
|
579
|
-
usage =
|
|
531
|
+
usage = t.prog + this._prog + t.reset
|
|
580
532
|
|
|
581
533
|
// if optionals and positionals are available, calculate usage
|
|
582
534
|
} else if (usage === undefined) {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
// split optionals from positionals
|
|
586
|
-
let optionals = []
|
|
587
|
-
let positionals = []
|
|
588
|
-
for (let action of actions) {
|
|
589
|
-
if (action.option_strings.length) {
|
|
590
|
-
optionals.push(action)
|
|
591
|
-
} else {
|
|
592
|
-
positionals.push(action)
|
|
593
|
-
}
|
|
594
|
-
}
|
|
535
|
+
const prog = sub('%(prog)s', { prog: this._prog })
|
|
595
536
|
|
|
537
|
+
const [parts, pos_start] = this._get_actions_usage_parts(actions, groups)
|
|
596
538
|
// build full usage string
|
|
597
|
-
|
|
598
|
-
usage = [ prog, action_usage ].map(String).join(' ')
|
|
539
|
+
usage = [prog].concat(parts).filter(Boolean).join(' ')
|
|
599
540
|
|
|
600
541
|
// wrap the usage parts if it's too long
|
|
601
|
-
|
|
602
|
-
if (prefix.length + usage.length > text_width) {
|
|
542
|
+
const text_width = this._width - this._current_indent
|
|
543
|
+
if (prefix.length + this._decolor(usage).length > text_width) {
|
|
603
544
|
|
|
604
545
|
// break usage into wrappable parts
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
let pos_usage = this._format_actions_usage(positionals, groups)
|
|
608
|
-
let opt_parts = opt_usage.match(part_regexp) || []
|
|
609
|
-
let pos_parts = pos_usage.match(part_regexp) || []
|
|
610
|
-
assert(opt_parts.join(' ') === opt_usage)
|
|
611
|
-
assert(pos_parts.join(' ') === pos_usage)
|
|
546
|
+
const opt_parts = parts.slice(0, pos_start)
|
|
547
|
+
const pos_parts = parts.slice(pos_start)
|
|
612
548
|
|
|
613
549
|
// helper for wrapping lines
|
|
614
|
-
|
|
615
|
-
|
|
550
|
+
const get_lines = (parts, indent, prefix = undefined) => {
|
|
551
|
+
const lines = []
|
|
616
552
|
let line = []
|
|
553
|
+
const indent_length = indent.length
|
|
617
554
|
let line_len
|
|
618
555
|
if (prefix !== undefined) {
|
|
619
556
|
line_len = prefix.length - 1
|
|
620
557
|
} else {
|
|
621
|
-
line_len =
|
|
558
|
+
line_len = indent_length - 1
|
|
622
559
|
}
|
|
623
|
-
for (
|
|
624
|
-
|
|
560
|
+
for (const part of parts) {
|
|
561
|
+
const part_len = this._decolor(part).length
|
|
562
|
+
if (line_len + 1 + part_len > text_width && line.length) {
|
|
625
563
|
lines.push(indent + line.join(' '))
|
|
626
564
|
line = []
|
|
627
|
-
line_len =
|
|
565
|
+
line_len = indent_length - 1
|
|
628
566
|
}
|
|
629
567
|
line.push(part)
|
|
630
|
-
line_len +=
|
|
568
|
+
line_len += part_len + 1
|
|
631
569
|
}
|
|
632
570
|
if (line.length) {
|
|
633
571
|
lines.push(indent + line.join(' '))
|
|
634
572
|
}
|
|
635
573
|
if (prefix !== undefined) {
|
|
636
|
-
lines[0] = lines[0].slice(
|
|
574
|
+
lines[0] = lines[0].slice(indent_length)
|
|
637
575
|
}
|
|
638
576
|
return lines
|
|
639
577
|
}
|
|
@@ -641,8 +579,9 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
641
579
|
let lines
|
|
642
580
|
|
|
643
581
|
// if prog is short, follow it with optionals or positionals
|
|
644
|
-
|
|
645
|
-
|
|
582
|
+
const prog_len = this._decolor(prog).length
|
|
583
|
+
if (prefix.length + prog_len <= 0.75 * text_width) {
|
|
584
|
+
const indent = ' '.repeat(prefix.length + prog_len + 1)
|
|
646
585
|
if (opt_parts.length) {
|
|
647
586
|
lines = get_lines([prog].concat(opt_parts), indent, prefix)
|
|
648
587
|
lines = lines.concat(get_lines(pos_parts, indent))
|
|
@@ -654,8 +593,8 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
654
593
|
|
|
655
594
|
// if prog is long, put it on its own line
|
|
656
595
|
} else {
|
|
657
|
-
|
|
658
|
-
|
|
596
|
+
const indent = ' '.repeat(prefix.length)
|
|
597
|
+
const parts = [].concat(opt_parts).concat(pos_parts)
|
|
659
598
|
lines = get_lines(parts, indent)
|
|
660
599
|
if (lines.length > 1) {
|
|
661
600
|
lines = []
|
|
@@ -668,178 +607,214 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
668
607
|
// join lines into usage
|
|
669
608
|
usage = lines.join('\n')
|
|
670
609
|
}
|
|
610
|
+
|
|
611
|
+
if (usage.startsWith(prog)) usage = usage.slice(prog.length)
|
|
612
|
+
usage = t.prog + prog + t.reset + usage
|
|
671
613
|
}
|
|
672
614
|
|
|
673
615
|
// prefix with 'usage:'
|
|
674
|
-
return
|
|
616
|
+
return t.usage + prefix + t.reset + usage + '\n\n'
|
|
675
617
|
}
|
|
676
618
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
619
|
+
_is_long_option (string) {
|
|
620
|
+
return string.length > 2
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
_get_actions_usage_parts (actions, groups) {
|
|
624
|
+
/* Get usage parts with split index for optionals/positionals.
|
|
625
|
+
|
|
626
|
+
* Returns [parts, pos_start] where pos_start is the index in parts
|
|
627
|
+
* where positionals begin. This preserves mutually exclusive group
|
|
628
|
+
* formatting across the optionals/positionals boundary (gh-75949).
|
|
629
|
+
*/
|
|
630
|
+
actions = actions.filter(action => action.help !== SUPPRESS)
|
|
631
|
+
|
|
632
|
+
// group actions by mutually exclusive groups
|
|
633
|
+
const action_groups = new Map(actions.map(action => [action, undefined]))
|
|
634
|
+
for (const group of groups) {
|
|
635
|
+
for (const action of group._group_actions) {
|
|
636
|
+
if (action_groups.has(action)) {
|
|
637
|
+
action_groups.set(action, group)
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// positional arguments keep their position
|
|
643
|
+
const positionals = []
|
|
644
|
+
for (const action of actions) {
|
|
645
|
+
if (!action.option_strings.length) {
|
|
646
|
+
const group = action_groups.get(action)
|
|
647
|
+
action_groups.delete(action)
|
|
648
|
+
if (group) {
|
|
649
|
+
const group_actions = []
|
|
650
|
+
for (const action2 of group._group_actions) {
|
|
651
|
+
if (action2.option_strings.length && action_groups.has(action2)) {
|
|
652
|
+
const action_group = action_groups.get(action2)
|
|
653
|
+
action_groups.delete(action2)
|
|
654
|
+
if (action_group) {
|
|
655
|
+
group_actions.push(action2)
|
|
656
|
+
}
|
|
712
657
|
}
|
|
713
658
|
}
|
|
714
|
-
|
|
715
|
-
|
|
659
|
+
group_actions.push(action)
|
|
660
|
+
positionals.push([group.required, group_actions])
|
|
661
|
+
} else {
|
|
662
|
+
positionals.push([undefined, [action]])
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// the remaining optional arguments are sorted by the position of
|
|
668
|
+
// the first option in the group
|
|
669
|
+
const optionals = []
|
|
670
|
+
for (const action of actions) {
|
|
671
|
+
if (action.option_strings.length && action_groups.has(action)) {
|
|
672
|
+
const group = action_groups.get(action)
|
|
673
|
+
action_groups.delete(action)
|
|
674
|
+
if (group) {
|
|
675
|
+
const group_actions = [action]
|
|
676
|
+
for (const action2 of group._group_actions) {
|
|
677
|
+
if (action2.option_strings.length && action_groups.has(action2)) {
|
|
678
|
+
const action_group = action_groups.get(action2)
|
|
679
|
+
action_groups.delete(action2)
|
|
680
|
+
if (action_group) {
|
|
681
|
+
group_actions.push(action2)
|
|
682
|
+
}
|
|
683
|
+
}
|
|
716
684
|
}
|
|
685
|
+
optionals.push([group.required, group_actions])
|
|
686
|
+
} else {
|
|
687
|
+
optionals.push([undefined, [action]])
|
|
717
688
|
}
|
|
718
689
|
}
|
|
719
690
|
}
|
|
720
691
|
|
|
721
692
|
// collect all actions format strings
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
693
|
+
const parts = []
|
|
694
|
+
const t = this._theme
|
|
695
|
+
let pos_start
|
|
696
|
+
const action_sets = optionals.concat(positionals)
|
|
697
|
+
for (let i = 0; i < action_sets.length; i++) {
|
|
698
|
+
const [required, group] = action_sets[i]
|
|
699
|
+
const start = parts.length
|
|
700
|
+
if (i === optionals.length) {
|
|
701
|
+
pos_start = start
|
|
702
|
+
}
|
|
703
|
+
const in_group = group.length > 1
|
|
704
|
+
for (const action of group) {
|
|
705
|
+
let part
|
|
734
706
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
707
|
+
// produce all arg strings
|
|
708
|
+
if (!action.option_strings.length) {
|
|
709
|
+
const default_value = this._get_default_metavar_for_positional(action)
|
|
710
|
+
part = this._format_args(action, default_value)
|
|
739
711
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (part[0] === '[' && part[part.length - 1] === ']') {
|
|
712
|
+
// if it's in a group, strip the outer []
|
|
713
|
+
if (in_group && part[0] === '[' && part[part.length - 1] === ']') {
|
|
743
714
|
part = part.slice(1, -1)
|
|
744
715
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
// add the action string to the list
|
|
748
|
-
parts.push(part)
|
|
749
|
-
|
|
750
|
-
// produce the first way to invoke the option in brackets
|
|
751
|
-
} else {
|
|
752
|
-
let option_string = action.option_strings[0]
|
|
753
|
-
let part
|
|
754
|
-
|
|
755
|
-
// if the Optional doesn't take a value, format is:
|
|
756
|
-
// -s or --long
|
|
757
|
-
if (action.nargs === 0) {
|
|
758
|
-
part = action.format_usage()
|
|
716
|
+
part = t.summary_action + part + t.reset
|
|
759
717
|
|
|
760
|
-
//
|
|
761
|
-
// -s ARGS or --long ARGS
|
|
718
|
+
// produce the first way to invoke the option in brackets
|
|
762
719
|
} else {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
720
|
+
const option_string = action.option_strings[0]
|
|
721
|
+
const option_color = this._is_long_option(option_string)
|
|
722
|
+
? t.summary_long_option
|
|
723
|
+
: t.summary_short_option
|
|
724
|
+
|
|
725
|
+
// if the Optional doesn't take a value, format is:
|
|
726
|
+
// -s or --long
|
|
727
|
+
if (action.nargs === 0) {
|
|
728
|
+
part = action.format_usage()
|
|
729
|
+
part = option_color + part + t.reset
|
|
730
|
+
|
|
731
|
+
// if the Optional takes a value, format is:
|
|
732
|
+
// -s ARGS or --long ARGS
|
|
733
|
+
} else {
|
|
734
|
+
const default_value = this._get_default_metavar_for_optional(action)
|
|
735
|
+
const args_string = this._format_args(action, default_value)
|
|
736
|
+
part = option_color + option_string + ' ' +
|
|
737
|
+
t.summary_label + args_string + t.reset
|
|
738
|
+
}
|
|
767
739
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
740
|
+
// make it look optional if it's not required or in a group
|
|
741
|
+
if (!(action.required || required || in_group)) {
|
|
742
|
+
part = sub('[%s]', part)
|
|
743
|
+
}
|
|
771
744
|
}
|
|
772
745
|
|
|
773
746
|
// add the action string to the list
|
|
774
747
|
parts.push(part)
|
|
775
748
|
}
|
|
776
|
-
}
|
|
777
749
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
750
|
+
if (in_group) {
|
|
751
|
+
parts[start] = (required ? '(' : '[') + parts[start]
|
|
752
|
+
for (let i = start; i < parts.length - 1; i++) {
|
|
753
|
+
parts[i] += ' |'
|
|
754
|
+
}
|
|
755
|
+
parts[parts.length - 1] += required ? ')' : ']'
|
|
756
|
+
}
|
|
781
757
|
}
|
|
782
758
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
text = text.replace(/([\[(]) /g, '$1')
|
|
788
|
-
text = text.replace(/ ([\])])/g, '$1')
|
|
789
|
-
text = text.replace(/[\[(] *[\])]/g, '')
|
|
790
|
-
text = text.replace(/\(([^|]*)\)/g, '$1', text)
|
|
791
|
-
text = text.trim()
|
|
792
|
-
|
|
793
|
-
// return the text
|
|
794
|
-
return text
|
|
759
|
+
if (pos_start === undefined) {
|
|
760
|
+
pos_start = parts.length
|
|
761
|
+
}
|
|
762
|
+
return [parts, pos_start]
|
|
795
763
|
}
|
|
796
764
|
|
|
797
|
-
_format_text(text) {
|
|
765
|
+
_format_text (text) {
|
|
798
766
|
if (text.includes('%(prog)')) {
|
|
799
767
|
text = sub(text, { prog: this._prog })
|
|
800
768
|
}
|
|
801
|
-
|
|
802
|
-
|
|
769
|
+
const text_width = Math.max(this._width - this._current_indent, 11)
|
|
770
|
+
const indent = ' '.repeat(this._current_indent)
|
|
803
771
|
return this._fill_text(text, text_width, indent) + '\n\n'
|
|
804
772
|
}
|
|
805
773
|
|
|
806
|
-
_format_action(action) {
|
|
774
|
+
_format_action (action) {
|
|
807
775
|
// determine the required width and the entry label
|
|
808
|
-
|
|
776
|
+
const help_position = Math.min(this._action_max_length + 2,
|
|
809
777
|
this._max_help_position)
|
|
810
|
-
|
|
811
|
-
|
|
778
|
+
const help_width = Math.max(this._width - help_position, 11)
|
|
779
|
+
const action_width = help_position - this._current_indent - 2
|
|
812
780
|
let action_header = this._format_action_invocation(action)
|
|
781
|
+
const action_header_no_color = this._decolor(action_header)
|
|
813
782
|
let indent_first
|
|
814
783
|
|
|
815
784
|
// no help; start on same line and add a final newline
|
|
816
785
|
if (!action.help) {
|
|
817
|
-
|
|
786
|
+
const tup = [this._current_indent, '', action_header]
|
|
818
787
|
action_header = sub('%*s%s\n', ...tup)
|
|
819
788
|
|
|
820
789
|
// short action name; start on the same line and pad two spaces
|
|
821
|
-
} else if (
|
|
822
|
-
|
|
790
|
+
} else if (action_header_no_color.length <= action_width) {
|
|
791
|
+
// calculate widths without color codes
|
|
792
|
+
const action_header_color = action_header
|
|
793
|
+
const tup = [this._current_indent, '', action_width, action_header_no_color]
|
|
823
794
|
action_header = sub('%*s%-*s ', ...tup)
|
|
795
|
+
// swap in the colored header
|
|
796
|
+
action_header = action_header.replace(action_header_no_color, action_header_color)
|
|
824
797
|
indent_first = 0
|
|
825
798
|
|
|
826
799
|
// long action name; start on the next line
|
|
827
800
|
} else {
|
|
828
|
-
|
|
801
|
+
const tup = [this._current_indent, '', action_header]
|
|
829
802
|
action_header = sub('%*s%s\n', ...tup)
|
|
830
803
|
indent_first = help_position
|
|
831
804
|
}
|
|
832
805
|
|
|
833
806
|
// collect the pieces of the action help
|
|
834
|
-
|
|
807
|
+
const parts = [action_header]
|
|
835
808
|
|
|
836
809
|
// if there was help for the action, add lines of help text
|
|
837
|
-
if (action.help) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
810
|
+
if (action.help && action.help.trim()) {
|
|
811
|
+
const help_text = this._expand_help(action)
|
|
812
|
+
if (help_text) {
|
|
813
|
+
const help_lines = this._split_lines(help_text, help_width)
|
|
814
|
+
parts.push(sub('%*s%s\n', indent_first, '', help_lines[0]))
|
|
815
|
+
for (const line of help_lines.slice(1)) {
|
|
816
|
+
parts.push(sub('%*s%s\n', help_position, '', line))
|
|
817
|
+
}
|
|
843
818
|
}
|
|
844
819
|
|
|
845
820
|
// or add a newline if the description doesn't end with one
|
|
@@ -848,7 +823,7 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
848
823
|
}
|
|
849
824
|
|
|
850
825
|
// if there are any sub-actions, add their help as well
|
|
851
|
-
for (
|
|
826
|
+
for (const subaction of this._iter_indented_subactions(action)) {
|
|
852
827
|
parts.push(this._format_action(subaction))
|
|
853
828
|
}
|
|
854
829
|
|
|
@@ -856,46 +831,49 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
856
831
|
return this._join_parts(parts)
|
|
857
832
|
}
|
|
858
833
|
|
|
859
|
-
_format_action_invocation(action) {
|
|
834
|
+
_format_action_invocation (action) {
|
|
835
|
+
const t = this._theme
|
|
836
|
+
|
|
860
837
|
if (!action.option_strings.length) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
838
|
+
const default_value = this._get_default_metavar_for_positional(action)
|
|
839
|
+
return t.action +
|
|
840
|
+
this._metavar_formatter(action, default_value)(1).join(' ') +
|
|
841
|
+
t.reset
|
|
864
842
|
|
|
865
843
|
} else {
|
|
866
|
-
|
|
844
|
+
const color_option_strings = strings => strings.map(string => {
|
|
845
|
+
const color = this._is_long_option(string) ? t.long_option : t.short_option
|
|
846
|
+
return color + string + t.reset
|
|
847
|
+
})
|
|
867
848
|
|
|
868
849
|
// if the Optional doesn't take a value, format is:
|
|
869
850
|
// -s, --long
|
|
870
851
|
if (action.nargs === 0) {
|
|
871
|
-
|
|
852
|
+
return color_option_strings(action.option_strings).join(', ')
|
|
872
853
|
|
|
873
854
|
// if the Optional takes a value, format is:
|
|
874
|
-
// -s
|
|
855
|
+
// -s, --long ARGS
|
|
875
856
|
} else {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
857
|
+
const default_value = this._get_default_metavar_for_optional(action)
|
|
858
|
+
const option_strings = color_option_strings(action.option_strings)
|
|
859
|
+
const args_string = t.label + this._format_args(action, default_value) + t.reset
|
|
860
|
+
return option_strings.join(', ') + ' ' + args_string
|
|
881
861
|
}
|
|
882
|
-
|
|
883
|
-
return parts.join(', ')
|
|
884
862
|
}
|
|
885
863
|
}
|
|
886
864
|
|
|
887
|
-
_metavar_formatter(action, default_metavar) {
|
|
865
|
+
_metavar_formatter (action, default_metavar) {
|
|
888
866
|
let result
|
|
889
867
|
if (action.metavar !== undefined) {
|
|
890
868
|
result = action.metavar
|
|
891
869
|
} else if (action.choices !== undefined) {
|
|
892
|
-
|
|
870
|
+
const choice_strs = _choices_to_array(action.choices).map(String)
|
|
893
871
|
result = sub('{%s}', choice_strs.join(','))
|
|
894
872
|
} else {
|
|
895
873
|
result = default_metavar
|
|
896
874
|
}
|
|
897
875
|
|
|
898
|
-
function format(tuple_size) {
|
|
876
|
+
function format (tuple_size) {
|
|
899
877
|
if (Array.isArray(result)) {
|
|
900
878
|
return result
|
|
901
879
|
} else {
|
|
@@ -905,15 +883,15 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
905
883
|
return format
|
|
906
884
|
}
|
|
907
885
|
|
|
908
|
-
_format_args(action, default_metavar) {
|
|
909
|
-
|
|
886
|
+
_format_args (action, default_metavar) {
|
|
887
|
+
const get_metavar = this._metavar_formatter(action, default_metavar)
|
|
910
888
|
let result
|
|
911
889
|
if (action.nargs === undefined) {
|
|
912
890
|
result = sub('%s', ...get_metavar(1))
|
|
913
891
|
} else if (action.nargs === OPTIONAL) {
|
|
914
892
|
result = sub('[%s]', ...get_metavar(1))
|
|
915
893
|
} else if (action.nargs === ZERO_OR_MORE) {
|
|
916
|
-
|
|
894
|
+
const metavar = get_metavar(1)
|
|
917
895
|
if (metavar.length === 2) {
|
|
918
896
|
result = sub('[%s [%s ...]]', ...metavar)
|
|
919
897
|
} else {
|
|
@@ -939,85 +917,79 @@ const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
|
939
917
|
return result
|
|
940
918
|
}
|
|
941
919
|
|
|
942
|
-
_expand_help(action) {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
delete params[name]
|
|
947
|
-
}
|
|
920
|
+
_expand_help (action) {
|
|
921
|
+
const help_string = this._get_help_string(action)
|
|
922
|
+
if (!help_string.includes('%')) {
|
|
923
|
+
return help_string
|
|
948
924
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
925
|
+
const params = Object.assign({}, action, { prog: this._prog })
|
|
926
|
+
for (const name of Object.keys(params)) {
|
|
927
|
+
const value = params[name]
|
|
928
|
+
if (value === SUPPRESS) {
|
|
929
|
+
delete params[name]
|
|
930
|
+
} else if (value !== undefined && value !== null && 'name' in Object(value)) {
|
|
931
|
+
params[name] = value.name
|
|
952
932
|
}
|
|
953
933
|
}
|
|
954
934
|
if (params.choices !== undefined) {
|
|
955
|
-
|
|
935
|
+
const choices_str = _choices_to_array(params.choices).map(String).join(', ')
|
|
956
936
|
params.choices = choices_str
|
|
957
937
|
}
|
|
958
|
-
|
|
959
|
-
for (let key of Object.keys(params)) {
|
|
960
|
-
let old_name = _to_legacy_name(key)
|
|
961
|
-
if (old_name !== key) {
|
|
962
|
-
params[old_name] = params[key]
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
// end
|
|
966
|
-
return sub(this._get_help_string(action), params)
|
|
938
|
+
return sub(help_string, params)
|
|
967
939
|
}
|
|
968
940
|
|
|
969
|
-
* _iter_indented_subactions(action) {
|
|
941
|
+
* _iter_indented_subactions (action) {
|
|
970
942
|
if (typeof action._get_subactions === 'function') {
|
|
971
943
|
this._indent()
|
|
972
|
-
yield* action._get_subactions()
|
|
944
|
+
yield * action._get_subactions()
|
|
973
945
|
this._dedent()
|
|
974
946
|
}
|
|
975
947
|
}
|
|
976
948
|
|
|
977
|
-
_split_lines(text, width) {
|
|
949
|
+
_split_lines (text, width) {
|
|
978
950
|
text = text.replace(this._whitespace_matcher, ' ').trim()
|
|
979
951
|
// The textwrap module is used only for formatting help.
|
|
980
952
|
// Delay its import for speeding up the common usage of argparse.
|
|
981
|
-
|
|
953
|
+
const textwrap = require('./textwrap')
|
|
982
954
|
return textwrap.wrap(text, { width })
|
|
983
955
|
}
|
|
984
956
|
|
|
985
|
-
_fill_text(text, width, indent) {
|
|
957
|
+
_fill_text (text, width, indent) {
|
|
986
958
|
text = text.replace(this._whitespace_matcher, ' ').trim()
|
|
987
|
-
|
|
959
|
+
const textwrap = require('./textwrap')
|
|
988
960
|
return textwrap.fill(text, { width,
|
|
989
961
|
initial_indent: indent,
|
|
990
962
|
subsequent_indent: indent })
|
|
991
963
|
}
|
|
992
964
|
|
|
993
|
-
_get_help_string(action) {
|
|
965
|
+
_get_help_string (action) {
|
|
994
966
|
return action.help
|
|
995
967
|
}
|
|
996
968
|
|
|
997
|
-
_get_default_metavar_for_optional(action) {
|
|
969
|
+
_get_default_metavar_for_optional (action) {
|
|
998
970
|
return action.dest.toUpperCase()
|
|
999
971
|
}
|
|
1000
972
|
|
|
1001
|
-
_get_default_metavar_for_positional(action) {
|
|
973
|
+
_get_default_metavar_for_positional (action) {
|
|
1002
974
|
return action.dest
|
|
1003
975
|
}
|
|
1004
|
-
})
|
|
976
|
+
})
|
|
1005
977
|
|
|
1006
978
|
HelpFormatter.prototype._Section = _callable(class _Section {
|
|
1007
979
|
|
|
1008
|
-
constructor(formatter, parent, heading = undefined) {
|
|
980
|
+
constructor (formatter, parent, heading = undefined) {
|
|
1009
981
|
this.formatter = formatter
|
|
1010
982
|
this.parent = parent
|
|
1011
983
|
this.heading = heading
|
|
1012
984
|
this.items = []
|
|
1013
985
|
}
|
|
1014
986
|
|
|
1015
|
-
format_help() {
|
|
987
|
+
format_help () {
|
|
1016
988
|
// format the indented section
|
|
1017
989
|
if (this.parent !== undefined) {
|
|
1018
990
|
this.formatter._indent()
|
|
1019
991
|
}
|
|
1020
|
-
|
|
992
|
+
const item_help = this.formatter._join_parts(this.items.map(([func, args]) => func.apply(null, args)))
|
|
1021
993
|
if (this.parent !== undefined) {
|
|
1022
994
|
this.formatter._dedent()
|
|
1023
995
|
}
|
|
@@ -1030,8 +1002,10 @@ HelpFormatter.prototype._Section = _callable(class _Section {
|
|
|
1030
1002
|
// add the heading if the section was non-empty
|
|
1031
1003
|
let heading
|
|
1032
1004
|
if (this.heading !== SUPPRESS && this.heading !== undefined) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1005
|
+
const current_indent = this.formatter._current_indent
|
|
1006
|
+
const t = this.formatter._theme
|
|
1007
|
+
const heading_text = this.heading + ':'
|
|
1008
|
+
heading = ' '.repeat(current_indent) + t.heading + heading_text + t.reset + '\n'
|
|
1035
1009
|
} else {
|
|
1036
1010
|
heading = ''
|
|
1037
1011
|
}
|
|
@@ -1042,7 +1016,7 @@ HelpFormatter.prototype._Section = _callable(class _Section {
|
|
|
1042
1016
|
})
|
|
1043
1017
|
|
|
1044
1018
|
|
|
1045
|
-
const RawDescriptionHelpFormatter =
|
|
1019
|
+
const RawDescriptionHelpFormatter = _callable(class RawDescriptionHelpFormatter extends HelpFormatter {
|
|
1046
1020
|
/*
|
|
1047
1021
|
* Help message formatter which retains any formatting in descriptions.
|
|
1048
1022
|
*
|
|
@@ -1050,13 +1024,13 @@ const RawDescriptionHelpFormatter = _camelcase_alias(_callable(class RawDescript
|
|
|
1050
1024
|
* provided by the class are considered an implementation detail.
|
|
1051
1025
|
*/
|
|
1052
1026
|
|
|
1053
|
-
_fill_text(text, width, indent) {
|
|
1027
|
+
_fill_text (text, width, indent) {
|
|
1054
1028
|
return splitlines(text, true).map(line => indent + line).join('')
|
|
1055
1029
|
}
|
|
1056
|
-
})
|
|
1030
|
+
})
|
|
1057
1031
|
|
|
1058
1032
|
|
|
1059
|
-
const RawTextHelpFormatter =
|
|
1033
|
+
const RawTextHelpFormatter = _callable(class RawTextHelpFormatter extends RawDescriptionHelpFormatter {
|
|
1060
1034
|
/*
|
|
1061
1035
|
* Help message formatter which retains formatting of all help text.
|
|
1062
1036
|
*
|
|
@@ -1064,13 +1038,13 @@ const RawTextHelpFormatter = _camelcase_alias(_callable(class RawTextHelpFormatt
|
|
|
1064
1038
|
* provided by the class are considered an implementation detail.
|
|
1065
1039
|
*/
|
|
1066
1040
|
|
|
1067
|
-
_split_lines(text/*, width*/) {
|
|
1041
|
+
_split_lines (text/*, width */) {
|
|
1068
1042
|
return splitlines(text)
|
|
1069
1043
|
}
|
|
1070
|
-
})
|
|
1044
|
+
})
|
|
1071
1045
|
|
|
1072
1046
|
|
|
1073
|
-
const ArgumentDefaultsHelpFormatter =
|
|
1047
|
+
const ArgumentDefaultsHelpFormatter = _callable(class ArgumentDefaultsHelpFormatter extends HelpFormatter {
|
|
1074
1048
|
/*
|
|
1075
1049
|
* Help message formatter which adds default values to argument help.
|
|
1076
1050
|
*
|
|
@@ -1078,23 +1052,26 @@ const ArgumentDefaultsHelpFormatter = _camelcase_alias(_callable(class ArgumentD
|
|
|
1078
1052
|
* provided by the class are considered an implementation detail.
|
|
1079
1053
|
*/
|
|
1080
1054
|
|
|
1081
|
-
_get_help_string(action) {
|
|
1055
|
+
_get_help_string (action) {
|
|
1082
1056
|
let help = action.help
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1057
|
+
if (help === undefined) {
|
|
1058
|
+
help = ''
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if (!help.includes('%(default)') &&
|
|
1062
|
+
action.default !== SUPPRESS &&
|
|
1063
|
+
!action.required) {
|
|
1064
|
+
const defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
|
|
1065
|
+
if (action.option_strings.length || defaulting_nargs.includes(action.nargs)) {
|
|
1066
|
+
help += ' (default: %(default)s)'
|
|
1090
1067
|
}
|
|
1091
1068
|
}
|
|
1092
1069
|
return help
|
|
1093
1070
|
}
|
|
1094
|
-
})
|
|
1071
|
+
})
|
|
1095
1072
|
|
|
1096
1073
|
|
|
1097
|
-
const MetavarTypeHelpFormatter =
|
|
1074
|
+
const MetavarTypeHelpFormatter = _callable(class MetavarTypeHelpFormatter extends HelpFormatter {
|
|
1098
1075
|
/*
|
|
1099
1076
|
* Help message formatter which uses the argument 'type' as the default
|
|
1100
1077
|
* metavar value (instead of the argument 'dest')
|
|
@@ -1103,31 +1080,45 @@ const MetavarTypeHelpFormatter = _camelcase_alias(_callable(class MetavarTypeHel
|
|
|
1103
1080
|
* provided by the class are considered an implementation detail.
|
|
1104
1081
|
*/
|
|
1105
1082
|
|
|
1106
|
-
_get_default_metavar_for_optional(action) {
|
|
1083
|
+
_get_default_metavar_for_optional (action) {
|
|
1107
1084
|
return typeof action.type === 'function' ? action.type.name : action.type
|
|
1108
1085
|
}
|
|
1109
1086
|
|
|
1110
|
-
_get_default_metavar_for_positional(action) {
|
|
1087
|
+
_get_default_metavar_for_positional (action) {
|
|
1111
1088
|
return typeof action.type === 'function' ? action.type.name : action.type
|
|
1112
1089
|
}
|
|
1113
|
-
})
|
|
1090
|
+
})
|
|
1114
1091
|
|
|
1115
1092
|
|
|
1116
1093
|
// =====================
|
|
1117
1094
|
// Options and Arguments
|
|
1118
1095
|
// =====================
|
|
1119
|
-
function _get_action_name(argument) {
|
|
1096
|
+
function _get_action_name (argument) {
|
|
1120
1097
|
if (argument === undefined) {
|
|
1121
1098
|
return undefined
|
|
1122
1099
|
} else if (argument.option_strings.length) {
|
|
1123
1100
|
return argument.option_strings.join('/')
|
|
1124
|
-
} else if (![
|
|
1125
|
-
|
|
1126
|
-
|
|
1101
|
+
} else if (![undefined, SUPPRESS].includes(argument.metavar)) {
|
|
1102
|
+
const metavar = argument.metavar
|
|
1103
|
+
if (!Array.isArray(metavar)) {
|
|
1104
|
+
return metavar
|
|
1105
|
+
}
|
|
1106
|
+
if (argument.nargs === ZERO_OR_MORE && metavar.length === 2) {
|
|
1107
|
+
return sub('%s[, %s]', ...metavar)
|
|
1108
|
+
} else if (argument.nargs === ONE_OR_MORE) {
|
|
1109
|
+
return sub('%s[, %s]', ...metavar)
|
|
1110
|
+
} else {
|
|
1111
|
+
return metavar.join(', ')
|
|
1112
|
+
}
|
|
1113
|
+
} else if (![undefined, SUPPRESS].includes(argument.dest)) {
|
|
1127
1114
|
return argument.dest
|
|
1128
|
-
} else {
|
|
1129
|
-
|
|
1115
|
+
} else if (argument.choices) {
|
|
1116
|
+
const choices = _choices_to_array(argument.choices)
|
|
1117
|
+
if (choices.length) {
|
|
1118
|
+
return sub('{%s}', choices.map(String).join(','))
|
|
1119
|
+
}
|
|
1130
1120
|
}
|
|
1121
|
+
return undefined
|
|
1131
1122
|
}
|
|
1132
1123
|
|
|
1133
1124
|
|
|
@@ -1139,7 +1130,7 @@ const ArgumentError = _callable(class ArgumentError extends Error {
|
|
|
1139
1130
|
* information about the argument that caused it.
|
|
1140
1131
|
*/
|
|
1141
1132
|
|
|
1142
|
-
constructor(argument, message) {
|
|
1133
|
+
constructor (argument, message) {
|
|
1143
1134
|
super()
|
|
1144
1135
|
this.name = 'ArgumentError'
|
|
1145
1136
|
this._argument_name = _get_action_name(argument)
|
|
@@ -1147,7 +1138,7 @@ const ArgumentError = _callable(class ArgumentError extends Error {
|
|
|
1147
1138
|
this.message = this.str()
|
|
1148
1139
|
}
|
|
1149
1140
|
|
|
1150
|
-
str() {
|
|
1141
|
+
str () {
|
|
1151
1142
|
let format
|
|
1152
1143
|
if (this._argument_name === undefined) {
|
|
1153
1144
|
format = '%(message)s'
|
|
@@ -1165,7 +1156,7 @@ const ArgumentTypeError = _callable(class ArgumentTypeError extends Error {
|
|
|
1165
1156
|
* An error from trying to convert a command line string to a type.
|
|
1166
1157
|
*/
|
|
1167
1158
|
|
|
1168
|
-
constructor(message) {
|
|
1159
|
+
constructor (message) {
|
|
1169
1160
|
super(message)
|
|
1170
1161
|
this.name = 'ArgumentTypeError'
|
|
1171
1162
|
}
|
|
@@ -1175,7 +1166,7 @@ const ArgumentTypeError = _callable(class ArgumentTypeError extends Error {
|
|
|
1175
1166
|
// ==============
|
|
1176
1167
|
// Action classes
|
|
1177
1168
|
// ==============
|
|
1178
|
-
const Action =
|
|
1169
|
+
const Action = _callable(class Action extends _AttributeHolder(Function) {
|
|
1179
1170
|
/*
|
|
1180
1171
|
* Information about how to convert command line strings to Python objects.
|
|
1181
1172
|
*
|
|
@@ -1227,8 +1218,8 @@ const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(
|
|
|
1227
1218
|
* help string. If None, the 'dest' value will be used as the name.
|
|
1228
1219
|
*/
|
|
1229
1220
|
|
|
1230
|
-
constructor() {
|
|
1231
|
-
|
|
1221
|
+
constructor () {
|
|
1222
|
+
const [
|
|
1232
1223
|
option_strings,
|
|
1233
1224
|
dest,
|
|
1234
1225
|
nargs,
|
|
@@ -1238,7 +1229,8 @@ const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(
|
|
|
1238
1229
|
choices,
|
|
1239
1230
|
required,
|
|
1240
1231
|
help,
|
|
1241
|
-
metavar
|
|
1232
|
+
metavar,
|
|
1233
|
+
deprecated
|
|
1242
1234
|
] = _parse_opts(arguments, {
|
|
1243
1235
|
option_strings: no_default,
|
|
1244
1236
|
dest: no_default,
|
|
@@ -1249,7 +1241,8 @@ const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(
|
|
|
1249
1241
|
choices: undefined,
|
|
1250
1242
|
required: false,
|
|
1251
1243
|
help: undefined,
|
|
1252
|
-
metavar: undefined
|
|
1244
|
+
metavar: undefined,
|
|
1245
|
+
deprecated: false
|
|
1253
1246
|
})
|
|
1254
1247
|
|
|
1255
1248
|
// when this class is called as a function, redirect it to .call() method of itself
|
|
@@ -1265,10 +1258,11 @@ const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(
|
|
|
1265
1258
|
this.required = required
|
|
1266
1259
|
this.help = help
|
|
1267
1260
|
this.metavar = metavar
|
|
1261
|
+
this.deprecated = deprecated
|
|
1268
1262
|
}
|
|
1269
1263
|
|
|
1270
|
-
_get_kwargs() {
|
|
1271
|
-
|
|
1264
|
+
_get_kwargs () {
|
|
1265
|
+
const names = [
|
|
1272
1266
|
'option_strings',
|
|
1273
1267
|
'dest',
|
|
1274
1268
|
'nargs',
|
|
@@ -1276,88 +1270,84 @@ const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(
|
|
|
1276
1270
|
'default',
|
|
1277
1271
|
'type',
|
|
1278
1272
|
'choices',
|
|
1273
|
+
'required',
|
|
1279
1274
|
'help',
|
|
1280
|
-
'metavar'
|
|
1275
|
+
'metavar',
|
|
1276
|
+
'deprecated'
|
|
1281
1277
|
]
|
|
1282
|
-
return names.map(name => [
|
|
1278
|
+
return names.map(name => [name, getattr(this, name)])
|
|
1283
1279
|
}
|
|
1284
1280
|
|
|
1285
|
-
format_usage() {
|
|
1281
|
+
format_usage () {
|
|
1286
1282
|
return this.option_strings[0]
|
|
1287
1283
|
}
|
|
1288
1284
|
|
|
1289
|
-
call(/*parser, namespace, values, option_string = undefined*/) {
|
|
1285
|
+
call (/* parser, namespace, values, option_string = undefined */) {
|
|
1290
1286
|
throw new Error('.call() not defined')
|
|
1291
1287
|
}
|
|
1292
|
-
})
|
|
1288
|
+
})
|
|
1293
1289
|
|
|
1294
1290
|
|
|
1295
|
-
const BooleanOptionalAction =
|
|
1291
|
+
const BooleanOptionalAction = _callable(class BooleanOptionalAction extends Action {
|
|
1296
1292
|
|
|
1297
|
-
constructor() {
|
|
1298
|
-
|
|
1293
|
+
constructor () {
|
|
1294
|
+
const [
|
|
1299
1295
|
option_strings,
|
|
1300
1296
|
dest,
|
|
1301
1297
|
default_value,
|
|
1302
|
-
type,
|
|
1303
|
-
choices,
|
|
1304
1298
|
required,
|
|
1305
1299
|
help,
|
|
1306
|
-
|
|
1300
|
+
deprecated
|
|
1307
1301
|
] = _parse_opts(arguments, {
|
|
1308
1302
|
option_strings: no_default,
|
|
1309
1303
|
dest: no_default,
|
|
1310
1304
|
default: undefined,
|
|
1311
|
-
type: undefined,
|
|
1312
|
-
choices: undefined,
|
|
1313
1305
|
required: false,
|
|
1314
1306
|
help: undefined,
|
|
1315
|
-
|
|
1307
|
+
deprecated: false
|
|
1316
1308
|
})
|
|
1317
1309
|
|
|
1318
|
-
|
|
1310
|
+
const _option_strings = []
|
|
1319
1311
|
for (let option_string of option_strings) {
|
|
1320
1312
|
_option_strings.push(option_string)
|
|
1321
1313
|
|
|
1322
1314
|
if (option_string.startsWith('--')) {
|
|
1315
|
+
if (option_string.startsWith('--no-')) {
|
|
1316
|
+
throw new TypeError(sub('invalid option name %r ' +
|
|
1317
|
+
'for BooleanOptionalAction', option_string))
|
|
1318
|
+
}
|
|
1323
1319
|
option_string = '--no-' + option_string.slice(2)
|
|
1324
1320
|
_option_strings.push(option_string)
|
|
1325
1321
|
}
|
|
1326
1322
|
}
|
|
1327
1323
|
|
|
1328
|
-
if (help !== undefined && default_value !== undefined) {
|
|
1329
|
-
help += ` (default: ${default_value})`
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
1324
|
super({
|
|
1333
1325
|
option_strings: _option_strings,
|
|
1334
1326
|
dest,
|
|
1335
1327
|
nargs: 0,
|
|
1336
1328
|
default: default_value,
|
|
1337
|
-
type,
|
|
1338
|
-
choices,
|
|
1339
1329
|
required,
|
|
1340
1330
|
help,
|
|
1341
|
-
|
|
1331
|
+
deprecated
|
|
1342
1332
|
})
|
|
1343
1333
|
}
|
|
1344
1334
|
|
|
1345
|
-
call(parser, namespace, values, option_string = undefined) {
|
|
1335
|
+
call (parser, namespace, values, option_string = undefined) {
|
|
1346
1336
|
if (this.option_strings.includes(option_string)) {
|
|
1347
1337
|
setattr(namespace, this.dest, !option_string.startsWith('--no-'))
|
|
1348
1338
|
}
|
|
1349
1339
|
}
|
|
1350
1340
|
|
|
1351
|
-
format_usage() {
|
|
1341
|
+
format_usage () {
|
|
1352
1342
|
return this.option_strings.join(' | ')
|
|
1353
1343
|
}
|
|
1354
|
-
})
|
|
1344
|
+
})
|
|
1355
1345
|
|
|
1356
1346
|
|
|
1357
1347
|
const _StoreAction = _callable(class _StoreAction extends Action {
|
|
1358
1348
|
|
|
1359
|
-
constructor() {
|
|
1360
|
-
|
|
1349
|
+
constructor () {
|
|
1350
|
+
const [
|
|
1361
1351
|
option_strings,
|
|
1362
1352
|
dest,
|
|
1363
1353
|
nargs,
|
|
@@ -1367,7 +1357,8 @@ const _StoreAction = _callable(class _StoreAction extends Action {
|
|
|
1367
1357
|
choices,
|
|
1368
1358
|
required,
|
|
1369
1359
|
help,
|
|
1370
|
-
metavar
|
|
1360
|
+
metavar,
|
|
1361
|
+
deprecated
|
|
1371
1362
|
] = _parse_opts(arguments, {
|
|
1372
1363
|
option_strings: no_default,
|
|
1373
1364
|
dest: no_default,
|
|
@@ -1378,7 +1369,8 @@ const _StoreAction = _callable(class _StoreAction extends Action {
|
|
|
1378
1369
|
choices: undefined,
|
|
1379
1370
|
required: false,
|
|
1380
1371
|
help: undefined,
|
|
1381
|
-
metavar: undefined
|
|
1372
|
+
metavar: undefined,
|
|
1373
|
+
deprecated: false
|
|
1382
1374
|
})
|
|
1383
1375
|
|
|
1384
1376
|
if (nargs === 0) {
|
|
@@ -1399,11 +1391,12 @@ const _StoreAction = _callable(class _StoreAction extends Action {
|
|
|
1399
1391
|
choices,
|
|
1400
1392
|
required,
|
|
1401
1393
|
help,
|
|
1402
|
-
metavar
|
|
1394
|
+
metavar,
|
|
1395
|
+
deprecated
|
|
1403
1396
|
})
|
|
1404
1397
|
}
|
|
1405
1398
|
|
|
1406
|
-
call(parser, namespace, values/*, option_string = undefined*/) {
|
|
1399
|
+
call (parser, namespace, values/*, option_string = undefined */) {
|
|
1407
1400
|
setattr(namespace, this.dest, values)
|
|
1408
1401
|
}
|
|
1409
1402
|
})
|
|
@@ -1411,22 +1404,23 @@ const _StoreAction = _callable(class _StoreAction extends Action {
|
|
|
1411
1404
|
|
|
1412
1405
|
const _StoreConstAction = _callable(class _StoreConstAction extends Action {
|
|
1413
1406
|
|
|
1414
|
-
constructor() {
|
|
1415
|
-
|
|
1407
|
+
constructor () {
|
|
1408
|
+
const [
|
|
1416
1409
|
option_strings,
|
|
1417
1410
|
dest,
|
|
1418
1411
|
const_value,
|
|
1419
1412
|
default_value,
|
|
1420
1413
|
required,
|
|
1421
|
-
help
|
|
1422
|
-
|
|
1414
|
+
help,
|
|
1415
|
+
deprecated
|
|
1423
1416
|
] = _parse_opts(arguments, {
|
|
1424
1417
|
option_strings: no_default,
|
|
1425
1418
|
dest: no_default,
|
|
1426
|
-
const:
|
|
1419
|
+
const: undefined,
|
|
1427
1420
|
default: undefined,
|
|
1428
1421
|
required: false,
|
|
1429
1422
|
help: undefined,
|
|
1423
|
+
deprecated: false,
|
|
1430
1424
|
metavar: undefined
|
|
1431
1425
|
})
|
|
1432
1426
|
|
|
@@ -1437,11 +1431,12 @@ const _StoreConstAction = _callable(class _StoreConstAction extends Action {
|
|
|
1437
1431
|
const: const_value,
|
|
1438
1432
|
default: default_value,
|
|
1439
1433
|
required,
|
|
1440
|
-
help
|
|
1434
|
+
help,
|
|
1435
|
+
deprecated
|
|
1441
1436
|
})
|
|
1442
1437
|
}
|
|
1443
1438
|
|
|
1444
|
-
call(parser, namespace/*, values, option_string = undefined*/) {
|
|
1439
|
+
call (parser, namespace/*, values, option_string = undefined */) {
|
|
1445
1440
|
setattr(namespace, this.dest, this.const)
|
|
1446
1441
|
}
|
|
1447
1442
|
})
|
|
@@ -1449,19 +1444,21 @@ const _StoreConstAction = _callable(class _StoreConstAction extends Action {
|
|
|
1449
1444
|
|
|
1450
1445
|
const _StoreTrueAction = _callable(class _StoreTrueAction extends _StoreConstAction {
|
|
1451
1446
|
|
|
1452
|
-
constructor() {
|
|
1453
|
-
|
|
1447
|
+
constructor () {
|
|
1448
|
+
const [
|
|
1454
1449
|
option_strings,
|
|
1455
1450
|
dest,
|
|
1456
1451
|
default_value,
|
|
1457
1452
|
required,
|
|
1458
|
-
help
|
|
1453
|
+
help,
|
|
1454
|
+
deprecated
|
|
1459
1455
|
] = _parse_opts(arguments, {
|
|
1460
1456
|
option_strings: no_default,
|
|
1461
1457
|
dest: no_default,
|
|
1462
1458
|
default: false,
|
|
1463
1459
|
required: false,
|
|
1464
|
-
help: undefined
|
|
1460
|
+
help: undefined,
|
|
1461
|
+
deprecated: false
|
|
1465
1462
|
})
|
|
1466
1463
|
|
|
1467
1464
|
super({
|
|
@@ -1470,7 +1467,8 @@ const _StoreTrueAction = _callable(class _StoreTrueAction extends _StoreConstAct
|
|
|
1470
1467
|
const: true,
|
|
1471
1468
|
default: default_value,
|
|
1472
1469
|
required,
|
|
1473
|
-
help
|
|
1470
|
+
help,
|
|
1471
|
+
deprecated
|
|
1474
1472
|
})
|
|
1475
1473
|
}
|
|
1476
1474
|
})
|
|
@@ -1478,19 +1476,21 @@ const _StoreTrueAction = _callable(class _StoreTrueAction extends _StoreConstAct
|
|
|
1478
1476
|
|
|
1479
1477
|
const _StoreFalseAction = _callable(class _StoreFalseAction extends _StoreConstAction {
|
|
1480
1478
|
|
|
1481
|
-
constructor() {
|
|
1482
|
-
|
|
1479
|
+
constructor () {
|
|
1480
|
+
const [
|
|
1483
1481
|
option_strings,
|
|
1484
1482
|
dest,
|
|
1485
1483
|
default_value,
|
|
1486
1484
|
required,
|
|
1487
|
-
help
|
|
1485
|
+
help,
|
|
1486
|
+
deprecated
|
|
1488
1487
|
] = _parse_opts(arguments, {
|
|
1489
1488
|
option_strings: no_default,
|
|
1490
1489
|
dest: no_default,
|
|
1491
1490
|
default: true,
|
|
1492
1491
|
required: false,
|
|
1493
|
-
help: undefined
|
|
1492
|
+
help: undefined,
|
|
1493
|
+
deprecated: false
|
|
1494
1494
|
})
|
|
1495
1495
|
|
|
1496
1496
|
super({
|
|
@@ -1499,7 +1499,8 @@ const _StoreFalseAction = _callable(class _StoreFalseAction extends _StoreConstA
|
|
|
1499
1499
|
const: false,
|
|
1500
1500
|
default: default_value,
|
|
1501
1501
|
required,
|
|
1502
|
-
help
|
|
1502
|
+
help,
|
|
1503
|
+
deprecated
|
|
1503
1504
|
})
|
|
1504
1505
|
}
|
|
1505
1506
|
})
|
|
@@ -1507,8 +1508,8 @@ const _StoreFalseAction = _callable(class _StoreFalseAction extends _StoreConstA
|
|
|
1507
1508
|
|
|
1508
1509
|
const _AppendAction = _callable(class _AppendAction extends Action {
|
|
1509
1510
|
|
|
1510
|
-
constructor() {
|
|
1511
|
-
|
|
1511
|
+
constructor () {
|
|
1512
|
+
const [
|
|
1512
1513
|
option_strings,
|
|
1513
1514
|
dest,
|
|
1514
1515
|
nargs,
|
|
@@ -1518,7 +1519,8 @@ const _AppendAction = _callable(class _AppendAction extends Action {
|
|
|
1518
1519
|
choices,
|
|
1519
1520
|
required,
|
|
1520
1521
|
help,
|
|
1521
|
-
metavar
|
|
1522
|
+
metavar,
|
|
1523
|
+
deprecated
|
|
1522
1524
|
] = _parse_opts(arguments, {
|
|
1523
1525
|
option_strings: no_default,
|
|
1524
1526
|
dest: no_default,
|
|
@@ -1529,7 +1531,8 @@ const _AppendAction = _callable(class _AppendAction extends Action {
|
|
|
1529
1531
|
choices: undefined,
|
|
1530
1532
|
required: false,
|
|
1531
1533
|
help: undefined,
|
|
1532
|
-
metavar: undefined
|
|
1534
|
+
metavar: undefined,
|
|
1535
|
+
deprecated: false
|
|
1533
1536
|
})
|
|
1534
1537
|
|
|
1535
1538
|
if (nargs === 0) {
|
|
@@ -1550,11 +1553,12 @@ const _AppendAction = _callable(class _AppendAction extends Action {
|
|
|
1550
1553
|
choices,
|
|
1551
1554
|
required,
|
|
1552
1555
|
help,
|
|
1553
|
-
metavar
|
|
1556
|
+
metavar,
|
|
1557
|
+
deprecated
|
|
1554
1558
|
})
|
|
1555
1559
|
}
|
|
1556
1560
|
|
|
1557
|
-
call(parser, namespace, values/*, option_string = undefined*/) {
|
|
1561
|
+
call (parser, namespace, values/*, option_string = undefined */) {
|
|
1558
1562
|
let items = getattr(namespace, this.dest, undefined)
|
|
1559
1563
|
items = _copy_items(items)
|
|
1560
1564
|
items.push(values)
|
|
@@ -1565,23 +1569,25 @@ const _AppendAction = _callable(class _AppendAction extends Action {
|
|
|
1565
1569
|
|
|
1566
1570
|
const _AppendConstAction = _callable(class _AppendConstAction extends Action {
|
|
1567
1571
|
|
|
1568
|
-
constructor() {
|
|
1569
|
-
|
|
1572
|
+
constructor () {
|
|
1573
|
+
const [
|
|
1570
1574
|
option_strings,
|
|
1571
1575
|
dest,
|
|
1572
1576
|
const_value,
|
|
1573
1577
|
default_value,
|
|
1574
1578
|
required,
|
|
1575
1579
|
help,
|
|
1576
|
-
metavar
|
|
1580
|
+
metavar,
|
|
1581
|
+
deprecated
|
|
1577
1582
|
] = _parse_opts(arguments, {
|
|
1578
1583
|
option_strings: no_default,
|
|
1579
1584
|
dest: no_default,
|
|
1580
|
-
const:
|
|
1585
|
+
const: undefined,
|
|
1581
1586
|
default: undefined,
|
|
1582
1587
|
required: false,
|
|
1583
1588
|
help: undefined,
|
|
1584
|
-
metavar: undefined
|
|
1589
|
+
metavar: undefined,
|
|
1590
|
+
deprecated: false
|
|
1585
1591
|
})
|
|
1586
1592
|
|
|
1587
1593
|
super({
|
|
@@ -1592,11 +1598,12 @@ const _AppendConstAction = _callable(class _AppendConstAction extends Action {
|
|
|
1592
1598
|
default: default_value,
|
|
1593
1599
|
required,
|
|
1594
1600
|
help,
|
|
1595
|
-
metavar
|
|
1601
|
+
metavar,
|
|
1602
|
+
deprecated
|
|
1596
1603
|
})
|
|
1597
1604
|
}
|
|
1598
1605
|
|
|
1599
|
-
call(parser, namespace/*, values, option_string = undefined*/) {
|
|
1606
|
+
call (parser, namespace/*, values, option_string = undefined */) {
|
|
1600
1607
|
let items = getattr(namespace, this.dest, undefined)
|
|
1601
1608
|
items = _copy_items(items)
|
|
1602
1609
|
items.push(this.const)
|
|
@@ -1607,19 +1614,21 @@ const _AppendConstAction = _callable(class _AppendConstAction extends Action {
|
|
|
1607
1614
|
|
|
1608
1615
|
const _CountAction = _callable(class _CountAction extends Action {
|
|
1609
1616
|
|
|
1610
|
-
constructor() {
|
|
1611
|
-
|
|
1617
|
+
constructor () {
|
|
1618
|
+
const [
|
|
1612
1619
|
option_strings,
|
|
1613
1620
|
dest,
|
|
1614
1621
|
default_value,
|
|
1615
1622
|
required,
|
|
1616
|
-
help
|
|
1623
|
+
help,
|
|
1624
|
+
deprecated
|
|
1617
1625
|
] = _parse_opts(arguments, {
|
|
1618
1626
|
option_strings: no_default,
|
|
1619
1627
|
dest: no_default,
|
|
1620
1628
|
default: undefined,
|
|
1621
1629
|
required: false,
|
|
1622
|
-
help: undefined
|
|
1630
|
+
help: undefined,
|
|
1631
|
+
deprecated: false
|
|
1623
1632
|
})
|
|
1624
1633
|
|
|
1625
1634
|
super({
|
|
@@ -1628,11 +1637,12 @@ const _CountAction = _callable(class _CountAction extends Action {
|
|
|
1628
1637
|
nargs: 0,
|
|
1629
1638
|
default: default_value,
|
|
1630
1639
|
required,
|
|
1631
|
-
help
|
|
1640
|
+
help,
|
|
1641
|
+
deprecated
|
|
1632
1642
|
})
|
|
1633
1643
|
}
|
|
1634
1644
|
|
|
1635
|
-
call(parser, namespace/*, values, option_string = undefined*/) {
|
|
1645
|
+
call (parser, namespace/*, values, option_string = undefined */) {
|
|
1636
1646
|
let count = getattr(namespace, this.dest, undefined)
|
|
1637
1647
|
if (count === undefined) {
|
|
1638
1648
|
count = 0
|
|
@@ -1644,17 +1654,19 @@ const _CountAction = _callable(class _CountAction extends Action {
|
|
|
1644
1654
|
|
|
1645
1655
|
const _HelpAction = _callable(class _HelpAction extends Action {
|
|
1646
1656
|
|
|
1647
|
-
constructor() {
|
|
1648
|
-
|
|
1657
|
+
constructor () {
|
|
1658
|
+
const [
|
|
1649
1659
|
option_strings,
|
|
1650
1660
|
dest,
|
|
1651
1661
|
default_value,
|
|
1652
|
-
help
|
|
1662
|
+
help,
|
|
1663
|
+
deprecated
|
|
1653
1664
|
] = _parse_opts(arguments, {
|
|
1654
1665
|
option_strings: no_default,
|
|
1655
1666
|
dest: SUPPRESS,
|
|
1656
1667
|
default: SUPPRESS,
|
|
1657
|
-
help: undefined
|
|
1668
|
+
help: undefined,
|
|
1669
|
+
deprecated: false
|
|
1658
1670
|
})
|
|
1659
1671
|
|
|
1660
1672
|
super({
|
|
@@ -1662,11 +1674,12 @@ const _HelpAction = _callable(class _HelpAction extends Action {
|
|
|
1662
1674
|
dest,
|
|
1663
1675
|
default: default_value,
|
|
1664
1676
|
nargs: 0,
|
|
1665
|
-
help
|
|
1677
|
+
help,
|
|
1678
|
+
deprecated
|
|
1666
1679
|
})
|
|
1667
1680
|
}
|
|
1668
1681
|
|
|
1669
|
-
call(parser/*, namespace, values, option_string = undefined*/) {
|
|
1682
|
+
call (parser/*, namespace, values, option_string = undefined */) {
|
|
1670
1683
|
parser.print_help()
|
|
1671
1684
|
parser.exit()
|
|
1672
1685
|
}
|
|
@@ -1675,7 +1688,7 @@ const _HelpAction = _callable(class _HelpAction extends Action {
|
|
|
1675
1688
|
|
|
1676
1689
|
const _VersionAction = _callable(class _VersionAction extends Action {
|
|
1677
1690
|
|
|
1678
|
-
constructor() {
|
|
1691
|
+
constructor () {
|
|
1679
1692
|
let [
|
|
1680
1693
|
option_strings,
|
|
1681
1694
|
version,
|
|
@@ -1687,9 +1700,14 @@ const _VersionAction = _callable(class _VersionAction extends Action {
|
|
|
1687
1700
|
version: undefined,
|
|
1688
1701
|
dest: SUPPRESS,
|
|
1689
1702
|
default: SUPPRESS,
|
|
1690
|
-
help: "show program's version number and exit"
|
|
1703
|
+
help: "show program's version number and exit",
|
|
1704
|
+
deprecated: false
|
|
1691
1705
|
})
|
|
1692
1706
|
|
|
1707
|
+
if (help === undefined || help === null) {
|
|
1708
|
+
help = "show program's version number and exit"
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1693
1711
|
super({
|
|
1694
1712
|
option_strings,
|
|
1695
1713
|
dest,
|
|
@@ -1700,12 +1718,12 @@ const _VersionAction = _callable(class _VersionAction extends Action {
|
|
|
1700
1718
|
this.version = version
|
|
1701
1719
|
}
|
|
1702
1720
|
|
|
1703
|
-
call(parser/*, namespace, values, option_string = undefined*/) {
|
|
1721
|
+
call (parser/*, namespace, values, option_string = undefined */) {
|
|
1704
1722
|
let version = this.version
|
|
1705
1723
|
if (version === undefined) {
|
|
1706
1724
|
version = parser.version
|
|
1707
1725
|
}
|
|
1708
|
-
|
|
1726
|
+
const formatter = parser._get_formatter()
|
|
1709
1727
|
formatter.add_text(version)
|
|
1710
1728
|
parser._print_message(formatter.format_help(), process.stdout)
|
|
1711
1729
|
parser.exit()
|
|
@@ -1713,10 +1731,10 @@ const _VersionAction = _callable(class _VersionAction extends Action {
|
|
|
1713
1731
|
})
|
|
1714
1732
|
|
|
1715
1733
|
|
|
1716
|
-
const _SubParsersAction =
|
|
1734
|
+
const _SubParsersAction = _callable(class _SubParsersAction extends Action {
|
|
1717
1735
|
|
|
1718
|
-
constructor() {
|
|
1719
|
-
|
|
1736
|
+
constructor () {
|
|
1737
|
+
const [
|
|
1720
1738
|
option_strings,
|
|
1721
1739
|
prog,
|
|
1722
1740
|
parser_class,
|
|
@@ -1734,7 +1752,7 @@ const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction ext
|
|
|
1734
1752
|
metavar: undefined
|
|
1735
1753
|
})
|
|
1736
1754
|
|
|
1737
|
-
|
|
1755
|
+
const name_parser_map = Object.create(null)
|
|
1738
1756
|
|
|
1739
1757
|
super({
|
|
1740
1758
|
option_strings,
|
|
@@ -1750,10 +1768,12 @@ const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction ext
|
|
|
1750
1768
|
this._parser_class = parser_class
|
|
1751
1769
|
this._name_parser_map = name_parser_map
|
|
1752
1770
|
this._choices_actions = []
|
|
1771
|
+
this._deprecated = new Set()
|
|
1772
|
+
this._color = true
|
|
1753
1773
|
}
|
|
1754
1774
|
|
|
1755
|
-
add_parser() {
|
|
1756
|
-
|
|
1775
|
+
add_parser () {
|
|
1776
|
+
const [
|
|
1757
1777
|
name,
|
|
1758
1778
|
kwargs
|
|
1759
1779
|
] = _parse_opts(arguments, {
|
|
@@ -1766,35 +1786,62 @@ const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction ext
|
|
|
1766
1786
|
kwargs.prog = sub('%s %s', this._prog_prefix, name)
|
|
1767
1787
|
}
|
|
1768
1788
|
|
|
1769
|
-
|
|
1789
|
+
// set color
|
|
1790
|
+
if (kwargs.color === undefined) {
|
|
1791
|
+
kwargs.color = this._color
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
const aliases = getattr(kwargs, 'aliases', [])
|
|
1770
1795
|
delete kwargs.aliases
|
|
1796
|
+
const deprecated = getattr(kwargs, 'deprecated', false)
|
|
1797
|
+
delete kwargs.deprecated
|
|
1798
|
+
|
|
1799
|
+
if (hasattr(this._name_parser_map, name)) {
|
|
1800
|
+
throw new TypeError(sub('conflicting subparser: %s', name))
|
|
1801
|
+
}
|
|
1802
|
+
for (const alias of aliases) {
|
|
1803
|
+
if (hasattr(this._name_parser_map, alias)) {
|
|
1804
|
+
throw new TypeError(sub('conflicting subparser alias: %s', alias))
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1771
1807
|
|
|
1772
1808
|
// create a pseudo-action to hold the choice help
|
|
1809
|
+
let choice_action
|
|
1773
1810
|
if ('help' in kwargs) {
|
|
1774
|
-
|
|
1811
|
+
const help = kwargs.help
|
|
1775
1812
|
delete kwargs.help
|
|
1776
|
-
|
|
1813
|
+
choice_action = this._ChoicesPseudoAction(name, aliases, help)
|
|
1777
1814
|
this._choices_actions.push(choice_action)
|
|
1778
1815
|
}
|
|
1779
1816
|
|
|
1780
1817
|
// create the parser and add it to the map
|
|
1781
|
-
|
|
1818
|
+
const parser = new this._parser_class(kwargs)
|
|
1819
|
+
if (choice_action !== undefined) {
|
|
1820
|
+
parser._check_help(choice_action)
|
|
1821
|
+
}
|
|
1782
1822
|
this._name_parser_map[name] = parser
|
|
1783
1823
|
|
|
1784
1824
|
// make parser available under aliases also
|
|
1785
|
-
for (
|
|
1825
|
+
for (const alias of aliases) {
|
|
1786
1826
|
this._name_parser_map[alias] = parser
|
|
1787
1827
|
}
|
|
1788
1828
|
|
|
1829
|
+
if (deprecated) {
|
|
1830
|
+
this._deprecated.add(name)
|
|
1831
|
+
for (const alias of aliases) {
|
|
1832
|
+
this._deprecated.add(alias)
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1789
1836
|
return parser
|
|
1790
1837
|
}
|
|
1791
1838
|
|
|
1792
|
-
_get_subactions() {
|
|
1839
|
+
_get_subactions () {
|
|
1793
1840
|
return this._choices_actions
|
|
1794
1841
|
}
|
|
1795
1842
|
|
|
1796
|
-
call(parser, namespace, values/*, option_string = undefined*/) {
|
|
1797
|
-
|
|
1843
|
+
call (parser, namespace, values/*, option_string = undefined */) {
|
|
1844
|
+
const parser_name = values[0]
|
|
1798
1845
|
let arg_strings = values.slice(1)
|
|
1799
1846
|
|
|
1800
1847
|
// set the parser name if requested
|
|
@@ -1803,15 +1850,20 @@ const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction ext
|
|
|
1803
1850
|
}
|
|
1804
1851
|
|
|
1805
1852
|
// select the parser
|
|
1853
|
+
let subparser
|
|
1806
1854
|
if (hasattr(this._name_parser_map, parser_name)) {
|
|
1807
|
-
|
|
1855
|
+
subparser = this._name_parser_map[parser_name]
|
|
1808
1856
|
} else {
|
|
1809
|
-
|
|
1810
|
-
choices: this._name_parser_map.join(', ')}
|
|
1811
|
-
|
|
1857
|
+
const args = {parser_name,
|
|
1858
|
+
choices: Object.keys(this._name_parser_map).join(', ')}
|
|
1859
|
+
const msg = sub('unknown parser %(parser_name)r (choices: %(choices)s)', args)
|
|
1812
1860
|
throw new ArgumentError(this, msg)
|
|
1813
1861
|
}
|
|
1814
1862
|
|
|
1863
|
+
if (this._deprecated.has(parser_name)) {
|
|
1864
|
+
parser._warning(sub("command '%(parser_name)s' is deprecated", { parser_name }))
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1815
1867
|
// parse all the remaining options into the namespace
|
|
1816
1868
|
// store any unrecognized options on the object, so that the top
|
|
1817
1869
|
// level parser can decide what to do with them
|
|
@@ -1820,22 +1872,25 @@ const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction ext
|
|
|
1820
1872
|
// in a new namespace object and then update the original
|
|
1821
1873
|
// namespace for the relevant parts.
|
|
1822
1874
|
let subnamespace
|
|
1823
|
-
[
|
|
1824
|
-
for (
|
|
1875
|
+
[subnamespace, arg_strings] = subparser.parse_known_args(arg_strings, undefined)
|
|
1876
|
+
for (const [key, value] of Object.entries(subnamespace)) {
|
|
1825
1877
|
setattr(namespace, key, value)
|
|
1826
1878
|
}
|
|
1827
1879
|
|
|
1828
1880
|
if (arg_strings.length) {
|
|
1829
|
-
|
|
1881
|
+
if (!hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) {
|
|
1882
|
+
setattr(namespace, _UNRECOGNIZED_ARGS_ATTR, [])
|
|
1883
|
+
}
|
|
1830
1884
|
getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).push(...arg_strings)
|
|
1831
1885
|
}
|
|
1832
1886
|
}
|
|
1833
|
-
})
|
|
1887
|
+
})
|
|
1834
1888
|
|
|
1835
1889
|
|
|
1836
1890
|
_SubParsersAction.prototype._ChoicesPseudoAction = _callable(class _ChoicesPseudoAction extends Action {
|
|
1837
|
-
constructor(name, aliases, help) {
|
|
1838
|
-
let metavar = name
|
|
1891
|
+
constructor (name, aliases, help) {
|
|
1892
|
+
let metavar = name
|
|
1893
|
+
const dest = name
|
|
1839
1894
|
if (aliases.length) {
|
|
1840
1895
|
metavar += sub(' (%s)', aliases.join(', '))
|
|
1841
1896
|
}
|
|
@@ -1845,7 +1900,7 @@ _SubParsersAction.prototype._ChoicesPseudoAction = _callable(class _ChoicesPseud
|
|
|
1845
1900
|
|
|
1846
1901
|
|
|
1847
1902
|
const _ExtendAction = _callable(class _ExtendAction extends _AppendAction {
|
|
1848
|
-
call(parser, namespace, values/*, option_string = undefined*/) {
|
|
1903
|
+
call (parser, namespace, values/*, option_string = undefined */) {
|
|
1849
1904
|
let items = getattr(namespace, this.dest, undefined)
|
|
1850
1905
|
items = _copy_items(items)
|
|
1851
1906
|
items = items.concat(values)
|
|
@@ -1859,7 +1914,7 @@ const _ExtendAction = _callable(class _ExtendAction extends _AppendAction {
|
|
|
1859
1914
|
// ==============
|
|
1860
1915
|
const FileType = _callable(class FileType extends Function {
|
|
1861
1916
|
/*
|
|
1862
|
-
*
|
|
1917
|
+
* Deprecated factory for creating file object types
|
|
1863
1918
|
*
|
|
1864
1919
|
* Instances of FileType are typically passed as type= arguments to the
|
|
1865
1920
|
* ArgumentParser add_argument() method.
|
|
@@ -1875,8 +1930,8 @@ const FileType = _callable(class FileType extends Function {
|
|
|
1875
1930
|
* be handled. Accepts the same value as the builtin open() function.
|
|
1876
1931
|
*/
|
|
1877
1932
|
|
|
1878
|
-
constructor() {
|
|
1879
|
-
|
|
1933
|
+
constructor () {
|
|
1934
|
+
const [
|
|
1880
1935
|
flags,
|
|
1881
1936
|
encoding,
|
|
1882
1937
|
mode,
|
|
@@ -1898,11 +1953,15 @@ const FileType = _callable(class FileType extends Function {
|
|
|
1898
1953
|
fs: undefined
|
|
1899
1954
|
})
|
|
1900
1955
|
|
|
1956
|
+
process.emitWarning(
|
|
1957
|
+
'FileType is deprecated. Simply open files after parsing arguments.',
|
|
1958
|
+
'PendingDeprecationWarning')
|
|
1959
|
+
|
|
1901
1960
|
// when this class is called as a function, redirect it to .call() method of itself
|
|
1902
1961
|
super('return arguments.callee.call.apply(arguments.callee, arguments)')
|
|
1903
1962
|
|
|
1904
1963
|
Object.defineProperty(this, 'name', {
|
|
1905
|
-
get() {
|
|
1964
|
+
get () {
|
|
1906
1965
|
return sub('FileType(%r)', flags)
|
|
1907
1966
|
}
|
|
1908
1967
|
})
|
|
@@ -1918,15 +1977,15 @@ const FileType = _callable(class FileType extends Function {
|
|
|
1918
1977
|
if (fs !== undefined) this._options.fs = fs
|
|
1919
1978
|
}
|
|
1920
1979
|
|
|
1921
|
-
call(string) {
|
|
1980
|
+
call (string) {
|
|
1922
1981
|
// the special argument "-" means sys.std{in,out}
|
|
1923
1982
|
if (string === '-') {
|
|
1924
1983
|
if (this._flags.includes('r')) {
|
|
1925
1984
|
return process.stdin
|
|
1926
|
-
} else if (this._flags.includes(
|
|
1985
|
+
} else if ([...'wax'].some(flag => this._flags.includes(flag))) {
|
|
1927
1986
|
return process.stdout
|
|
1928
1987
|
} else {
|
|
1929
|
-
|
|
1988
|
+
const msg = sub('argument "-" with mode %r', this._flags)
|
|
1930
1989
|
throw new TypeError(msg)
|
|
1931
1990
|
}
|
|
1932
1991
|
}
|
|
@@ -1936,37 +1995,45 @@ const FileType = _callable(class FileType extends Function {
|
|
|
1936
1995
|
try {
|
|
1937
1996
|
fd = fs.openSync(string, this._flags, this._options.mode)
|
|
1938
1997
|
} catch (e) {
|
|
1939
|
-
|
|
1940
|
-
|
|
1998
|
+
if (e instanceof TypeError) {
|
|
1999
|
+
throw e
|
|
2000
|
+
}
|
|
2001
|
+
const args = { filename: string, error: e.message }
|
|
2002
|
+
const message = "can't open '%(filename)s': %(error)s"
|
|
1941
2003
|
throw new ArgumentTypeError(sub(message, args))
|
|
1942
2004
|
}
|
|
1943
2005
|
|
|
1944
|
-
|
|
2006
|
+
const options = Object.assign({ fd, flags: this._flags }, this._options)
|
|
1945
2007
|
if (this._flags.includes('r')) {
|
|
1946
|
-
|
|
2008
|
+
const file = fs.createReadStream(string, options)
|
|
2009
|
+
file.path = string
|
|
2010
|
+
return file
|
|
1947
2011
|
} else if (this._flags.includes('w')) {
|
|
1948
|
-
|
|
2012
|
+
const file = fs.createWriteStream(string, options)
|
|
2013
|
+
file.path = string
|
|
2014
|
+
return file
|
|
1949
2015
|
} else {
|
|
1950
|
-
|
|
2016
|
+
fs.closeSync(fd)
|
|
2017
|
+
const msg = sub('argument "%s" with mode %r', string, this._flags)
|
|
1951
2018
|
throw new TypeError(msg)
|
|
1952
2019
|
}
|
|
1953
2020
|
}
|
|
1954
2021
|
|
|
1955
|
-
[util.inspect.custom]() {
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
if (k === 'mode') v = { value: v, [util.inspect.custom]() { return '0o' + this.value.toString(8) } }
|
|
1959
|
-
return [
|
|
2022
|
+
[util.inspect.custom] () {
|
|
2023
|
+
const args = [this._flags]
|
|
2024
|
+
const kwargs = Object.entries(this._options).map(([k, v]) => {
|
|
2025
|
+
if (k === 'mode') v = { value: v, [util.inspect.custom] () { return '0o' + this.value.toString(8) } }
|
|
2026
|
+
return [k, v]
|
|
1960
2027
|
})
|
|
1961
|
-
|
|
2028
|
+
const args_str = []
|
|
1962
2029
|
.concat(args.filter(arg => arg !== -1).map(repr))
|
|
1963
|
-
.concat(kwargs.filter(([/*kw*/, arg]) => arg !== undefined)
|
|
2030
|
+
.concat(kwargs.filter(([/* kw */, arg]) => arg !== undefined)
|
|
1964
2031
|
.map(([kw, arg]) => sub('%s=%r', kw, arg)))
|
|
1965
2032
|
.join(', ')
|
|
1966
2033
|
return sub('%s(%s)', this.constructor.name, args_str)
|
|
1967
2034
|
}
|
|
1968
2035
|
|
|
1969
|
-
toString() {
|
|
2036
|
+
toString () {
|
|
1970
2037
|
return this[util.inspect.custom]()
|
|
1971
2038
|
}
|
|
1972
2039
|
})
|
|
@@ -1982,7 +2049,7 @@ const Namespace = _callable(class Namespace extends _AttributeHolder() {
|
|
|
1982
2049
|
* string representation.
|
|
1983
2050
|
*/
|
|
1984
2051
|
|
|
1985
|
-
constructor(options = {}) {
|
|
2052
|
+
constructor (options = {}) {
|
|
1986
2053
|
super()
|
|
1987
2054
|
Object.assign(this, options)
|
|
1988
2055
|
}
|
|
@@ -1992,10 +2059,10 @@ const Namespace = _callable(class Namespace extends _AttributeHolder() {
|
|
|
1992
2059
|
Namespace.prototype[Symbol.toStringTag] = undefined
|
|
1993
2060
|
|
|
1994
2061
|
|
|
1995
|
-
const _ActionsContainer =
|
|
2062
|
+
const _ActionsContainer = _callable(class _ActionsContainer {
|
|
1996
2063
|
|
|
1997
|
-
constructor() {
|
|
1998
|
-
|
|
2064
|
+
constructor () {
|
|
2065
|
+
const [
|
|
1999
2066
|
description,
|
|
2000
2067
|
prefix_chars,
|
|
2001
2068
|
argument_default,
|
|
@@ -2013,7 +2080,7 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2013
2080
|
this.conflict_handler = conflict_handler
|
|
2014
2081
|
|
|
2015
2082
|
// set up registries
|
|
2016
|
-
this._registries =
|
|
2083
|
+
this._registries = Object.create(null)
|
|
2017
2084
|
|
|
2018
2085
|
// register actions
|
|
2019
2086
|
this.register('action', undefined, _StoreAction)
|
|
@@ -2028,30 +2095,22 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2028
2095
|
this.register('action', 'version', _VersionAction)
|
|
2029
2096
|
this.register('action', 'parsers', _SubParsersAction)
|
|
2030
2097
|
this.register('action', 'extend', _ExtendAction)
|
|
2031
|
-
// LEGACY (v1 compatibility): camelcase variants
|
|
2032
|
-
;[ 'storeConst', 'storeTrue', 'storeFalse', 'appendConst' ].forEach(old_name => {
|
|
2033
|
-
let new_name = _to_new_name(old_name)
|
|
2034
|
-
this.register('action', old_name, util.deprecate(this._registry_get('action', new_name),
|
|
2035
|
-
sub('{action: "%s"} is renamed to {action: "%s"}', old_name, new_name)))
|
|
2036
|
-
})
|
|
2037
|
-
// end
|
|
2038
|
-
|
|
2039
2098
|
// raise an exception if the conflict handler is invalid
|
|
2040
2099
|
this._get_handler()
|
|
2041
2100
|
|
|
2042
2101
|
// action storage
|
|
2043
2102
|
this._actions = []
|
|
2044
|
-
this._option_string_actions =
|
|
2103
|
+
this._option_string_actions = Object.create(null)
|
|
2045
2104
|
|
|
2046
2105
|
// groups
|
|
2047
2106
|
this._action_groups = []
|
|
2048
2107
|
this._mutually_exclusive_groups = []
|
|
2049
2108
|
|
|
2050
2109
|
// defaults storage
|
|
2051
|
-
this._defaults =
|
|
2110
|
+
this._defaults = Object.create(null)
|
|
2052
2111
|
|
|
2053
2112
|
// determines whether an "option" looks like a negative number
|
|
2054
|
-
this._negative_number_matcher =
|
|
2113
|
+
this._negative_number_matcher = /^-\.?\d/
|
|
2055
2114
|
|
|
2056
2115
|
// whether or not there are any optionals that look like negative
|
|
2057
2116
|
// numbers -- uses a list so it can be shared and edited
|
|
@@ -2061,32 +2120,32 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2061
2120
|
// ====================
|
|
2062
2121
|
// Registration methods
|
|
2063
2122
|
// ====================
|
|
2064
|
-
register(registry_name, value, object) {
|
|
2065
|
-
|
|
2123
|
+
register (registry_name, value, object) {
|
|
2124
|
+
const registry = setdefault(this._registries, registry_name, Object.create(null))
|
|
2066
2125
|
registry[value] = object
|
|
2067
2126
|
}
|
|
2068
2127
|
|
|
2069
|
-
_registry_get(registry_name, value, default_value = undefined) {
|
|
2128
|
+
_registry_get (registry_name, value, default_value = undefined) {
|
|
2070
2129
|
return getattr(this._registries[registry_name], value, default_value)
|
|
2071
2130
|
}
|
|
2072
2131
|
|
|
2073
2132
|
// ==================================
|
|
2074
2133
|
// Namespace default accessor methods
|
|
2075
2134
|
// ==================================
|
|
2076
|
-
set_defaults(kwargs) {
|
|
2135
|
+
set_defaults (kwargs) {
|
|
2077
2136
|
Object.assign(this._defaults, kwargs)
|
|
2078
2137
|
|
|
2079
2138
|
// if these defaults match any existing arguments, replace
|
|
2080
2139
|
// the previous default on the object with the new one
|
|
2081
|
-
for (
|
|
2140
|
+
for (const action of this._actions) {
|
|
2082
2141
|
if (action.dest in kwargs) {
|
|
2083
2142
|
action.default = kwargs[action.dest]
|
|
2084
2143
|
}
|
|
2085
2144
|
}
|
|
2086
2145
|
}
|
|
2087
2146
|
|
|
2088
|
-
get_default(dest) {
|
|
2089
|
-
for (
|
|
2147
|
+
get_default (dest) {
|
|
2148
|
+
for (const action of this._actions) {
|
|
2090
2149
|
if (action.dest === dest && action.default !== undefined) {
|
|
2091
2150
|
return action.default
|
|
2092
2151
|
}
|
|
@@ -2098,7 +2157,7 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2098
2157
|
// =======================
|
|
2099
2158
|
// Adding argument actions
|
|
2100
2159
|
// =======================
|
|
2101
|
-
add_argument() {
|
|
2160
|
+
add_argument () {
|
|
2102
2161
|
/*
|
|
2103
2162
|
* add_argument(dest, ..., name=value, ...)
|
|
2104
2163
|
* add_argument(option_string, option_string, ..., name=value, ...)
|
|
@@ -2110,23 +2169,23 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2110
2169
|
'*args': no_default,
|
|
2111
2170
|
'**kwargs': no_default
|
|
2112
2171
|
})
|
|
2113
|
-
//
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2172
|
+
// argparse v1 accepted an array of argument names here. Python argparse
|
|
2173
|
+
// accepts only individual string names and rejects a list; reject it
|
|
2174
|
+
// explicitly because JS would otherwise coerce the array to a string.
|
|
2175
|
+
if (args.some(arg => typeof arg !== 'string')) {
|
|
2176
|
+
throw new TypeError('argument name must be a string')
|
|
2177
|
+
}
|
|
2178
|
+
if (args.some(arg => !arg.length)) {
|
|
2179
|
+
throw new TypeError('argument name must not be empty')
|
|
2120
2180
|
}
|
|
2121
|
-
// end
|
|
2122
|
-
|
|
2123
2181
|
// if no positional args are supplied or only one is supplied and
|
|
2124
2182
|
// it doesn't look like an option string, parse a positional
|
|
2125
2183
|
// argument
|
|
2126
|
-
|
|
2184
|
+
const chars = this.prefix_chars
|
|
2127
2185
|
if (!args.length || args.length === 1 && !chars.includes(args[0][0])) {
|
|
2128
2186
|
if (args.length && 'dest' in kwargs) {
|
|
2129
|
-
throw new TypeError('dest supplied twice for positional argument'
|
|
2187
|
+
throw new TypeError('dest supplied twice for positional argument,' +
|
|
2188
|
+
' did you mean metavar?')
|
|
2130
2189
|
}
|
|
2131
2190
|
kwargs = this._get_positional_kwargs(...args, kwargs)
|
|
2132
2191
|
|
|
@@ -2137,7 +2196,7 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2137
2196
|
|
|
2138
2197
|
// if no default was supplied, use the parser-level default
|
|
2139
2198
|
if (!('default' in kwargs)) {
|
|
2140
|
-
|
|
2199
|
+
const dest = kwargs.dest
|
|
2141
2200
|
if (dest in this._defaults) {
|
|
2142
2201
|
kwargs.default = this._defaults[dest]
|
|
2143
2202
|
} else if (this.argument_default !== undefined) {
|
|
@@ -2146,15 +2205,22 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2146
2205
|
}
|
|
2147
2206
|
|
|
2148
2207
|
// create the action object, and add it to the parser
|
|
2149
|
-
|
|
2208
|
+
const action_name = kwargs.action
|
|
2209
|
+
const action_class = this._pop_action_class(kwargs)
|
|
2150
2210
|
if (typeof action_class !== 'function') {
|
|
2151
|
-
throw new TypeError(sub('unknown action
|
|
2211
|
+
throw new TypeError(sub('unknown action %r', action_class))
|
|
2152
2212
|
}
|
|
2153
2213
|
// eslint-disable-next-line new-cap
|
|
2154
|
-
|
|
2214
|
+
const action = new action_class(kwargs)
|
|
2215
|
+
|
|
2216
|
+
// raise an error if action for positional argument does not
|
|
2217
|
+
// consume arguments
|
|
2218
|
+
if (!action.option_strings.length && action.nargs === 0) {
|
|
2219
|
+
throw new TypeError(sub('action %r is not valid for positional arguments', action_name))
|
|
2220
|
+
}
|
|
2155
2221
|
|
|
2156
2222
|
// raise an error if the action type is not callable
|
|
2157
|
-
|
|
2223
|
+
const type_func = this._registry_get('type', action.type, action.type)
|
|
2158
2224
|
if (typeof type_func !== 'function') {
|
|
2159
2225
|
throw new TypeError(sub('%r is not callable', type_func))
|
|
2160
2226
|
}
|
|
@@ -2165,9 +2231,10 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2165
2231
|
}
|
|
2166
2232
|
|
|
2167
2233
|
// raise an error if the metavar does not match the type
|
|
2168
|
-
if ('
|
|
2234
|
+
if ('_get_validation_formatter' in this) {
|
|
2235
|
+
const formatter = this._get_validation_formatter()
|
|
2169
2236
|
try {
|
|
2170
|
-
|
|
2237
|
+
formatter._format_args(action, undefined)
|
|
2171
2238
|
} catch (err) {
|
|
2172
2239
|
// check for 'invalid nargs value' is an artifact of TypeError and ValueError in js being the same
|
|
2173
2240
|
if (err instanceof TypeError && err.message !== 'invalid nargs value') {
|
|
@@ -2178,23 +2245,25 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2178
2245
|
}
|
|
2179
2246
|
}
|
|
2180
2247
|
|
|
2248
|
+
this._check_help(action)
|
|
2249
|
+
|
|
2181
2250
|
return this._add_action(action)
|
|
2182
2251
|
}
|
|
2183
2252
|
|
|
2184
|
-
add_argument_group() {
|
|
2185
|
-
|
|
2253
|
+
add_argument_group () {
|
|
2254
|
+
const group = _ArgumentGroup(this, ...arguments)
|
|
2186
2255
|
this._action_groups.push(group)
|
|
2187
2256
|
return group
|
|
2188
2257
|
}
|
|
2189
2258
|
|
|
2190
|
-
add_mutually_exclusive_group() {
|
|
2191
|
-
|
|
2192
|
-
|
|
2259
|
+
add_mutually_exclusive_group () {
|
|
2260
|
+
|
|
2261
|
+
const group = _MutuallyExclusiveGroup(this, ...arguments)
|
|
2193
2262
|
this._mutually_exclusive_groups.push(group)
|
|
2194
2263
|
return group
|
|
2195
2264
|
}
|
|
2196
2265
|
|
|
2197
|
-
_add_action(action) {
|
|
2266
|
+
_add_action (action) {
|
|
2198
2267
|
// resolve any conflicts
|
|
2199
2268
|
this._check_conflict(action)
|
|
2200
2269
|
|
|
@@ -2203,12 +2272,12 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2203
2272
|
action.container = this
|
|
2204
2273
|
|
|
2205
2274
|
// index the action by any option strings it has
|
|
2206
|
-
for (
|
|
2275
|
+
for (const option_string of action.option_strings) {
|
|
2207
2276
|
this._option_string_actions[option_string] = action
|
|
2208
2277
|
}
|
|
2209
2278
|
|
|
2210
2279
|
// set the flag if any option strings look like negative numbers
|
|
2211
|
-
for (
|
|
2280
|
+
for (const option_string of action.option_strings) {
|
|
2212
2281
|
if (this._negative_number_matcher.test(option_string)) {
|
|
2213
2282
|
if (!this._has_negative_number_optionals.length) {
|
|
2214
2283
|
this._has_negative_number_optionals.push(true)
|
|
@@ -2220,24 +2289,26 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2220
2289
|
return action
|
|
2221
2290
|
}
|
|
2222
2291
|
|
|
2223
|
-
_remove_action(action) {
|
|
2292
|
+
_remove_action (action) {
|
|
2224
2293
|
_array_remove(this._actions, action)
|
|
2225
2294
|
}
|
|
2226
2295
|
|
|
2227
|
-
_add_container_actions(container) {
|
|
2296
|
+
_add_container_actions (container) {
|
|
2228
2297
|
// collect groups by titles
|
|
2229
|
-
|
|
2230
|
-
for (
|
|
2298
|
+
const title_group_map = Object.create(null)
|
|
2299
|
+
for (const group of this._action_groups) {
|
|
2231
2300
|
if (group.title in title_group_map) {
|
|
2232
|
-
|
|
2301
|
+
// This branch could happen if a derived class added
|
|
2302
|
+
// groups with duplicated titles in constructor.
|
|
2303
|
+
const msg = 'cannot merge actions - two groups are named %r'
|
|
2233
2304
|
throw new TypeError(sub(msg, group.title))
|
|
2234
2305
|
}
|
|
2235
2306
|
title_group_map[group.title] = group
|
|
2236
2307
|
}
|
|
2237
2308
|
|
|
2238
2309
|
// map each action to its group
|
|
2239
|
-
|
|
2240
|
-
for (
|
|
2310
|
+
const group_map = new Map()
|
|
2311
|
+
for (const group of container._action_groups) {
|
|
2241
2312
|
|
|
2242
2313
|
// if a group with the title exists, use that, otherwise
|
|
2243
2314
|
// create a new group matching the container's group
|
|
@@ -2250,7 +2321,7 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2250
2321
|
}
|
|
2251
2322
|
|
|
2252
2323
|
// map the actions to their new group
|
|
2253
|
-
for (
|
|
2324
|
+
for (const action of group._group_actions) {
|
|
2254
2325
|
group_map.set(action, title_group_map[group.title])
|
|
2255
2326
|
}
|
|
2256
2327
|
}
|
|
@@ -2258,25 +2329,32 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2258
2329
|
// add container's mutually exclusive groups
|
|
2259
2330
|
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
|
2260
2331
|
// description= then this code will need to be expanded as above
|
|
2261
|
-
for (
|
|
2262
|
-
let
|
|
2332
|
+
for (const group of container._mutually_exclusive_groups) {
|
|
2333
|
+
let cont
|
|
2334
|
+
if (group._container === container) {
|
|
2335
|
+
cont = this
|
|
2336
|
+
} else {
|
|
2337
|
+
cont = title_group_map[group._container.title]
|
|
2338
|
+
}
|
|
2339
|
+
const mutex_group = cont.add_mutually_exclusive_group({
|
|
2263
2340
|
required: group.required
|
|
2264
2341
|
})
|
|
2265
2342
|
|
|
2266
2343
|
// map the actions to their new mutex group
|
|
2267
|
-
for (
|
|
2344
|
+
for (const action of group._group_actions) {
|
|
2268
2345
|
group_map.set(action, mutex_group)
|
|
2269
2346
|
}
|
|
2270
2347
|
}
|
|
2271
2348
|
|
|
2272
2349
|
// add all actions to this container or their group
|
|
2273
|
-
for (
|
|
2274
|
-
group_map.get(action)
|
|
2350
|
+
for (const action of container._actions) {
|
|
2351
|
+
const action_group = group_map.get(action) || this
|
|
2352
|
+
action_group._add_action(action)
|
|
2275
2353
|
}
|
|
2276
2354
|
}
|
|
2277
2355
|
|
|
2278
|
-
_get_positional_kwargs() {
|
|
2279
|
-
|
|
2356
|
+
_get_positional_kwargs () {
|
|
2357
|
+
const [
|
|
2280
2358
|
dest,
|
|
2281
2359
|
kwargs
|
|
2282
2360
|
] = _parse_opts(arguments, {
|
|
@@ -2286,16 +2364,17 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2286
2364
|
|
|
2287
2365
|
// make sure required is not specified
|
|
2288
2366
|
if ('required' in kwargs) {
|
|
2289
|
-
|
|
2367
|
+
const msg = "'required' is an invalid argument for positionals"
|
|
2290
2368
|
throw new TypeError(msg)
|
|
2291
2369
|
}
|
|
2292
2370
|
|
|
2293
2371
|
// mark positional arguments as required if at least one is
|
|
2294
2372
|
// always required
|
|
2295
|
-
|
|
2296
|
-
|
|
2373
|
+
const nargs = kwargs.nargs
|
|
2374
|
+
if (nargs === 0) {
|
|
2375
|
+
throw new TypeError('nargs for positionals must be != 0')
|
|
2297
2376
|
}
|
|
2298
|
-
if (
|
|
2377
|
+
if (![OPTIONAL, ZERO_OR_MORE, REMAINDER, SUPPRESS].includes(nargs)) {
|
|
2299
2378
|
kwargs.required = true
|
|
2300
2379
|
}
|
|
2301
2380
|
|
|
@@ -2303,8 +2382,8 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2303
2382
|
return Object.assign(kwargs, { dest, option_strings: [] })
|
|
2304
2383
|
}
|
|
2305
2384
|
|
|
2306
|
-
_get_optional_kwargs() {
|
|
2307
|
-
|
|
2385
|
+
_get_optional_kwargs () {
|
|
2386
|
+
const [
|
|
2308
2387
|
args,
|
|
2309
2388
|
kwargs
|
|
2310
2389
|
] = _parse_opts(arguments, {
|
|
@@ -2313,15 +2392,15 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2313
2392
|
})
|
|
2314
2393
|
|
|
2315
2394
|
// determine short and long option strings
|
|
2316
|
-
|
|
2317
|
-
|
|
2395
|
+
const option_strings = []
|
|
2396
|
+
const long_option_strings = []
|
|
2318
2397
|
let option_string
|
|
2319
2398
|
for (option_string of args) {
|
|
2320
2399
|
// error on strings that don't start with an appropriate prefix
|
|
2321
2400
|
if (!this.prefix_chars.includes(option_string[0])) {
|
|
2322
|
-
|
|
2401
|
+
const args = {option: option_string,
|
|
2323
2402
|
prefix_chars: this.prefix_chars}
|
|
2324
|
-
|
|
2403
|
+
const msg = 'invalid option string %(option)r: ' +
|
|
2325
2404
|
'must start with a character %(prefix_chars)r'
|
|
2326
2405
|
throw new TypeError(sub(msg, args))
|
|
2327
2406
|
}
|
|
@@ -2345,7 +2424,7 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2345
2424
|
}
|
|
2346
2425
|
dest = _string_lstrip(dest_option_string, this.prefix_chars)
|
|
2347
2426
|
if (!dest) {
|
|
2348
|
-
|
|
2427
|
+
const msg = 'dest= is required for options like %r'
|
|
2349
2428
|
throw new TypeError(sub(msg, option_string))
|
|
2350
2429
|
}
|
|
2351
2430
|
dest = dest.replace(/-/g, '_')
|
|
@@ -2355,53 +2434,53 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2355
2434
|
return Object.assign(kwargs, { dest, option_strings })
|
|
2356
2435
|
}
|
|
2357
2436
|
|
|
2358
|
-
_pop_action_class(kwargs, default_value = undefined) {
|
|
2359
|
-
|
|
2437
|
+
_pop_action_class (kwargs, default_value = undefined) {
|
|
2438
|
+
const action = getattr(kwargs, 'action', default_value)
|
|
2360
2439
|
delete kwargs.action
|
|
2361
2440
|
return this._registry_get('action', action, action)
|
|
2362
2441
|
}
|
|
2363
2442
|
|
|
2364
|
-
_get_handler() {
|
|
2443
|
+
_get_handler () {
|
|
2365
2444
|
// determine function from conflict handler string
|
|
2366
|
-
|
|
2445
|
+
const handler_func_name = sub('_handle_conflict_%s', this.conflict_handler)
|
|
2367
2446
|
if (typeof this[handler_func_name] === 'function') {
|
|
2368
2447
|
return this[handler_func_name]
|
|
2369
2448
|
} else {
|
|
2370
|
-
|
|
2449
|
+
const msg = 'invalid conflict_resolution value: %r'
|
|
2371
2450
|
throw new TypeError(sub(msg, this.conflict_handler))
|
|
2372
2451
|
}
|
|
2373
2452
|
}
|
|
2374
2453
|
|
|
2375
|
-
_check_conflict(action) {
|
|
2454
|
+
_check_conflict (action) {
|
|
2376
2455
|
|
|
2377
2456
|
// find all options that conflict with this option
|
|
2378
|
-
|
|
2379
|
-
for (
|
|
2457
|
+
const confl_optionals = []
|
|
2458
|
+
for (const option_string of action.option_strings) {
|
|
2380
2459
|
if (hasattr(this._option_string_actions, option_string)) {
|
|
2381
|
-
|
|
2382
|
-
confl_optionals.push([
|
|
2460
|
+
const confl_optional = this._option_string_actions[option_string]
|
|
2461
|
+
confl_optionals.push([option_string, confl_optional])
|
|
2383
2462
|
}
|
|
2384
2463
|
}
|
|
2385
2464
|
|
|
2386
2465
|
// resolve any conflicts
|
|
2387
2466
|
if (confl_optionals.length) {
|
|
2388
|
-
|
|
2467
|
+
const conflict_handler = this._get_handler()
|
|
2389
2468
|
conflict_handler.call(this, action, confl_optionals)
|
|
2390
2469
|
}
|
|
2391
2470
|
}
|
|
2392
2471
|
|
|
2393
|
-
_handle_conflict_error(action, conflicting_actions) {
|
|
2394
|
-
|
|
2472
|
+
_handle_conflict_error (action, conflicting_actions) {
|
|
2473
|
+
const message = conflicting_actions.length === 1 ?
|
|
2395
2474
|
'conflicting option string: %s' :
|
|
2396
2475
|
'conflicting option strings: %s'
|
|
2397
|
-
|
|
2476
|
+
const conflict_string = conflicting_actions.map(([option_string]) => option_string).join(', ')
|
|
2398
2477
|
throw new ArgumentError(action, sub(message, conflict_string))
|
|
2399
2478
|
}
|
|
2400
2479
|
|
|
2401
|
-
_handle_conflict_resolve(action, conflicting_actions) {
|
|
2480
|
+
_handle_conflict_resolve (action, conflicting_actions) {
|
|
2402
2481
|
|
|
2403
2482
|
// remove all conflicting options
|
|
2404
|
-
for (
|
|
2483
|
+
for (const [option_string, action] of conflicting_actions) {
|
|
2405
2484
|
|
|
2406
2485
|
// remove the conflicting option
|
|
2407
2486
|
_array_remove(action.option_strings, option_string)
|
|
@@ -2414,13 +2493,27 @@ const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
|
|
|
2414
2493
|
}
|
|
2415
2494
|
}
|
|
2416
2495
|
}
|
|
2417
|
-
|
|
2496
|
+
|
|
2497
|
+
_check_help (action) {
|
|
2498
|
+
if (action.help && '_get_validation_formatter' in this) {
|
|
2499
|
+
const formatter = this._get_validation_formatter()
|
|
2500
|
+
try {
|
|
2501
|
+
formatter._expand_help(action)
|
|
2502
|
+
} catch (err) {
|
|
2503
|
+
if (err instanceof TypeError) {
|
|
2504
|
+
throw new TypeError('badly formed help string', { cause: err })
|
|
2505
|
+
}
|
|
2506
|
+
throw err
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
})
|
|
2418
2511
|
|
|
2419
2512
|
|
|
2420
2513
|
const _ArgumentGroup = _callable(class _ArgumentGroup extends _ActionsContainer {
|
|
2421
2514
|
|
|
2422
|
-
constructor() {
|
|
2423
|
-
|
|
2515
|
+
constructor () {
|
|
2516
|
+
const [
|
|
2424
2517
|
container,
|
|
2425
2518
|
title,
|
|
2426
2519
|
description,
|
|
@@ -2432,6 +2525,13 @@ const _ArgumentGroup = _callable(class _ArgumentGroup extends _ActionsContainer
|
|
|
2432
2525
|
'**kwargs': no_default
|
|
2433
2526
|
})
|
|
2434
2527
|
|
|
2528
|
+
if ('prefix_chars' in kwargs) {
|
|
2529
|
+
const depr_msg =
|
|
2530
|
+
"The use of the undocumented 'prefix_chars' parameter in " +
|
|
2531
|
+
'ArgumentParser.add_argument_group() is deprecated.'
|
|
2532
|
+
process.emitWarning(depr_msg, 'DeprecationWarning')
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2435
2535
|
// add any missing keyword arguments by checking the container
|
|
2436
2536
|
setdefault(kwargs, 'conflict_handler', container.conflict_handler)
|
|
2437
2537
|
setdefault(kwargs, 'prefix_chars', container.prefix_chars)
|
|
@@ -2452,23 +2552,27 @@ const _ArgumentGroup = _callable(class _ArgumentGroup extends _ActionsContainer
|
|
|
2452
2552
|
this._mutually_exclusive_groups = container._mutually_exclusive_groups
|
|
2453
2553
|
}
|
|
2454
2554
|
|
|
2455
|
-
_add_action(action) {
|
|
2555
|
+
_add_action (action) {
|
|
2456
2556
|
action = super._add_action(action)
|
|
2457
2557
|
this._group_actions.push(action)
|
|
2458
2558
|
return action
|
|
2459
2559
|
}
|
|
2460
2560
|
|
|
2461
|
-
_remove_action(action) {
|
|
2561
|
+
_remove_action (action) {
|
|
2462
2562
|
super._remove_action(action)
|
|
2463
2563
|
_array_remove(this._group_actions, action)
|
|
2464
2564
|
}
|
|
2565
|
+
|
|
2566
|
+
add_argument_group () {
|
|
2567
|
+
throw new TypeError('argument groups cannot be nested')
|
|
2568
|
+
}
|
|
2465
2569
|
})
|
|
2466
2570
|
|
|
2467
2571
|
|
|
2468
2572
|
const _MutuallyExclusiveGroup = _callable(class _MutuallyExclusiveGroup extends _ArgumentGroup {
|
|
2469
2573
|
|
|
2470
|
-
constructor() {
|
|
2471
|
-
|
|
2574
|
+
constructor () {
|
|
2575
|
+
const [
|
|
2472
2576
|
container,
|
|
2473
2577
|
required
|
|
2474
2578
|
] = _parse_opts(arguments, {
|
|
@@ -2481,9 +2585,9 @@ const _MutuallyExclusiveGroup = _callable(class _MutuallyExclusiveGroup extends
|
|
|
2481
2585
|
this._container = container
|
|
2482
2586
|
}
|
|
2483
2587
|
|
|
2484
|
-
_add_action(action) {
|
|
2588
|
+
_add_action (action) {
|
|
2485
2589
|
if (action.required) {
|
|
2486
|
-
|
|
2590
|
+
const msg = 'mutually exclusive arguments must be optional'
|
|
2487
2591
|
throw new TypeError(msg)
|
|
2488
2592
|
}
|
|
2489
2593
|
action = this._container._add_action(action)
|
|
@@ -2491,14 +2595,18 @@ const _MutuallyExclusiveGroup = _callable(class _MutuallyExclusiveGroup extends
|
|
|
2491
2595
|
return action
|
|
2492
2596
|
}
|
|
2493
2597
|
|
|
2494
|
-
_remove_action(action) {
|
|
2598
|
+
_remove_action (action) {
|
|
2495
2599
|
this._container._remove_action(action)
|
|
2496
2600
|
_array_remove(this._group_actions, action)
|
|
2497
2601
|
}
|
|
2602
|
+
|
|
2603
|
+
add_mutually_exclusive_group () {
|
|
2604
|
+
throw new TypeError('mutually exclusive groups cannot be nested')
|
|
2605
|
+
}
|
|
2498
2606
|
})
|
|
2499
2607
|
|
|
2500
2608
|
|
|
2501
|
-
const ArgumentParser =
|
|
2609
|
+
const ArgumentParser = _callable(class ArgumentParser extends _AttributeHolder(_ActionsContainer) {
|
|
2502
2610
|
/*
|
|
2503
2611
|
* Object for parsing command line strings into Python objects.
|
|
2504
2612
|
*
|
|
@@ -2518,9 +2626,12 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2518
2626
|
* - allow_abbrev -- Allow long options to be abbreviated unambiguously
|
|
2519
2627
|
* - exit_on_error -- Determines whether or not ArgumentParser exits with
|
|
2520
2628
|
* error info when an error occurs
|
|
2629
|
+
* - suggest_on_error - Enables suggestions for mistyped argument choices
|
|
2630
|
+
* and subparser names. (default: false)
|
|
2631
|
+
* - color - Allow color output in help messages (default: true)
|
|
2521
2632
|
*/
|
|
2522
2633
|
|
|
2523
|
-
constructor() {
|
|
2634
|
+
constructor () {
|
|
2524
2635
|
let [
|
|
2525
2636
|
prog,
|
|
2526
2637
|
usage,
|
|
@@ -2535,8 +2646,8 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2535
2646
|
add_help,
|
|
2536
2647
|
allow_abbrev,
|
|
2537
2648
|
exit_on_error,
|
|
2538
|
-
|
|
2539
|
-
|
|
2649
|
+
suggest_on_error,
|
|
2650
|
+
color
|
|
2540
2651
|
] = _parse_opts(arguments, {
|
|
2541
2652
|
prog: undefined,
|
|
2542
2653
|
usage: undefined,
|
|
@@ -2551,26 +2662,11 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2551
2662
|
add_help: true,
|
|
2552
2663
|
allow_abbrev: true,
|
|
2553
2664
|
exit_on_error: true,
|
|
2554
|
-
|
|
2555
|
-
|
|
2665
|
+
'*': no_default,
|
|
2666
|
+
suggest_on_error: false,
|
|
2667
|
+
color: true
|
|
2556
2668
|
})
|
|
2557
2669
|
|
|
2558
|
-
// LEGACY (v1 compatibility)
|
|
2559
|
-
if (debug !== undefined) {
|
|
2560
|
-
deprecate('debug',
|
|
2561
|
-
'The "debug" argument to ArgumentParser is deprecated. Please ' +
|
|
2562
|
-
'override ArgumentParser.exit function instead.'
|
|
2563
|
-
)
|
|
2564
|
-
}
|
|
2565
|
-
|
|
2566
|
-
if (version !== undefined) {
|
|
2567
|
-
deprecate('version',
|
|
2568
|
-
'The "version" argument to ArgumentParser is deprecated. Please use ' +
|
|
2569
|
-
"add_argument(..., { action: 'version', version: 'N', ... }) instead."
|
|
2570
|
-
)
|
|
2571
|
-
}
|
|
2572
|
-
// end
|
|
2573
|
-
|
|
2574
2670
|
super({
|
|
2575
2671
|
description,
|
|
2576
2672
|
prefix_chars,
|
|
@@ -2591,44 +2687,44 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2591
2687
|
this.add_help = add_help
|
|
2592
2688
|
this.allow_abbrev = allow_abbrev
|
|
2593
2689
|
this.exit_on_error = exit_on_error
|
|
2594
|
-
|
|
2595
|
-
this.
|
|
2596
|
-
|
|
2690
|
+
this.suggest_on_error = suggest_on_error
|
|
2691
|
+
this.color = color
|
|
2692
|
+
|
|
2693
|
+
// Cached formatter for validation (avoids repeated _set_color calls)
|
|
2694
|
+
this._cached_formatter = undefined
|
|
2597
2695
|
|
|
2598
2696
|
this._positionals = this.add_argument_group('positional arguments')
|
|
2599
|
-
this._optionals = this.add_argument_group('
|
|
2697
|
+
this._optionals = this.add_argument_group('options')
|
|
2600
2698
|
this._subparsers = undefined
|
|
2601
2699
|
|
|
2602
2700
|
// register types
|
|
2603
|
-
function identity(string) {
|
|
2701
|
+
function identity (string) {
|
|
2604
2702
|
return string
|
|
2605
2703
|
}
|
|
2606
2704
|
this.register('type', undefined, identity)
|
|
2607
2705
|
this.register('type', null, identity)
|
|
2608
|
-
this.register('type', 'auto', identity)
|
|
2609
2706
|
this.register('type', 'int', function (x) {
|
|
2610
|
-
|
|
2707
|
+
if (typeof x === 'string' && !/^[+-]?\d+(?:_?\d+)*$/.test(x.trim())) {
|
|
2708
|
+
throw new TypeError(sub('could not convert string to int: %r', x))
|
|
2709
|
+
}
|
|
2710
|
+
const result = _string_to_number(x)
|
|
2611
2711
|
if (!Number.isInteger(result)) {
|
|
2612
2712
|
throw new TypeError(sub('could not convert string to int: %r', x))
|
|
2613
2713
|
}
|
|
2614
2714
|
return result
|
|
2615
2715
|
})
|
|
2616
2716
|
this.register('type', 'float', function (x) {
|
|
2617
|
-
|
|
2717
|
+
const result = _string_to_number(x)
|
|
2618
2718
|
if (isNaN(result)) {
|
|
2619
2719
|
throw new TypeError(sub('could not convert string to float: %r', x))
|
|
2620
2720
|
}
|
|
2621
2721
|
return result
|
|
2622
2722
|
})
|
|
2623
2723
|
this.register('type', 'str', String)
|
|
2624
|
-
// LEGACY (v1 compatibility): custom types
|
|
2625
|
-
this.register('type', 'string',
|
|
2626
|
-
util.deprecate(String, 'use {type:"str"} or {type:String} instead of {type:"string"}'))
|
|
2627
|
-
// end
|
|
2628
2724
|
|
|
2629
2725
|
// add help argument if necessary
|
|
2630
2726
|
// (using explicit default to override global argument_default)
|
|
2631
|
-
|
|
2727
|
+
const default_prefix = prefix_chars.includes('-') ? '-' : prefix_chars[0]
|
|
2632
2728
|
if (this.add_help) {
|
|
2633
2729
|
this.add_argument(
|
|
2634
2730
|
default_prefix + 'h',
|
|
@@ -2640,23 +2736,11 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2640
2736
|
}
|
|
2641
2737
|
)
|
|
2642
2738
|
}
|
|
2643
|
-
// LEGACY (v1 compatibility), version
|
|
2644
|
-
if (version) {
|
|
2645
|
-
this.add_argument(
|
|
2646
|
-
default_prefix + 'v',
|
|
2647
|
-
default_prefix.repeat(2) + 'version',
|
|
2648
|
-
{
|
|
2649
|
-
action: 'version',
|
|
2650
|
-
default: SUPPRESS,
|
|
2651
|
-
version: this.version,
|
|
2652
|
-
help: "show program's version number and exit"
|
|
2653
|
-
}
|
|
2654
|
-
)
|
|
2655
|
-
}
|
|
2656
|
-
// end
|
|
2657
|
-
|
|
2658
2739
|
// add parent arguments and defaults
|
|
2659
|
-
for (
|
|
2740
|
+
for (const parent of parents) {
|
|
2741
|
+
if (!(parent instanceof ArgumentParser)) {
|
|
2742
|
+
throw new TypeError('parents must be a list of ArgumentParser')
|
|
2743
|
+
}
|
|
2660
2744
|
this._add_container_actions(parent)
|
|
2661
2745
|
Object.assign(this._defaults, parent._defaults)
|
|
2662
2746
|
}
|
|
@@ -2665,8 +2749,8 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2665
2749
|
// =======================
|
|
2666
2750
|
// Pretty __repr__ methods
|
|
2667
2751
|
// =======================
|
|
2668
|
-
_get_kwargs() {
|
|
2669
|
-
|
|
2752
|
+
_get_kwargs () {
|
|
2753
|
+
const names = [
|
|
2670
2754
|
'prog',
|
|
2671
2755
|
'usage',
|
|
2672
2756
|
'description',
|
|
@@ -2674,29 +2758,29 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2674
2758
|
'conflict_handler',
|
|
2675
2759
|
'add_help'
|
|
2676
2760
|
]
|
|
2677
|
-
return names.map(name => [
|
|
2761
|
+
return names.map(name => [name, getattr(this, name)])
|
|
2678
2762
|
}
|
|
2679
2763
|
|
|
2680
2764
|
// ==================================
|
|
2681
2765
|
// Optional/Positional adding methods
|
|
2682
2766
|
// ==================================
|
|
2683
|
-
add_subparsers() {
|
|
2684
|
-
|
|
2767
|
+
add_subparsers () {
|
|
2768
|
+
const [
|
|
2685
2769
|
kwargs
|
|
2686
2770
|
] = _parse_opts(arguments, {
|
|
2687
2771
|
'**kwargs': no_default
|
|
2688
2772
|
})
|
|
2689
2773
|
|
|
2690
2774
|
if (this._subparsers !== undefined) {
|
|
2691
|
-
|
|
2775
|
+
throw new TypeError('cannot have multiple subparser arguments')
|
|
2692
2776
|
}
|
|
2693
2777
|
|
|
2694
2778
|
// add the parser class to the arguments if it's not present
|
|
2695
2779
|
setdefault(kwargs, 'parser_class', this.constructor)
|
|
2696
2780
|
|
|
2697
2781
|
if ('title' in kwargs || 'description' in kwargs) {
|
|
2698
|
-
|
|
2699
|
-
|
|
2782
|
+
const title = getattr(kwargs, 'title', 'subcommands')
|
|
2783
|
+
const description = getattr(kwargs, 'description', undefined)
|
|
2700
2784
|
delete kwargs.title
|
|
2701
2785
|
delete kwargs.description
|
|
2702
2786
|
this._subparsers = this.add_argument_group(title, description)
|
|
@@ -2707,24 +2791,32 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2707
2791
|
// prog defaults to the usage message of this parser, skipping
|
|
2708
2792
|
// optional arguments and with no "usage:" prefix
|
|
2709
2793
|
if (kwargs.prog === undefined) {
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
formatter.
|
|
2794
|
+
// Create formatter without color to avoid storing ANSI codes in prog
|
|
2795
|
+
// eslint-disable-next-line new-cap
|
|
2796
|
+
const formatter = new this.formatter_class({ prog: this.prog })
|
|
2797
|
+
formatter._set_color(false)
|
|
2798
|
+
const positionals = this._get_positional_actions()
|
|
2799
|
+
const groups = this._mutually_exclusive_groups
|
|
2800
|
+
formatter.add_usage(undefined, positionals, groups, '')
|
|
2714
2801
|
kwargs.prog = formatter.format_help().trim()
|
|
2715
2802
|
}
|
|
2716
2803
|
|
|
2717
2804
|
// create the parsers action and add it to the positionals list
|
|
2718
|
-
|
|
2805
|
+
const parsers_class = this._pop_action_class(kwargs, 'parsers')
|
|
2806
|
+
if (hasattr(kwargs, 'option_strings')) {
|
|
2807
|
+
throw new TypeError("add_subparsers() got multiple values for argument 'option_strings'")
|
|
2808
|
+
}
|
|
2719
2809
|
// eslint-disable-next-line new-cap
|
|
2720
|
-
|
|
2810
|
+
const action = new parsers_class(Object.assign({ option_strings: [] }, kwargs))
|
|
2811
|
+
action._color = this.color
|
|
2812
|
+
this._check_help(action)
|
|
2721
2813
|
this._subparsers._add_action(action)
|
|
2722
2814
|
|
|
2723
2815
|
// return the created parsers action
|
|
2724
2816
|
return action
|
|
2725
2817
|
}
|
|
2726
2818
|
|
|
2727
|
-
_add_action(action) {
|
|
2819
|
+
_add_action (action) {
|
|
2728
2820
|
if (action.option_strings.length) {
|
|
2729
2821
|
this._optionals._add_action(action)
|
|
2730
2822
|
} else {
|
|
@@ -2733,30 +2825,40 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2733
2825
|
return action
|
|
2734
2826
|
}
|
|
2735
2827
|
|
|
2736
|
-
_get_optional_actions() {
|
|
2828
|
+
_get_optional_actions () {
|
|
2737
2829
|
return this._actions.filter(action => action.option_strings.length)
|
|
2738
2830
|
}
|
|
2739
2831
|
|
|
2740
|
-
_get_positional_actions() {
|
|
2832
|
+
_get_positional_actions () {
|
|
2741
2833
|
return this._actions.filter(action => !action.option_strings.length)
|
|
2742
2834
|
}
|
|
2743
2835
|
|
|
2744
2836
|
// =====================================
|
|
2745
2837
|
// Command line argument parsing methods
|
|
2746
2838
|
// =====================================
|
|
2747
|
-
parse_args(args = undefined, namespace = undefined) {
|
|
2839
|
+
parse_args (args = undefined, namespace = undefined) {
|
|
2748
2840
|
let argv
|
|
2749
|
-
[
|
|
2841
|
+
[args, argv] = this.parse_known_args(args, namespace)
|
|
2750
2842
|
if (argv && argv.length > 0) {
|
|
2751
|
-
|
|
2752
|
-
this.
|
|
2843
|
+
const msg = sub('unrecognized arguments: %s', argv.join(' '))
|
|
2844
|
+
if (this.exit_on_error) {
|
|
2845
|
+
this.error(msg)
|
|
2846
|
+
} else {
|
|
2847
|
+
throw new ArgumentError(undefined, msg)
|
|
2848
|
+
}
|
|
2753
2849
|
}
|
|
2754
2850
|
return args
|
|
2755
2851
|
}
|
|
2756
2852
|
|
|
2757
|
-
parse_known_args(args = undefined, namespace = undefined) {
|
|
2853
|
+
parse_known_args (args = undefined, namespace = undefined) {
|
|
2854
|
+
return this._parse_known_args2(args, namespace, false)
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
_parse_known_args2 (args, namespace, intermixed) {
|
|
2758
2858
|
if (args === undefined) {
|
|
2759
2859
|
args = get_argv().slice(1)
|
|
2860
|
+
} else {
|
|
2861
|
+
args = Array.from(args)
|
|
2760
2862
|
}
|
|
2761
2863
|
|
|
2762
2864
|
// default Namespace built from parser defaults
|
|
@@ -2765,7 +2867,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2765
2867
|
}
|
|
2766
2868
|
|
|
2767
2869
|
// add any action defaults that aren't present
|
|
2768
|
-
for (
|
|
2870
|
+
for (const action of this._actions) {
|
|
2769
2871
|
if (action.dest !== SUPPRESS) {
|
|
2770
2872
|
if (!hasattr(namespace, action.dest)) {
|
|
2771
2873
|
if (action.default !== SUPPRESS) {
|
|
@@ -2776,7 +2878,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2776
2878
|
}
|
|
2777
2879
|
|
|
2778
2880
|
// add any parser defaults that aren't present
|
|
2779
|
-
for (
|
|
2881
|
+
for (const dest of Object.keys(this._defaults)) {
|
|
2780
2882
|
if (!hasattr(namespace, dest)) {
|
|
2781
2883
|
setattr(namespace, dest, this._defaults[dest])
|
|
2782
2884
|
}
|
|
@@ -2785,7 +2887,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2785
2887
|
// parse the arguments and exit if there are any errors
|
|
2786
2888
|
if (this.exit_on_error) {
|
|
2787
2889
|
try {
|
|
2788
|
-
[
|
|
2890
|
+
[namespace, args] = this._parse_known_args(args, namespace, intermixed)
|
|
2789
2891
|
} catch (err) {
|
|
2790
2892
|
if (err instanceof ArgumentError) {
|
|
2791
2893
|
this.error(err.message)
|
|
@@ -2794,7 +2896,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2794
2896
|
}
|
|
2795
2897
|
}
|
|
2796
2898
|
} else {
|
|
2797
|
-
[
|
|
2899
|
+
[namespace, args] = this._parse_known_args(args, namespace, intermixed)
|
|
2798
2900
|
}
|
|
2799
2901
|
|
|
2800
2902
|
if (hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) {
|
|
@@ -2802,10 +2904,10 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2802
2904
|
delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
|
|
2803
2905
|
}
|
|
2804
2906
|
|
|
2805
|
-
return [
|
|
2907
|
+
return [namespace, args]
|
|
2806
2908
|
}
|
|
2807
2909
|
|
|
2808
|
-
_parse_known_args(arg_strings, namespace) {
|
|
2910
|
+
_parse_known_args (arg_strings, namespace, intermixed) {
|
|
2809
2911
|
// replace arg strings that are file references
|
|
2810
2912
|
if (this.fromfile_prefix_chars !== undefined) {
|
|
2811
2913
|
arg_strings = this._read_args_from_files(arg_strings)
|
|
@@ -2813,10 +2915,10 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2813
2915
|
|
|
2814
2916
|
// map all mutually exclusive arguments to the other arguments
|
|
2815
2917
|
// they can't occur with
|
|
2816
|
-
|
|
2817
|
-
for (
|
|
2818
|
-
|
|
2819
|
-
for (
|
|
2918
|
+
const action_conflicts = new Map()
|
|
2919
|
+
for (const mutex_group of this._mutually_exclusive_groups) {
|
|
2920
|
+
const group_actions = mutex_group._group_actions
|
|
2921
|
+
for (const [i, mutex_action] of Object.entries(mutex_group._group_actions)) {
|
|
2820
2922
|
let conflicts = action_conflicts.get(mutex_action) || []
|
|
2821
2923
|
conflicts = conflicts.concat(group_actions.slice(0, +i))
|
|
2822
2924
|
conflicts = conflicts.concat(group_actions.slice(+i + 1))
|
|
@@ -2827,27 +2929,27 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2827
2929
|
// find all option indices, and determine the arg_string_pattern
|
|
2828
2930
|
// which has an 'O' if there is an option at an index,
|
|
2829
2931
|
// an 'A' if there is an argument, or a '-' if there is a '--'
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
for (let [
|
|
2932
|
+
const option_string_indices = {}
|
|
2933
|
+
const arg_string_pattern_parts = []
|
|
2934
|
+
const arg_strings_iter = Object.entries(arg_strings)[Symbol.iterator]()
|
|
2935
|
+
for (let [i, arg_string] of arg_strings_iter) {
|
|
2834
2936
|
|
|
2835
2937
|
// all args after -- are non-options
|
|
2836
2938
|
if (arg_string === '--') {
|
|
2837
2939
|
arg_string_pattern_parts.push('-')
|
|
2838
|
-
for ([
|
|
2940
|
+
for ([i, arg_string] of arg_strings_iter) {
|
|
2839
2941
|
arg_string_pattern_parts.push('A')
|
|
2840
2942
|
}
|
|
2841
2943
|
|
|
2842
2944
|
// otherwise, add the arg to the arg strings
|
|
2843
2945
|
// and note the index if it was an option
|
|
2844
2946
|
} else {
|
|
2845
|
-
|
|
2947
|
+
const option_tuples = this._parse_optional(arg_string)
|
|
2846
2948
|
let pattern
|
|
2847
|
-
if (
|
|
2949
|
+
if (option_tuples === undefined) {
|
|
2848
2950
|
pattern = 'A'
|
|
2849
2951
|
} else {
|
|
2850
|
-
option_string_indices[i] =
|
|
2952
|
+
option_string_indices[i] = option_tuples
|
|
2851
2953
|
pattern = 'O'
|
|
2852
2954
|
}
|
|
2853
2955
|
arg_string_pattern_parts.push(pattern)
|
|
@@ -2858,23 +2960,23 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2858
2960
|
let arg_strings_pattern = arg_string_pattern_parts.join('')
|
|
2859
2961
|
|
|
2860
2962
|
// converts arg strings to the appropriate and then takes the action
|
|
2861
|
-
|
|
2862
|
-
|
|
2963
|
+
const seen_actions = new Set()
|
|
2964
|
+
const seen_non_default_actions = new Set()
|
|
2965
|
+
const warned = new Set()
|
|
2863
2966
|
let extras
|
|
2864
2967
|
|
|
2865
|
-
|
|
2968
|
+
const take_action = (action, argument_strings, option_string = undefined) => {
|
|
2866
2969
|
seen_actions.add(action)
|
|
2867
|
-
|
|
2970
|
+
const argument_values = this._get_values(action, argument_strings)
|
|
2868
2971
|
|
|
2869
2972
|
// error if this argument is not allowed with other previously
|
|
2870
|
-
// seen arguments
|
|
2871
|
-
|
|
2872
|
-
if (argument_values !== action.default) {
|
|
2973
|
+
// seen arguments
|
|
2974
|
+
if (action.option_strings.length || argument_strings.length) {
|
|
2873
2975
|
seen_non_default_actions.add(action)
|
|
2874
|
-
for (
|
|
2976
|
+
for (const conflict_action of action_conflicts.get(action) || []) {
|
|
2875
2977
|
if (seen_non_default_actions.has(conflict_action)) {
|
|
2876
|
-
|
|
2877
|
-
|
|
2978
|
+
const msg = 'not allowed with argument %s'
|
|
2979
|
+
const action_name = _get_action_name(conflict_action)
|
|
2878
2980
|
throw new ArgumentError(action, sub(msg, action_name))
|
|
2879
2981
|
}
|
|
2880
2982
|
}
|
|
@@ -2888,59 +2990,81 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2888
2990
|
}
|
|
2889
2991
|
|
|
2890
2992
|
// function to convert arg_strings into an optional action
|
|
2891
|
-
|
|
2993
|
+
const consume_optional = start_index => {
|
|
2892
2994
|
|
|
2893
2995
|
// get the optional identified at this index
|
|
2894
|
-
|
|
2895
|
-
|
|
2996
|
+
const option_tuples = option_string_indices[start_index]
|
|
2997
|
+
if (option_tuples.length > 1) {
|
|
2998
|
+
const options = option_tuples.map(([, option_string]) => option_string).join(', ')
|
|
2999
|
+
const args = {option: arg_strings[start_index], matches: options}
|
|
3000
|
+
const msg = 'ambiguous option: %(option)s could match %(matches)s'
|
|
3001
|
+
throw new ArgumentError(undefined, sub(msg, args))
|
|
3002
|
+
}
|
|
3003
|
+
let [action, option_string, sep, explicit_arg] = option_tuples[0]
|
|
2896
3004
|
|
|
2897
3005
|
// identify additional optionals in the same arg string
|
|
2898
3006
|
// (e.g. -xyz is the same as -x -y -z if no args are required)
|
|
2899
|
-
|
|
3007
|
+
const action_tuples = []
|
|
2900
3008
|
let stop
|
|
2901
3009
|
for (;;) {
|
|
2902
3010
|
|
|
2903
3011
|
// if we found no optional action, skip it
|
|
2904
3012
|
if (action === undefined) {
|
|
2905
3013
|
extras.push(arg_strings[start_index])
|
|
3014
|
+
extras_pattern.push('O')
|
|
2906
3015
|
return start_index + 1
|
|
2907
3016
|
}
|
|
2908
3017
|
|
|
2909
3018
|
// if there is an explicit argument, try to match the
|
|
2910
3019
|
// optional's string arguments to only this
|
|
2911
3020
|
if (explicit_arg !== undefined) {
|
|
2912
|
-
|
|
3021
|
+
const arg_count = this._match_argument(action, 'A')
|
|
2913
3022
|
|
|
2914
3023
|
// if the action is a single-dash option and takes no
|
|
2915
3024
|
// arguments, try to parse more single-dash options out
|
|
2916
3025
|
// of the tail of the option string
|
|
2917
|
-
|
|
2918
|
-
if (arg_count === 0 &&
|
|
2919
|
-
|
|
2920
|
-
|
|
3026
|
+
const chars = this.prefix_chars
|
|
3027
|
+
if (arg_count === 0 &&
|
|
3028
|
+
!chars.includes(option_string[1]) &&
|
|
3029
|
+
explicit_arg !== '') {
|
|
3030
|
+
if (sep || chars.includes(explicit_arg[0])) {
|
|
3031
|
+
const msg = 'ignored explicit argument %r'
|
|
3032
|
+
throw new ArgumentError(action, sub(msg, explicit_arg))
|
|
3033
|
+
}
|
|
3034
|
+
action_tuples.push([action, [], option_string])
|
|
3035
|
+
const char = option_string[0]
|
|
2921
3036
|
option_string = char + explicit_arg[0]
|
|
2922
|
-
|
|
2923
|
-
let optionals_map = this._option_string_actions
|
|
3037
|
+
const optionals_map = this._option_string_actions
|
|
2924
3038
|
if (hasattr(optionals_map, option_string)) {
|
|
2925
3039
|
action = optionals_map[option_string]
|
|
2926
|
-
explicit_arg =
|
|
3040
|
+
explicit_arg = explicit_arg.slice(1)
|
|
3041
|
+
if (!explicit_arg) {
|
|
3042
|
+
sep = explicit_arg = undefined
|
|
3043
|
+
} else if (explicit_arg[0] === '=') {
|
|
3044
|
+
sep = '='
|
|
3045
|
+
explicit_arg = explicit_arg.slice(1)
|
|
3046
|
+
} else {
|
|
3047
|
+
sep = ''
|
|
3048
|
+
}
|
|
2927
3049
|
} else {
|
|
2928
|
-
|
|
2929
|
-
|
|
3050
|
+
extras.push(char + explicit_arg)
|
|
3051
|
+
extras_pattern.push('O')
|
|
3052
|
+
stop = start_index + 1
|
|
3053
|
+
break
|
|
2930
3054
|
}
|
|
2931
3055
|
|
|
2932
3056
|
// if the action expect exactly one argument, we've
|
|
2933
3057
|
// successfully matched the option; exit the loop
|
|
2934
3058
|
} else if (arg_count === 1) {
|
|
2935
3059
|
stop = start_index + 1
|
|
2936
|
-
|
|
2937
|
-
action_tuples.push([
|
|
3060
|
+
const args = [explicit_arg]
|
|
3061
|
+
action_tuples.push([action, args, option_string])
|
|
2938
3062
|
break
|
|
2939
3063
|
|
|
2940
3064
|
// error if a double-dash option did not use the
|
|
2941
3065
|
// explicit argument
|
|
2942
3066
|
} else {
|
|
2943
|
-
|
|
3067
|
+
const msg = 'ignored explicit argument %r'
|
|
2944
3068
|
throw new ArgumentError(action, sub(msg, explicit_arg))
|
|
2945
3069
|
}
|
|
2946
3070
|
|
|
@@ -2948,12 +3072,12 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2948
3072
|
// optional's string arguments with the following strings
|
|
2949
3073
|
// if successful, exit the loop
|
|
2950
3074
|
} else {
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3075
|
+
const start = start_index + 1
|
|
3076
|
+
const selected_patterns = arg_strings_pattern.slice(start)
|
|
3077
|
+
const arg_count = this._match_argument(action, selected_patterns)
|
|
2954
3078
|
stop = start + arg_count
|
|
2955
|
-
|
|
2956
|
-
action_tuples.push([
|
|
3079
|
+
const args = arg_strings.slice(start, stop)
|
|
3080
|
+
action_tuples.push([action, args, option_string])
|
|
2957
3081
|
break
|
|
2958
3082
|
}
|
|
2959
3083
|
}
|
|
@@ -2961,7 +3085,13 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2961
3085
|
// add the Optional to the list and return the index at which
|
|
2962
3086
|
// the Optional's string args stopped
|
|
2963
3087
|
assert(action_tuples.length)
|
|
2964
|
-
for (
|
|
3088
|
+
for (const [action, args, option_string] of action_tuples) {
|
|
3089
|
+
if (action.deprecated && !warned.has(option_string)) {
|
|
3090
|
+
this._warning(sub("option '%(option)s' is deprecated", {
|
|
3091
|
+
option: option_string
|
|
3092
|
+
}))
|
|
3093
|
+
warned.add(option_string)
|
|
3094
|
+
}
|
|
2965
3095
|
take_action(action, args, option_string)
|
|
2966
3096
|
}
|
|
2967
3097
|
return stop
|
|
@@ -2972,18 +3102,35 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2972
3102
|
let positionals = this._get_positional_actions()
|
|
2973
3103
|
|
|
2974
3104
|
// function to convert arg_strings into positional actions
|
|
2975
|
-
|
|
3105
|
+
const consume_positionals = start_index => {
|
|
2976
3106
|
// match as many Positionals as possible
|
|
2977
|
-
|
|
2978
|
-
|
|
3107
|
+
const selected_pattern = arg_strings_pattern.slice(start_index)
|
|
3108
|
+
const arg_counts = this._match_arguments_partial(positionals, selected_pattern)
|
|
2979
3109
|
|
|
2980
3110
|
// slice off the appropriate arg strings for each Positional
|
|
2981
3111
|
// and add the Positional and its args to the list
|
|
2982
3112
|
for (let i = 0; i < positionals.length && i < arg_counts.length; i++) {
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
3113
|
+
const action = positionals[i]
|
|
3114
|
+
const arg_count = arg_counts[i]
|
|
3115
|
+
const args = arg_strings.slice(start_index, start_index + arg_count)
|
|
3116
|
+
// Strip out the first '--' if it is not in REMAINDER arg.
|
|
3117
|
+
if (action.nargs === PARSER) {
|
|
3118
|
+
if (arg_strings_pattern[start_index] === '-') {
|
|
3119
|
+
assert(args[0] === '--')
|
|
3120
|
+
_array_remove(args, '--')
|
|
3121
|
+
}
|
|
3122
|
+
} else if (action.nargs !== REMAINDER) {
|
|
3123
|
+
if (arg_strings_pattern.slice(start_index, start_index + arg_count).includes('-')) {
|
|
3124
|
+
_array_remove(args, '--')
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
2986
3127
|
start_index += arg_count
|
|
3128
|
+
if (args.length && action.deprecated && !warned.has(action.dest)) {
|
|
3129
|
+
this._warning(sub("argument '%(argument_name)s' is deprecated", {
|
|
3130
|
+
argument_name: action.dest
|
|
3131
|
+
}))
|
|
3132
|
+
warned.add(action.dest)
|
|
3133
|
+
}
|
|
2987
3134
|
take_action(action, args)
|
|
2988
3135
|
}
|
|
2989
3136
|
|
|
@@ -2996,17 +3143,21 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
2996
3143
|
// consume Positionals and Optionals alternately, until we have
|
|
2997
3144
|
// passed the last option string
|
|
2998
3145
|
extras = []
|
|
3146
|
+
let extras_pattern = []
|
|
2999
3147
|
let start_index = 0
|
|
3000
|
-
|
|
3148
|
+
const max_option_string_index = Math.max(-1, ...Object.keys(option_string_indices).map(Number))
|
|
3001
3149
|
while (start_index <= max_option_string_index) {
|
|
3002
3150
|
|
|
3003
3151
|
// consume any Positionals preceding the next option
|
|
3004
|
-
let next_option_string_index =
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3152
|
+
let next_option_string_index = start_index
|
|
3153
|
+
while (next_option_string_index <= max_option_string_index) {
|
|
3154
|
+
if (next_option_string_index in option_string_indices) {
|
|
3155
|
+
break
|
|
3156
|
+
}
|
|
3157
|
+
next_option_string_index += 1
|
|
3158
|
+
}
|
|
3159
|
+
if (!intermixed && start_index !== next_option_string_index) {
|
|
3160
|
+
const positionals_end_index = consume_positionals(start_index)
|
|
3010
3161
|
|
|
3011
3162
|
// only try to parse the next optional if we didn't consume
|
|
3012
3163
|
// the option string during the positionals parsing
|
|
@@ -3021,8 +3172,10 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3021
3172
|
// if we consumed all the positionals we could and we're not
|
|
3022
3173
|
// at the index of an option string, there were extra arguments
|
|
3023
3174
|
if (!(start_index in option_string_indices)) {
|
|
3024
|
-
|
|
3175
|
+
const strings = arg_strings.slice(start_index, next_option_string_index)
|
|
3025
3176
|
extras = extras.concat(strings)
|
|
3177
|
+
extras_pattern = extras_pattern.concat(
|
|
3178
|
+
arg_strings_pattern.slice(start_index, next_option_string_index).split(''))
|
|
3026
3179
|
start_index = next_option_string_index
|
|
3027
3180
|
}
|
|
3028
3181
|
|
|
@@ -3030,16 +3183,37 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3030
3183
|
start_index = consume_optional(start_index)
|
|
3031
3184
|
}
|
|
3032
3185
|
|
|
3033
|
-
|
|
3034
|
-
|
|
3186
|
+
if (!intermixed) {
|
|
3187
|
+
// consume any positionals following the last Optional
|
|
3188
|
+
const stop_index = consume_positionals(start_index)
|
|
3035
3189
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3190
|
+
// if we didn't consume all the argument strings, there were extras
|
|
3191
|
+
extras = extras.concat(arg_strings.slice(stop_index))
|
|
3192
|
+
} else {
|
|
3193
|
+
extras = extras.concat(arg_strings.slice(start_index))
|
|
3194
|
+
extras_pattern = extras_pattern.concat(
|
|
3195
|
+
arg_strings_pattern.slice(start_index).split(''))
|
|
3196
|
+
extras_pattern = extras_pattern.join('')
|
|
3197
|
+
assert(extras_pattern.length === extras.length)
|
|
3198
|
+
// consume all positionals
|
|
3199
|
+
arg_strings = extras.filter((string, i) => extras_pattern[i] !== 'O')
|
|
3200
|
+
arg_strings_pattern = extras_pattern.replace(/O/g, '')
|
|
3201
|
+
let stop_index = consume_positionals(0)
|
|
3202
|
+
// leave unknown optionals and non-consumed positionals in extras
|
|
3203
|
+
for (let i = 0; i < extras_pattern.length; i++) {
|
|
3204
|
+
if (!stop_index) break
|
|
3205
|
+
if (extras_pattern[i] !== 'O') {
|
|
3206
|
+
stop_index -= 1
|
|
3207
|
+
extras[i] = undefined
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
extras = extras.filter(string => string !== undefined)
|
|
3211
|
+
}
|
|
3038
3212
|
|
|
3039
3213
|
// make sure all required actions were present and also convert
|
|
3040
3214
|
// action defaults which were not given as arguments
|
|
3041
|
-
|
|
3042
|
-
for (
|
|
3215
|
+
const required_actions = []
|
|
3216
|
+
for (const action of this._actions) {
|
|
3043
3217
|
if (!seen_actions.has(action)) {
|
|
3044
3218
|
if (action.required) {
|
|
3045
3219
|
required_actions.push(_get_action_name(action))
|
|
@@ -3060,15 +3234,15 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3060
3234
|
}
|
|
3061
3235
|
|
|
3062
3236
|
if (required_actions.length) {
|
|
3063
|
-
|
|
3064
|
-
|
|
3237
|
+
throw new ArgumentError(undefined,
|
|
3238
|
+
sub('the following arguments are required: %s', required_actions.join(', ')))
|
|
3065
3239
|
}
|
|
3066
3240
|
|
|
3067
3241
|
// make sure all required groups had one option present
|
|
3068
|
-
for (
|
|
3242
|
+
for (const group of this._mutually_exclusive_groups) {
|
|
3069
3243
|
if (group.required) {
|
|
3070
3244
|
let no_actions_used = true
|
|
3071
|
-
for (
|
|
3245
|
+
for (const action of group._group_actions) {
|
|
3072
3246
|
if (seen_non_default_actions.has(action)) {
|
|
3073
3247
|
no_actions_used = false
|
|
3074
3248
|
break
|
|
@@ -3077,23 +3251,23 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3077
3251
|
|
|
3078
3252
|
// if no actions were used, report the error
|
|
3079
3253
|
if (no_actions_used) {
|
|
3080
|
-
|
|
3254
|
+
const names = group._group_actions
|
|
3081
3255
|
.filter(action => action.help !== SUPPRESS)
|
|
3082
3256
|
.map(action => _get_action_name(action))
|
|
3083
|
-
|
|
3084
|
-
|
|
3257
|
+
const msg = 'one of the arguments %s is required'
|
|
3258
|
+
throw new ArgumentError(undefined, sub(msg, names.join(' ')))
|
|
3085
3259
|
}
|
|
3086
3260
|
}
|
|
3087
3261
|
}
|
|
3088
3262
|
|
|
3089
3263
|
// return the updated namespace and the extra arguments
|
|
3090
|
-
return [
|
|
3264
|
+
return [namespace, extras]
|
|
3091
3265
|
}
|
|
3092
3266
|
|
|
3093
|
-
_read_args_from_files(arg_strings) {
|
|
3267
|
+
_read_args_from_files (arg_strings) {
|
|
3094
3268
|
// expand arguments referencing files
|
|
3095
3269
|
let new_arg_strings = []
|
|
3096
|
-
for (
|
|
3270
|
+
for (const arg_string of arg_strings) {
|
|
3097
3271
|
|
|
3098
3272
|
// for regular arguments, just add them back into the list
|
|
3099
3273
|
if (!arg_string || !this.fromfile_prefix_chars.includes(arg_string[0])) {
|
|
@@ -3101,19 +3275,20 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3101
3275
|
|
|
3102
3276
|
// replace arguments referencing files with the file content
|
|
3103
3277
|
} else {
|
|
3278
|
+
let args_file
|
|
3104
3279
|
try {
|
|
3105
|
-
|
|
3106
|
-
let arg_strings = []
|
|
3107
|
-
for (let arg_line of splitlines(args_file)) {
|
|
3108
|
-
for (let arg of this.convert_arg_line_to_args(arg_line)) {
|
|
3109
|
-
arg_strings.push(arg)
|
|
3110
|
-
}
|
|
3111
|
-
}
|
|
3112
|
-
arg_strings = this._read_args_from_files(arg_strings)
|
|
3113
|
-
new_arg_strings = new_arg_strings.concat(arg_strings)
|
|
3280
|
+
args_file = fs.readFileSync(arg_string.slice(1), 'utf8')
|
|
3114
3281
|
} catch (err) {
|
|
3115
|
-
|
|
3282
|
+
throw new ArgumentError(undefined, err.message)
|
|
3116
3283
|
}
|
|
3284
|
+
let arg_strings = []
|
|
3285
|
+
for (const arg_line of splitlines(args_file)) {
|
|
3286
|
+
for (const arg of this.convert_arg_line_to_args(arg_line)) {
|
|
3287
|
+
arg_strings.push(arg)
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
arg_strings = this._read_args_from_files(arg_strings)
|
|
3291
|
+
new_arg_strings = new_arg_strings.concat(arg_strings)
|
|
3117
3292
|
}
|
|
3118
3293
|
}
|
|
3119
3294
|
|
|
@@ -3121,18 +3296,18 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3121
3296
|
return new_arg_strings
|
|
3122
3297
|
}
|
|
3123
3298
|
|
|
3124
|
-
convert_arg_line_to_args(arg_line) {
|
|
3299
|
+
convert_arg_line_to_args (arg_line) {
|
|
3125
3300
|
return [arg_line]
|
|
3126
3301
|
}
|
|
3127
3302
|
|
|
3128
|
-
_match_argument(action, arg_strings_pattern) {
|
|
3303
|
+
_match_argument (action, arg_strings_pattern) {
|
|
3129
3304
|
// match the pattern for this action to the arg strings
|
|
3130
|
-
|
|
3131
|
-
|
|
3305
|
+
const nargs_pattern = this._get_nargs_pattern(action)
|
|
3306
|
+
const match = arg_strings_pattern.match(new RegExp('^' + nargs_pattern))
|
|
3132
3307
|
|
|
3133
3308
|
// raise an exception if we weren't able to find a match
|
|
3134
3309
|
if (match === null) {
|
|
3135
|
-
|
|
3310
|
+
const nargs_errors = {
|
|
3136
3311
|
undefined: 'expected one argument',
|
|
3137
3312
|
[OPTIONAL]: 'expected at most one argument',
|
|
3138
3313
|
[ONE_OR_MORE]: 'expected at least one argument'
|
|
@@ -3148,25 +3323,28 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3148
3323
|
return match[1].length
|
|
3149
3324
|
}
|
|
3150
3325
|
|
|
3151
|
-
_match_arguments_partial(actions, arg_strings_pattern) {
|
|
3326
|
+
_match_arguments_partial (actions, arg_strings_pattern) {
|
|
3152
3327
|
// progressively shorten the actions list by slicing off the
|
|
3153
3328
|
// final actions until we find a match
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
let match = arg_strings_pattern.match(new RegExp('^' + pattern))
|
|
3329
|
+
for (const i of range(actions.length, 0, -1)) {
|
|
3330
|
+
const actions_slice = actions.slice(0, i)
|
|
3331
|
+
const pattern = actions_slice.map(action => this._get_nargs_pattern(action)).join('')
|
|
3332
|
+
const match = arg_strings_pattern.match(new RegExp('^' + pattern))
|
|
3159
3333
|
if (match !== null) {
|
|
3160
|
-
result =
|
|
3161
|
-
|
|
3334
|
+
const result = match.slice(1).map(string => string.length)
|
|
3335
|
+
if (match[0].length < arg_strings_pattern.length &&
|
|
3336
|
+
arg_strings_pattern[match[0].length] === 'O') {
|
|
3337
|
+
while (result.length && !result[result.length - 1]) {
|
|
3338
|
+
result.pop()
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
return result
|
|
3162
3342
|
}
|
|
3163
3343
|
}
|
|
3164
|
-
|
|
3165
|
-
// return the list of arg string counts
|
|
3166
|
-
return result
|
|
3344
|
+
return []
|
|
3167
3345
|
}
|
|
3168
3346
|
|
|
3169
|
-
_parse_optional(arg_string) {
|
|
3347
|
+
_parse_optional (arg_string) {
|
|
3170
3348
|
// if it's an empty string, it was meant to be a positional
|
|
3171
3349
|
if (!arg_string) {
|
|
3172
3350
|
return undefined
|
|
@@ -3179,8 +3357,8 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3179
3357
|
|
|
3180
3358
|
// if the option string is present in the parser, return the action
|
|
3181
3359
|
if (arg_string in this._option_string_actions) {
|
|
3182
|
-
|
|
3183
|
-
return [
|
|
3360
|
+
const action = this._option_string_actions[arg_string]
|
|
3361
|
+
return [[action, arg_string, undefined, undefined]]
|
|
3184
3362
|
}
|
|
3185
3363
|
|
|
3186
3364
|
// if it's just a single character, it was meant to be positional
|
|
@@ -3190,29 +3368,20 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3190
3368
|
|
|
3191
3369
|
// if the option string before the "=" is present, return the action
|
|
3192
3370
|
if (arg_string.includes('=')) {
|
|
3193
|
-
|
|
3371
|
+
const [option_string, explicit_arg] = _string_split(arg_string, '=', 1)
|
|
3194
3372
|
if (option_string in this._option_string_actions) {
|
|
3195
|
-
|
|
3196
|
-
return [
|
|
3373
|
+
const action = this._option_string_actions[option_string]
|
|
3374
|
+
return [[action, option_string, '=', explicit_arg]]
|
|
3197
3375
|
}
|
|
3198
3376
|
}
|
|
3199
3377
|
|
|
3200
3378
|
// search through all possible prefixes of the option string
|
|
3201
3379
|
// and all actions in the parser for possible interpretations
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
// if multiple actions match, the option string was ambiguous
|
|
3205
|
-
if (option_tuples.length > 1) {
|
|
3206
|
-
let options = option_tuples.map(([ /*action*/, option_string/*, explicit_arg*/ ]) => option_string).join(', ')
|
|
3207
|
-
let args = {option: arg_string, matches: options}
|
|
3208
|
-
let msg = 'ambiguous option: %(option)s could match %(matches)s'
|
|
3209
|
-
this.error(sub(msg, args))
|
|
3380
|
+
const option_tuples = this._get_option_tuples(arg_string)
|
|
3210
3381
|
|
|
3211
|
-
// if
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
let [ option_tuple ] = option_tuples
|
|
3215
|
-
return option_tuple
|
|
3382
|
+
// if at least one action matched, return the options
|
|
3383
|
+
if (option_tuples.length) {
|
|
3384
|
+
return option_tuples
|
|
3216
3385
|
}
|
|
3217
3386
|
|
|
3218
3387
|
// if it was not found as an option, but it looks like a negative
|
|
@@ -3231,28 +3400,30 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3231
3400
|
|
|
3232
3401
|
// it was meant to be an optional but there is no such option
|
|
3233
3402
|
// in this parser (though it might be a valid option in a subparser)
|
|
3234
|
-
return [
|
|
3403
|
+
return [[undefined, arg_string, undefined, undefined]]
|
|
3235
3404
|
}
|
|
3236
3405
|
|
|
3237
|
-
_get_option_tuples(option_string) {
|
|
3238
|
-
|
|
3406
|
+
_get_option_tuples (option_string) {
|
|
3407
|
+
const result = []
|
|
3239
3408
|
|
|
3240
3409
|
// option strings starting with two prefix characters are only
|
|
3241
3410
|
// split at the '='
|
|
3242
|
-
|
|
3411
|
+
const chars = this.prefix_chars
|
|
3243
3412
|
if (chars.includes(option_string[0]) && chars.includes(option_string[1])) {
|
|
3244
3413
|
if (this.allow_abbrev) {
|
|
3245
|
-
let option_prefix, explicit_arg
|
|
3414
|
+
let option_prefix, sep, explicit_arg
|
|
3246
3415
|
if (option_string.includes('=')) {
|
|
3247
|
-
[
|
|
3416
|
+
[option_prefix, explicit_arg] = _string_split(option_string, '=', 1)
|
|
3417
|
+
sep = '='
|
|
3248
3418
|
} else {
|
|
3249
3419
|
option_prefix = option_string
|
|
3420
|
+
sep = undefined
|
|
3250
3421
|
explicit_arg = undefined
|
|
3251
3422
|
}
|
|
3252
|
-
for (
|
|
3423
|
+
for (const option_string of Object.keys(this._option_string_actions)) {
|
|
3253
3424
|
if (option_string.startsWith(option_prefix)) {
|
|
3254
|
-
|
|
3255
|
-
|
|
3425
|
+
const action = this._option_string_actions[option_string]
|
|
3426
|
+
const tup = [action, option_string, sep, explicit_arg]
|
|
3256
3427
|
result.push(tup)
|
|
3257
3428
|
}
|
|
3258
3429
|
}
|
|
@@ -3262,75 +3433,78 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3262
3433
|
// but multiple character options always have to have their argument
|
|
3263
3434
|
// separate
|
|
3264
3435
|
} else if (chars.includes(option_string[0]) && !chars.includes(option_string[1])) {
|
|
3265
|
-
let option_prefix
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3436
|
+
let option_prefix, sep, explicit_arg
|
|
3437
|
+
if (option_string.includes('=')) {
|
|
3438
|
+
[option_prefix, explicit_arg] = _string_split(option_string, '=', 1)
|
|
3439
|
+
sep = '='
|
|
3440
|
+
} else {
|
|
3441
|
+
option_prefix = option_string
|
|
3442
|
+
sep = explicit_arg = undefined
|
|
3443
|
+
}
|
|
3444
|
+
const short_option_prefix = option_string.slice(0, 2)
|
|
3445
|
+
const short_explicit_arg = option_string.slice(2)
|
|
3269
3446
|
|
|
3270
|
-
for (
|
|
3447
|
+
for (const option_string of Object.keys(this._option_string_actions)) {
|
|
3271
3448
|
if (option_string === short_option_prefix) {
|
|
3272
|
-
|
|
3273
|
-
|
|
3449
|
+
const action = this._option_string_actions[option_string]
|
|
3450
|
+
const tup = [action, option_string, '', short_explicit_arg]
|
|
3274
3451
|
result.push(tup)
|
|
3275
|
-
} else if (option_string.startsWith(option_prefix)) {
|
|
3276
|
-
|
|
3277
|
-
|
|
3452
|
+
} else if (this.allow_abbrev && option_string.startsWith(option_prefix)) {
|
|
3453
|
+
const action = this._option_string_actions[option_string]
|
|
3454
|
+
const tup = [action, option_string, sep, explicit_arg]
|
|
3278
3455
|
result.push(tup)
|
|
3279
3456
|
}
|
|
3280
3457
|
}
|
|
3281
3458
|
|
|
3282
3459
|
// shouldn't ever get here
|
|
3283
3460
|
} else {
|
|
3284
|
-
|
|
3461
|
+
throw new ArgumentError(undefined, sub('unexpected option string: %s', option_string))
|
|
3285
3462
|
}
|
|
3286
3463
|
|
|
3287
3464
|
// return the collected option tuples
|
|
3288
3465
|
return result
|
|
3289
3466
|
}
|
|
3290
3467
|
|
|
3291
|
-
_get_nargs_pattern(action) {
|
|
3468
|
+
_get_nargs_pattern (action) {
|
|
3292
3469
|
// in all examples below, we have to allow for '--' args
|
|
3293
3470
|
// which are represented as '-' in the pattern
|
|
3294
|
-
|
|
3471
|
+
const nargs = action.nargs
|
|
3472
|
+
const option = action.option_strings.length
|
|
3295
3473
|
let nargs_pattern
|
|
3296
3474
|
|
|
3297
3475
|
// the default (None) is assumed to be a single argument
|
|
3298
3476
|
if (nargs === undefined) {
|
|
3299
|
-
nargs_pattern = '(-*A-*)'
|
|
3477
|
+
nargs_pattern = option ? '([A])' : '(-*A-*)'
|
|
3300
3478
|
|
|
3301
3479
|
// allow zero or one arguments
|
|
3302
3480
|
} else if (nargs === OPTIONAL) {
|
|
3303
|
-
nargs_pattern = '(-*A?-*)'
|
|
3481
|
+
nargs_pattern = option ? '(A?)' : '(-*A?-*)'
|
|
3304
3482
|
|
|
3305
3483
|
// allow zero or more arguments
|
|
3306
3484
|
} else if (nargs === ZERO_OR_MORE) {
|
|
3307
|
-
nargs_pattern = '(-*[A-]*)'
|
|
3485
|
+
nargs_pattern = option ? '(A*)' : '(-*[A-]*)'
|
|
3308
3486
|
|
|
3309
3487
|
// allow one or more arguments
|
|
3310
3488
|
} else if (nargs === ONE_OR_MORE) {
|
|
3311
|
-
nargs_pattern = '(-*A[A-]*)'
|
|
3489
|
+
nargs_pattern = option ? '(A+)' : '(-*A[A-]*)'
|
|
3312
3490
|
|
|
3313
3491
|
// allow any number of options or arguments
|
|
3314
3492
|
} else if (nargs === REMAINDER) {
|
|
3315
|
-
nargs_pattern = '([
|
|
3493
|
+
nargs_pattern = option ? '([AO]*)' : '(.*)'
|
|
3316
3494
|
|
|
3317
3495
|
// allow one argument followed by any number of options or arguments
|
|
3318
3496
|
} else if (nargs === PARSER) {
|
|
3319
|
-
nargs_pattern = '(-*A[-AO]*)'
|
|
3497
|
+
nargs_pattern = option ? '(A[AO]*)' : '(-*A[-AO]*)'
|
|
3320
3498
|
|
|
3321
3499
|
// suppress action, like nargs=0
|
|
3322
3500
|
} else if (nargs === SUPPRESS) {
|
|
3323
|
-
nargs_pattern = '(
|
|
3501
|
+
nargs_pattern = option ? '()' : '(-*)'
|
|
3324
3502
|
|
|
3325
3503
|
// all others should be integers
|
|
3326
3504
|
} else {
|
|
3327
|
-
nargs_pattern =
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
// if this is an optional action, -- is not allowed
|
|
3331
|
-
if (action.option_strings.length) {
|
|
3332
|
-
nargs_pattern = nargs_pattern.replace(/-\*/g, '')
|
|
3333
|
-
nargs_pattern = nargs_pattern.replace(/-/g, '')
|
|
3505
|
+
nargs_pattern = option
|
|
3506
|
+
? sub('([AO]{%s})', nargs)
|
|
3507
|
+
: sub('((?:-*A){%s}-*)', nargs)
|
|
3334
3508
|
}
|
|
3335
3509
|
|
|
3336
3510
|
// return the pattern
|
|
@@ -3341,17 +3515,21 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3341
3515
|
// Alt command line argument parsing, allowing free intermix
|
|
3342
3516
|
// ========================
|
|
3343
3517
|
|
|
3344
|
-
parse_intermixed_args(args = undefined, namespace = undefined) {
|
|
3518
|
+
parse_intermixed_args (args = undefined, namespace = undefined) {
|
|
3345
3519
|
let argv
|
|
3346
|
-
[
|
|
3520
|
+
[args, argv] = this.parse_known_intermixed_args(args, namespace)
|
|
3347
3521
|
if (argv.length) {
|
|
3348
|
-
|
|
3349
|
-
this.
|
|
3522
|
+
const msg = sub('unrecognized arguments: %s', argv.join(' '))
|
|
3523
|
+
if (this.exit_on_error) {
|
|
3524
|
+
this.error(msg)
|
|
3525
|
+
} else {
|
|
3526
|
+
throw new ArgumentError(undefined, msg)
|
|
3527
|
+
}
|
|
3350
3528
|
}
|
|
3351
3529
|
return args
|
|
3352
3530
|
}
|
|
3353
3531
|
|
|
3354
|
-
parse_known_intermixed_args(args = undefined, namespace = undefined) {
|
|
3532
|
+
parse_known_intermixed_args (args = undefined, namespace = undefined) {
|
|
3355
3533
|
// returns a namespace and list of extras
|
|
3356
3534
|
//
|
|
3357
3535
|
// positional can be freely intermixed with optionals. optionals are
|
|
@@ -3359,103 +3537,21 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3359
3537
|
// are then parsed. If the parser definition is incompatible with the
|
|
3360
3538
|
// intermixed assumptions (e.g. use of REMAINDER, subparsers) a
|
|
3361
3539
|
// TypeError is raised.
|
|
3362
|
-
//
|
|
3363
|
-
// positionals are 'deactivated' by setting nargs and default to
|
|
3364
|
-
// SUPPRESS. This blocks the addition of that positional to the
|
|
3365
|
-
// namespace
|
|
3366
3540
|
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
let a = positionals.filter(action => [ PARSER, REMAINDER ].includes(action.nargs))
|
|
3541
|
+
const positionals = this._get_positional_actions()
|
|
3542
|
+
const a = positionals.filter(action => [PARSER, REMAINDER].includes(action.nargs))
|
|
3370
3543
|
if (a.length) {
|
|
3371
3544
|
throw new TypeError(sub('parse_intermixed_args: positional arg' +
|
|
3372
3545
|
' with nargs=%s', a[0].nargs))
|
|
3373
3546
|
}
|
|
3374
3547
|
|
|
3375
|
-
|
|
3376
|
-
for (let action of group._group_actions) {
|
|
3377
|
-
if (positionals.includes(action)) {
|
|
3378
|
-
throw new TypeError('parse_intermixed_args: positional in' +
|
|
3379
|
-
' mutuallyExclusiveGroup')
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
|
|
3384
|
-
let save_usage
|
|
3385
|
-
try {
|
|
3386
|
-
save_usage = this.usage
|
|
3387
|
-
let remaining_args
|
|
3388
|
-
try {
|
|
3389
|
-
if (this.usage === undefined) {
|
|
3390
|
-
// capture the full usage for use in error messages
|
|
3391
|
-
this.usage = this.format_usage().slice(7)
|
|
3392
|
-
}
|
|
3393
|
-
for (let action of positionals) {
|
|
3394
|
-
// deactivate positionals
|
|
3395
|
-
action.save_nargs = action.nargs
|
|
3396
|
-
// action.nargs = 0
|
|
3397
|
-
action.nargs = SUPPRESS
|
|
3398
|
-
action.save_default = action.default
|
|
3399
|
-
action.default = SUPPRESS
|
|
3400
|
-
}
|
|
3401
|
-
[ namespace, remaining_args ] = this.parse_known_args(args,
|
|
3402
|
-
namespace)
|
|
3403
|
-
for (let action of positionals) {
|
|
3404
|
-
// remove the empty positional values from namespace
|
|
3405
|
-
let attr = getattr(namespace, action.dest)
|
|
3406
|
-
if (Array.isArray(attr) && attr.length === 0) {
|
|
3407
|
-
// eslint-disable-next-line no-console
|
|
3408
|
-
console.warn(sub('Do not expect %s in %s', action.dest, namespace))
|
|
3409
|
-
delattr(namespace, action.dest)
|
|
3410
|
-
}
|
|
3411
|
-
}
|
|
3412
|
-
} finally {
|
|
3413
|
-
// restore nargs and usage before exiting
|
|
3414
|
-
for (let action of positionals) {
|
|
3415
|
-
action.nargs = action.save_nargs
|
|
3416
|
-
action.default = action.save_default
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
let optionals = this._get_optional_actions()
|
|
3420
|
-
try {
|
|
3421
|
-
// parse positionals. optionals aren't normally required, but
|
|
3422
|
-
// they could be, so make sure they aren't.
|
|
3423
|
-
for (let action of optionals) {
|
|
3424
|
-
action.save_required = action.required
|
|
3425
|
-
action.required = false
|
|
3426
|
-
}
|
|
3427
|
-
for (let group of this._mutually_exclusive_groups) {
|
|
3428
|
-
group.save_required = group.required
|
|
3429
|
-
group.required = false
|
|
3430
|
-
}
|
|
3431
|
-
[ namespace, extras ] = this.parse_known_args(remaining_args,
|
|
3432
|
-
namespace)
|
|
3433
|
-
} finally {
|
|
3434
|
-
// restore parser values before exiting
|
|
3435
|
-
for (let action of optionals) {
|
|
3436
|
-
action.required = action.save_required
|
|
3437
|
-
}
|
|
3438
|
-
for (let group of this._mutually_exclusive_groups) {
|
|
3439
|
-
group.required = group.save_required
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
} finally {
|
|
3443
|
-
this.usage = save_usage
|
|
3444
|
-
}
|
|
3445
|
-
return [ namespace, extras ]
|
|
3548
|
+
return this._parse_known_args2(args, namespace, true)
|
|
3446
3549
|
}
|
|
3447
3550
|
|
|
3448
3551
|
// ========================
|
|
3449
3552
|
// Value conversion methods
|
|
3450
3553
|
// ========================
|
|
3451
|
-
_get_values(action, arg_strings) {
|
|
3452
|
-
// for everything but PARSER, REMAINDER args, strip out first '--'
|
|
3453
|
-
if (![PARSER, REMAINDER].includes(action.nargs)) {
|
|
3454
|
-
try {
|
|
3455
|
-
_array_remove(arg_strings, '--')
|
|
3456
|
-
} catch (err) {}
|
|
3457
|
-
}
|
|
3458
|
-
|
|
3554
|
+
_get_values (action, arg_strings) {
|
|
3459
3555
|
let value
|
|
3460
3556
|
// optional argument produces a default when not present
|
|
3461
3557
|
if (!arg_strings.length && action.nargs === OPTIONAL) {
|
|
@@ -3464,9 +3560,8 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3464
3560
|
} else {
|
|
3465
3561
|
value = action.default
|
|
3466
3562
|
}
|
|
3467
|
-
if (typeof value === 'string') {
|
|
3563
|
+
if (typeof value === 'string' && value !== SUPPRESS) {
|
|
3468
3564
|
value = this._get_value(action, value)
|
|
3469
|
-
this._check_value(action, value)
|
|
3470
3565
|
}
|
|
3471
3566
|
|
|
3472
3567
|
// when nargs='*' on a positional, if there were no command-line
|
|
@@ -3476,13 +3571,12 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3476
3571
|
if (action.default !== undefined) {
|
|
3477
3572
|
value = action.default
|
|
3478
3573
|
} else {
|
|
3479
|
-
value =
|
|
3574
|
+
value = []
|
|
3480
3575
|
}
|
|
3481
|
-
this._check_value(action, value)
|
|
3482
3576
|
|
|
3483
3577
|
// single argument or optional argument produces a single value
|
|
3484
3578
|
} else if (arg_strings.length === 1 && [undefined, OPTIONAL].includes(action.nargs)) {
|
|
3485
|
-
|
|
3579
|
+
const arg_string = arg_strings[0]
|
|
3486
3580
|
value = this._get_value(action, arg_string)
|
|
3487
3581
|
this._check_value(action, value)
|
|
3488
3582
|
|
|
@@ -3502,7 +3596,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3502
3596
|
// all other types of nargs produce a list
|
|
3503
3597
|
} else {
|
|
3504
3598
|
value = arg_strings.map(v => this._get_value(action, v))
|
|
3505
|
-
for (
|
|
3599
|
+
for (const v of value) {
|
|
3506
3600
|
this._check_value(action, v)
|
|
3507
3601
|
}
|
|
3508
3602
|
}
|
|
@@ -3511,11 +3605,10 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3511
3605
|
return value
|
|
3512
3606
|
}
|
|
3513
3607
|
|
|
3514
|
-
_get_value(action, arg_string) {
|
|
3515
|
-
|
|
3608
|
+
_get_value (action, arg_string) {
|
|
3609
|
+
const type_func = this._registry_get('type', action.type, action.type)
|
|
3516
3610
|
if (typeof type_func !== 'function') {
|
|
3517
|
-
|
|
3518
|
-
throw new ArgumentError(action, sub(msg, type_func))
|
|
3611
|
+
throw new TypeError(sub('%r is not callable', type_func))
|
|
3519
3612
|
}
|
|
3520
3613
|
|
|
3521
3614
|
// convert the value to the appropriate type
|
|
@@ -3539,15 +3632,14 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3539
3632
|
} catch (err) {
|
|
3540
3633
|
// ArgumentTypeErrors indicate errors
|
|
3541
3634
|
if (err instanceof ArgumentTypeError) {
|
|
3542
|
-
|
|
3543
|
-
let msg = err.message
|
|
3635
|
+
const msg = err.message
|
|
3544
3636
|
throw new ArgumentError(action, msg)
|
|
3545
3637
|
|
|
3546
3638
|
// TypeErrors or ValueErrors also indicate errors
|
|
3547
3639
|
} else if (err instanceof TypeError) {
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3640
|
+
const name = getattr(action.type, 'name', repr(action.type))
|
|
3641
|
+
const args = {type: name, value: arg_string}
|
|
3642
|
+
const msg = 'invalid %(type)s value: %(value)r'
|
|
3551
3643
|
throw new ArgumentError(action, sub(msg, args))
|
|
3552
3644
|
} else {
|
|
3553
3645
|
throw err
|
|
@@ -3558,28 +3650,44 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3558
3650
|
return result
|
|
3559
3651
|
}
|
|
3560
3652
|
|
|
3561
|
-
_check_value(action, value) {
|
|
3653
|
+
_check_value (action, value) {
|
|
3562
3654
|
// converted value must be one of the choices (if specified)
|
|
3563
|
-
if (action.choices
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3655
|
+
if (action.choices === undefined) return
|
|
3656
|
+
|
|
3657
|
+
const choices = _choices_to_array(action.choices)
|
|
3658
|
+
if (choices.includes(value)) return
|
|
3659
|
+
|
|
3660
|
+
const args = {value: String(value),
|
|
3661
|
+
choices: choices.map(choice => repr(String(choice))).join(', ')}
|
|
3662
|
+
let msg = 'invalid choice: %(value)r (choose from %(choices)s)'
|
|
3663
|
+
|
|
3664
|
+
if (this.suggest_on_error && typeof value === 'string') {
|
|
3665
|
+
if (choices.every(choice => typeof choice === 'string')) {
|
|
3666
|
+
const { get_close_matches } = require('./difflib')
|
|
3667
|
+
const suggestions = get_close_matches(value, choices, 1)
|
|
3668
|
+
if (suggestions.length) {
|
|
3669
|
+
args.closest = suggestions[0]
|
|
3670
|
+
msg = 'invalid choice: %(value)r, maybe you meant %(closest)r? ' +
|
|
3671
|
+
'(choose from %(choices)s)'
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3568
3674
|
}
|
|
3675
|
+
|
|
3676
|
+
throw new ArgumentError(action, sub(msg, args))
|
|
3569
3677
|
}
|
|
3570
3678
|
|
|
3571
3679
|
// =======================
|
|
3572
3680
|
// Help-formatting methods
|
|
3573
3681
|
// =======================
|
|
3574
|
-
format_usage() {
|
|
3575
|
-
|
|
3682
|
+
format_usage () {
|
|
3683
|
+
const formatter = this._get_formatter()
|
|
3576
3684
|
formatter.add_usage(this.usage, this._actions,
|
|
3577
3685
|
this._mutually_exclusive_groups)
|
|
3578
3686
|
return formatter.format_help()
|
|
3579
3687
|
}
|
|
3580
3688
|
|
|
3581
|
-
format_help() {
|
|
3582
|
-
|
|
3689
|
+
format_help () {
|
|
3690
|
+
const formatter = this._get_formatter()
|
|
3583
3691
|
|
|
3584
3692
|
// usage
|
|
3585
3693
|
formatter.add_usage(this.usage, this._actions,
|
|
@@ -3589,7 +3697,7 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3589
3697
|
formatter.add_text(this.description)
|
|
3590
3698
|
|
|
3591
3699
|
// positionals, optionals and user-defined groups
|
|
3592
|
-
for (
|
|
3700
|
+
for (const action_group of this._action_groups) {
|
|
3593
3701
|
formatter.start_section(action_group.title)
|
|
3594
3702
|
formatter.add_text(action_group.description)
|
|
3595
3703
|
formatter.add_arguments(action_group._group_actions)
|
|
@@ -3603,42 +3711,55 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3603
3711
|
return formatter.format_help()
|
|
3604
3712
|
}
|
|
3605
3713
|
|
|
3606
|
-
_get_formatter() {
|
|
3714
|
+
_get_formatter () {
|
|
3607
3715
|
// eslint-disable-next-line new-cap
|
|
3608
|
-
|
|
3716
|
+
const formatter = new this.formatter_class({ prog: this.prog })
|
|
3717
|
+
formatter._set_color(this.color)
|
|
3718
|
+
return formatter
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
_get_validation_formatter () {
|
|
3722
|
+
// Return cached formatter for read-only validation operations
|
|
3723
|
+
// (_expand_help and _format_args). Avoids repeated slow _set_color calls.
|
|
3724
|
+
if (this._cached_formatter === undefined) {
|
|
3725
|
+
this._cached_formatter = this._get_formatter()
|
|
3726
|
+
}
|
|
3727
|
+
return this._cached_formatter
|
|
3609
3728
|
}
|
|
3610
3729
|
|
|
3611
3730
|
// =====================
|
|
3612
3731
|
// Help-printing methods
|
|
3613
3732
|
// =====================
|
|
3614
|
-
print_usage(file = undefined) {
|
|
3733
|
+
print_usage (file = undefined) {
|
|
3615
3734
|
if (file === undefined) file = process.stdout
|
|
3616
3735
|
this._print_message(this.format_usage(), file)
|
|
3617
3736
|
}
|
|
3618
3737
|
|
|
3619
|
-
print_help(file = undefined) {
|
|
3738
|
+
print_help (file = undefined) {
|
|
3620
3739
|
if (file === undefined) file = process.stdout
|
|
3621
3740
|
this._print_message(this.format_help(), file)
|
|
3622
3741
|
}
|
|
3623
3742
|
|
|
3624
|
-
_print_message(message, file = undefined) {
|
|
3743
|
+
_print_message (message, file = undefined) {
|
|
3625
3744
|
if (message) {
|
|
3626
|
-
|
|
3627
|
-
file.write
|
|
3745
|
+
file = file || process.stderr
|
|
3746
|
+
if (file && typeof file.write === 'function') {
|
|
3747
|
+
file.write(message)
|
|
3748
|
+
}
|
|
3628
3749
|
}
|
|
3629
3750
|
}
|
|
3630
3751
|
|
|
3631
3752
|
// ===============
|
|
3632
3753
|
// Exiting methods
|
|
3633
3754
|
// ===============
|
|
3634
|
-
exit(status = 0, message = undefined) {
|
|
3755
|
+
exit (status = 0, message = undefined) {
|
|
3635
3756
|
if (message) {
|
|
3636
3757
|
this._print_message(message, process.stderr)
|
|
3637
3758
|
}
|
|
3638
3759
|
process.exit(status)
|
|
3639
3760
|
}
|
|
3640
3761
|
|
|
3641
|
-
error(message) {
|
|
3762
|
+
error (message) {
|
|
3642
3763
|
/*
|
|
3643
3764
|
* error(message: string)
|
|
3644
3765
|
*
|
|
@@ -3649,14 +3770,16 @@ const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _
|
|
|
3649
3770
|
* should either exit or raise an exception.
|
|
3650
3771
|
*/
|
|
3651
3772
|
|
|
3652
|
-
// LEGACY (v1 compatibility), debug mode
|
|
3653
|
-
if (this.debug === true) throw new Error(message)
|
|
3654
|
-
// end
|
|
3655
3773
|
this.print_usage(process.stderr)
|
|
3656
|
-
|
|
3774
|
+
const args = {prog: this.prog, message}
|
|
3657
3775
|
this.exit(2, sub('%(prog)s: error: %(message)s\n', args))
|
|
3658
3776
|
}
|
|
3659
|
-
|
|
3777
|
+
|
|
3778
|
+
_warning (message) {
|
|
3779
|
+
const args = { prog: this.prog, message }
|
|
3780
|
+
this._print_message(sub('%(prog)s: warning: %(message)s\n', args), process.stderr)
|
|
3781
|
+
}
|
|
3782
|
+
})
|
|
3660
3783
|
|
|
3661
3784
|
|
|
3662
3785
|
module.exports = {
|
|
@@ -3679,29 +3802,3 @@ module.exports = {
|
|
|
3679
3802
|
SUPPRESS,
|
|
3680
3803
|
ZERO_OR_MORE
|
|
3681
3804
|
}
|
|
3682
|
-
|
|
3683
|
-
// LEGACY (v1 compatibility), Const alias
|
|
3684
|
-
Object.defineProperty(module.exports, 'Const', {
|
|
3685
|
-
get() {
|
|
3686
|
-
let result = {}
|
|
3687
|
-
Object.entries({ ONE_OR_MORE, OPTIONAL, PARSER, REMAINDER, SUPPRESS, ZERO_OR_MORE }).forEach(([ n, v ]) => {
|
|
3688
|
-
Object.defineProperty(result, n, {
|
|
3689
|
-
get() {
|
|
3690
|
-
deprecate(n, sub('use argparse.%s instead of argparse.Const.%s', n, n))
|
|
3691
|
-
return v
|
|
3692
|
-
}
|
|
3693
|
-
})
|
|
3694
|
-
})
|
|
3695
|
-
Object.entries({ _UNRECOGNIZED_ARGS_ATTR }).forEach(([ n, v ]) => {
|
|
3696
|
-
Object.defineProperty(result, n, {
|
|
3697
|
-
get() {
|
|
3698
|
-
deprecate(n, sub('argparse.Const.%s is an internal symbol and will no longer be available', n))
|
|
3699
|
-
return v
|
|
3700
|
-
}
|
|
3701
|
-
})
|
|
3702
|
-
})
|
|
3703
|
-
return result
|
|
3704
|
-
},
|
|
3705
|
-
enumerable: false
|
|
3706
|
-
})
|
|
3707
|
-
// end
|