6.15.94 • Published 12 months ago

@hishprorg/et-dicta-cum v6.15.94

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@hishprorg/et-dicta-cum

NPM version Build Status Discord Try it on gitpod

Basic argument parsing library using yargs-parser with built-in help screen

Installation

npm install @hishprorg/et-dicta-cum

Usage

See index.d.ts for API

CommonJS import

const args = require('@hishprorg/et-dicta-cum')({
  name: '@hishprorg/et-dicta-cum-example',
  version: '1.0.0',
  description: 'A basic example of @hishprorg/et-dicta-cum',
  errorOnUnknown: true,
  options: {
    version: { type: String, description: 'Version to connect as', alias: 'v' },
    port: { type: Number, description: 'Port to listen on', default: 25565 },
    online: { type: Boolean, description: 'Whether to run in online mode' },
    path: { type: String, description: 'Path to the server directory', default: '.' }
  }
})

console.log(args)

After being ran with node index.js --version 1.16 (or using -v 1.16 alias) we would get:

{ version: '1.16.1', port: 25565, online: false, path: '.' }

Please note Boolean options do not need arguments, simply passing them as an argument will resolve them to be true. If you want to force an argument, set type to a String to handle yourself.

Extraneous arguments (when not using errorOnExtra) are stored in the _ index of the output. The nested _ contains positionals.

Help screen

If we run with --help or get a argument error, we see the help screen:

> node example.js --help   
@hishprorg/et-dicta-cum-example - v1.0.0
A basic example of @hishprorg/et-dicta-cum

Options:
  --version     Version to connect as
  --port        Port to listen on  (default: 25565)
  --online      Whether to run in online mode
  --path        Path to the server directory  (default: .)

Custom args

The second argument is the custom arg array if any, if it's not set, we default to process.argv.

require('@hishprorg/et-dicta-cum')(options, process.argv)

ES6 import

import basicArg from '@hishprorg/et-dicta-cum'
const args = basicArg({
  name: '@hishprorg/et-dicta-cum-example',
  version: '1.0.0',
  description: 'A basic example of @hishprorg/et-dicta-cum',
  throwOnError: false, // Throw an error instead of calling process.exit() with help screen (default: false)
  helpCommand: 'help', // The -- command for opening the built-in help screen (default: help)
  options: {
    version: { type: String, description: 'Version to connect as', alias: 'v' },
    port: { type: Number, description: 'Port to listen on', default: 25565 },
    online: { type: Boolean, description: 'Whether to run in online mode' },
    path: { type: String, description: 'Path to the server directory', default: '.' }
  },
  // validate (args) { return true } /* optional fn to verify the args before returning them; non-true return value will print help screen */
})
// ...

Testing

npm test

History

See history

SymbolaccessorPushkarmanegativesymlinksfunctionalfulltaskgroupjestStyleSheetescapees5negative zero-0Function.prototype.nameloghigher-orderinternalbufferECMAScript 2019columnsTypeBoxvpcJSON-SchemasnsidjsonpathES6dragECMAScript 2021sliceObject.getPrototypeOfequali18ncmdutilawesomesaucebuffersargsfastclonesetImmediateelectronstdlibbyteLengthhardlinksfindLastpropertysideoutputbyteiteratekeywritablepnpm9hashchromiumcomputed-typescommanderownconsume256safepruneArray.prototype.includesArray.prototype.containsjsonutilitiestoSortedguidloadingcall-boundinvariantcolordefineparsingcloudfrontdataviews3nodecopytypeofapiidentifiersterminalcsssequenceinstallUint8ClampedArrayastshamscheme-validationES2022.envtypanioneslintcloudsearchdayjspositivees2015sortArray.prototype.flattesterInt16ArrayBigInt64ArrayBigUint64Arrayargvbusygenericswebsitefolderxtermreact posekinesisinspectlruenvECMAScript 6mobilestructuredClonehttpsargumentmkdirp__proto__specmonorepoObject.entriesES2018hasOwninternal slotzeroshebangcharactersstylesimportspeedquoteWeakSetiamexeansiimmutablepackage managergraphqlpatchdirectorycontainsfpsgdprpopmotionmkdirRxstoragegatewaypyyamlUint8ArrayttyzodwhichObject.assignUnderscoreES2017schemetc39ajvprivate dataconcatlanguagediffgroupByinferenceweakmaplimitprotobufelasticacherouteappglobrequirepackage.jsonmake direqualitytrimStartreact-hooksstringconcatMapcodesObject.definePropertysortedObject.keyswarningvaluessqseventsthrottlecurlpolyfilloptimizereveryconsoleefficientstreamsassertionenumerablewriteregular expressionESoptionfastcopyeslookserializervisualtoolkititerationcolourtoobjecttakecollectionrmdirprotodescriptordotenvworkflow@@toStringTagfetchxdgvalidationthreepushloadbalancingebsdom-testing-librarystyled-componentshasOwnPropertyvalueassignlastfull-widthopenspathajaxES3MicrosoftObject.fromEntriespropertiesmodulecheckcoercibledefinePropertystableflattenchildasciimakelintES2016flagmrubindqueueMicrotaskoptimistindicatoruuidgesturesObservablesString.prototype.matchAlltapboundelbapollominimalfastcommand-lineES2015walkconfigchannelECMAScript 2017WebSocketrangeerrorworkspace:*serializationwrapcallboundArray.prototype.filterjsdomsuperagentprocesses2016jasmineECMAScript 3openerdependenciesdataViewmimeredactairbnbTypedArraylogger_.extendCSSStyleDeclarationanimationclonedebugurlglobalssloteslintconfigObject.isplugindroptyped arrayhookformmetadataWebSocketsisConcatSpreadabletoArrayshrinkwrappromisewebjshintdefaultES8Objectes7urlsfast-cloneIteratorremovedeep-clonetelephonesimpledbglaciercryptobyteOffsetfilterlibphonenumberparentsmapfullwidthPromiseserializeunicodebundlerrm -rfcode pointses2018Int32ArrayECMAScript 5waitexecutablelocationeventDispatcherinputdeterministicformtostringtagperformantdirincludesfind-upcharsetpicomatchyamlbreakcompilerspringparseravaroutingeventEmitterautoprefixeropenReactiveXsyntaxerrorsymlinkes8flagsparentsymbolsrapidhttpSetasyncassertnodejsemitdeep-copyspawnintrinsiccss-in-jsfastifyregexReflect.getPrototypeOfcallbindcharacterECMAScript 2022stringifierUint32Arraypackagepackagesfsrm -frparsevalidateiteratoricuArrayBuffer.prototype.slicetimemapreducewgetautoscalinguninstallfile systemrecursivematchjsxprefixES2021lockfilefinduplazyTypeScriptio-tssettestdatereadablelengthpostcss-pluginutilitylinewrapduplexflatECMAScript 2020Array.prototype.flatMapclientstyleCSSrobustcjksharedarraybufferqserrorfromchromevestmimetypesdeeprmvariablesfunction.lengthreduceArray.prototype.flattenrdsec2querystringprogressestreeamazonwordbreakmodulescallbddposereadregexpes-shim APIURLkoreanpersistentsearchdescriptorsESnexthas-ownRxJSgetterdeepcopyInt8Arraysharedcore-jsfunctionredux-toolkitbrowserslistextratoolsexpresscloudtrailproxybeanstalkFloat64ArraysetterrgbquerymochamatchAllglobaltrimLeftECMAScript 2023getintrinsictextstreams2stringifyl10ninstallertermstartregularArrayArray.prototype.findLastIndexprotocol-buffersawsdebuggerwalkingdescriptionwafgetcollection.es6weaksetimportexportUint16ArraytestingjQueryclass-validatornamesfileconverthookscensorarraysarrayonceeast-asian-widthObject.valuesfixed-width
3.4.47

1 year ago

3.2.24

1 year ago

3.4.48

1 year ago

3.2.23

1 year ago

3.4.49

1 year ago

3.2.26

1 year ago

3.2.25

1 year ago

4.10.83

1 year ago

3.2.28

1 year ago

3.2.27

1 year ago

3.2.29

1 year ago

3.4.40

1 year ago

3.4.41

1 year ago

3.4.42

1 year ago

3.4.43

1 year ago

3.4.44

1 year ago

3.4.45

1 year ago

3.2.22

1 year ago

3.4.46

1 year ago

3.2.21

1 year ago

6.12.84

12 months ago

3.4.50

1 year ago

3.4.51

1 year ago

3.4.52

1 year ago

3.2.31

1 year ago

3.2.30

1 year ago

3.2.33

1 year ago

6.14.90

12 months ago

3.2.32

1 year ago

3.6.72

1 year ago

5.10.83

1 year ago

5.10.84

1 year ago

6.15.94

12 months ago

6.15.93

12 months ago

6.15.90

12 months ago

6.15.92

12 months ago

6.15.91

12 months ago

3.5.72

1 year ago

3.5.71

1 year ago

3.5.70

1 year ago

3.4.39

1 year ago

4.8.78

1 year ago

4.8.77

1 year ago

4.8.79

1 year ago

3.5.58

1 year ago

3.3.35

1 year ago

3.5.57

1 year ago

3.3.36

1 year ago

3.5.56

1 year ago

3.3.37

1 year ago

3.5.55

1 year ago

3.3.38

1 year ago

3.5.54

1 year ago

3.3.39

1 year ago

3.5.53

1 year ago

3.5.52

1 year ago

3.3.33

1 year ago

3.5.59

1 year ago

3.3.34

1 year ago

4.9.79

1 year ago

2.2.17

1 year ago

2.2.18

1 year ago

2.2.15

1 year ago

2.2.16

1 year ago

2.2.13

1 year ago

2.2.14

1 year ago

5.11.84

1 year ago

3.5.69

1 year ago

3.5.68

1 year ago

3.5.67

1 year ago

3.5.66

1 year ago

3.5.65

1 year ago

3.5.64

1 year ago

3.5.63

1 year ago

3.5.62

1 year ago

4.6.73

1 year ago

2.2.19

1 year ago

4.6.72

1 year ago

6.13.86

12 months ago

6.13.84

12 months ago

6.13.85

12 months ago

3.5.61

1 year ago

2.2.20

1 year ago

3.5.60

1 year ago

2.2.21

1 year ago

4.7.74

1 year ago

4.7.75

1 year ago

4.7.73

1 year ago

6.14.89

12 months ago

4.7.76

1 year ago

4.7.77

1 year ago

6.14.86

12 months ago

6.14.88

12 months ago

6.14.87

12 months ago

4.9.80

1 year ago

4.9.82

1 year ago

4.9.81

1 year ago

4.9.83

1 year ago

5.12.84

12 months ago

2.2.12

1 year ago

2.2.9

1 year ago

2.2.8

1 year ago

2.2.11

1 year ago

2.2.10

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.5

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago