2.9.115 • Published 11 months ago

@devtea2026/in-doloribus-neque-omnis v2.9.115

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

Ask

Wrapper of yargs and enquirer libs to ask user for input.

Install

npm i @devtea2026/in-doloribus-neque-omnis

Usage

Command line arguments

Create command line arguments. Each command line argument can be passed through the command line, environment variables and .env file. If the argument is missing and required, the user is prompted for it. Arguments are required by default. The options --help and --version are created automatically.

Pass an object describing each command line argument, the returned promise is an object of the same shape with the values extracted.

import { askArgv } from "@devtea2026/in-doloribus-neque-omnis";

const { password } = await askArgv({
  password: {
    type: "password",
  },
});

Passing value using the command line.

node src/test.js --password xxx
# no prompt

Passing value using environment variable.

PASSWORD=xxx node src/test.js
# no prompt

Passing value using the .env file.

echo PASSWORD=xxx > .env
node src/test.js
# no prompt

Prompt the user for the missing value.

node src/test.js
# prompt for password

For each command line argument you can also specify:

  • yargsOverrides Override yargs lib configuration.
  • enquirerOverrides Override enquirer lib configuration.
  • defaultValue Default value.
  • options Possible options for strings and array types.
  • required If the value is required or not.

Positional arguments

import { askArgv } from "@devtea2026/in-doloribus-neque-omnis";

const { username, password } = await askArgv({
  username: { type: "string", position: 0 },
  password: { type: "password", position: 1 },
});
node src/test.js john xxx

.env location.

You can also pass the location of the .env file as the second parameter.

import { askArgv } from "@devtea2026/in-doloribus-neque-omnis";

const { username } = await askArgv({ username: { type: "string" } }, { dotEnvConfig: ".dev.env" });
echo USERNAME=john > .dev.env
node src/test.js

User input

You can prompt the user in the middle of your program without defining new command line arguments.

import { ask } from "@devtea2026/in-doloribus-neque-omnis";

const password = await ask({ name: "password", type: "password" });

Environment variables only

You can use askEnv to get values from environment variables alone. An error will be thrown if the environment variable is required, missing and there is no default value for it. You can pass dotEnvConfig as a field of the object of the second argument. The value will be parsed according to the type. Arrays are split by a single , and booleans are true if they match the string true when converted to lower case.

const { username, password } = askEnv({
  username: { type: "string" },
  password: { type: "password" },
});
  • required If the value is required or not.
  • defaultValue Default value.
  • options Array of allowed values.

Supported types

Typeoptionsyargsenquirer
arraynoarraylist
arrayyesarrayauto complete
booleanbooleanconfirm
numbernumbernumeral
stringnostringinput
stringyesstringauto complete
passwordstringinvisible

Changelog

Changelog

License

MIT License

ECMAScript 2019styleguidefastifyflatMapweaksetkoreanECMAScript 2017watchFileapparktypefullwidthPromisedeepclonecharactersfetchsnsoptionESnextenumerablewhatwglimitedidlebrowserslistjsdiffsetPrototypeOfES2023loadingdebugfromjwtsyntaxqswarninguninstallcollection.es6breakreduceArray.prototype.includesbrowserlistslicepostcssconfigurableWeakSetES7performancetrimEndquoteiteratoropensfilterpersistentmobileterminalflatiampasswordoffsetWebSockets$.extendnegative zerogetbrowserchildbufferes6replayhandlersconnectruntimeajaxvalidateTypedArrayidtrimLeftlinewrapmulti-packageformpyyamlfindLastartworkertrimRightsafespinnerArray.prototype.filtercallbindtypedarraysdomunicodeObservableES2022eslintagentjestcloudtrailMapescapeRFC-6455propreduxautoscalingjsonpathglobalsec2flattenchannelfullinternal slotsqsECMAScript 2021everydeterministicdefineconsolemimecollectionestreetypedwgetmochamoduleduplexdeeputilityreactpushdeletemapreduceargvcss nestingtimedom-testing-libraryrm -frqueueMicrotaskUint8ClampedArraysimpledbnested csscss variabletestingObject.keysroute53shebangasyncintrinsictelephonemapstatelesswindowsimmerjsonnpmframeworkfastclonePushtraversefseventscolorsfast-deep-copyinstallershelltaskexit-codecolumnsansiESemojiparserdayjsidentifiersgetopteditorHyBioperating-systemsigtermdebuggerlesscssmergeUnderscorechromeeventEmitteropenstringjscommandercjkreact-hook-formObjectrm -rferrorstreamECMAScript 3kinesisrategradients css3corslinuxbatchlibphonenumberstreams2less mixinscryptmatchless compilerES3rgbURLSearchParamspicomatchenvironmentemrreadablestreamtesterdeep-copycommand-lineprocesscolumnquerystringUint8ArraycallbackenvsharedcurlargsInt32ArrayECMAScript 5Function.prototype.namecolorindicatorplugingetOwnPropertyDescriptorflageslint-pluginprogressECMAScript 2022ES8requeststylesheetArray.prototype.flatMapbuffersschemaequalglobObject.entriesdeep-cloneasciiratelimitsettingsargumentecmascriptparsingbusyES2016code pointssameValueZerostreamscloudfrontweakmapcloudsearchdefaultBigUint64ArrayReactiveExtensionswalkingimmutablerestfulsortedsetImmediate[[Prototype]]bcryptauthdropreal-timeequalitycss lesstslibfile systemslotarraysextraexecutablees5class-validatorform-validationautoprefixerrmdirreact-testing-librarysortdataViewUint32ArrayimportjasmineES2019japaneseworkspace:*lastreact-hookslengthformattingString.prototype.trimexecspawnmacosinternalviewairbnbbyteOffsetassertscomputed-typestapforEachspeedbindhigher-orderextendebsRegExp.prototype.flagsremoveES6ECMAScript 2023classnamesemitnamesfunctionsmonorepoisdefinePropertysignalArrayBuffercss-in-jspipeoptimizerfindLastIndexnopewritesequencestringifybannerURLless.jsfluxiterateregular expressionnativeincludesStreamscliprotoyamltyped arraykeyobjrapidprototypebounddescriptorscharacterString.prototype.matchAllprunenegativestructuredCloneclassesless csswritablestringifierdeepcopyendereslintpluginmixinsregular expressionsjQueryArrayparsecloudwatchkeysrouterfunctioninexitrmdateassertinspecturlswebsitegradients cssnumberRxrobustajvtakepackageses2016findupinstallelmiterationfindECMAScript 2016Object.definePropertyJSONtypedarrayvisualerror-handlingtrimStartECMAScript 2015testspinnerstc39karmatoolkitfast-copytouchwatchcall-boundhasOwnPropertycheckchromiumhttpirqhas_.extendshammimetypeswaitproxyInt16Arrayregularglacierfind-upprotocol-buffersstablegdprxhrdires2017bdddataviewtextzeroes8loadbalancingvarsvpcdependenciesexpresspromisecreatel10nInt8ArraygetPrototypeOftoSortedstarterrandomwatchinges2018mime-dbdescriptortypeerrortypesafeECMAScript 2020esinputresolveCSSStyleDeclarationhookformES2020bundlerthrottlemodulescontainsponyfilllistenersassignstdlibmkdirpvestbluebirdReflect.getPrototypeOfprefixconcatMapsomebundlingeventDispatchersharedarraybufferSymbol.toStringTagArray.prototype.containspropertyexpressionelasticachebootstrap csses2015momentlinksearchstatechaixtermArray.prototype.findLastbootstrap lesstoArrayhashreadsyntaxerrorwordbreakcompareloggervalidationflagstoolsfast-clone-0toStringTagsymlinksObservablesjshintjoiArray.prototype.flattencodesswfefficientIteratorxdg-openBigInt64ArraymovesesdescriptionSetnameglobalTypeScriptpnpm9outputvariables in csslrushimimportexportarraybufferSymbolFloat32Arrayutil.inspectawsrangeerrorprotobufastawaitRxJSregexargparsea11ybyteprivate datahelpersrequireJSON-SchemafiglettrimWebSocketUint16Arrayscheme-validationrdsredactpromisesstyling256groupaccessorauthenticationwrapjsxnodeopenerstyleslimitwhichvalidstartcloneisConcatSpreadablefastcopytypanioncompile lessminimalconfigpackage managerzodcoreArray.prototype.flatstyled-componentsdependency managerparenthotconcates-shims0typescriptwordwrapmetadatapostcss-pluginconcurrencyhooksmakexdgoncelanguageTypeBoxdatastructurehasOwnpolyfillmatchAllttyapigenericsAsyncIteratortermstoragegatewayjsdomFloat64ArrayWeakMapentriesoptimistStreamcore-jsfast-deep-clonetssignalsArray.prototype.findLastIndexES2015callreusemkdircssguidiees-shim APIRegExp#flagsmkdirsawesomesauceutilMicrosoftrfc4122cryptoES5urlpatchliveObject.fromEntriesio-tssetterES2017classnamesidedirectoryfspathreducerfilewidthformatfixed-widthcmdphonesymbolarraysetupcopysuperagentinterruptsspecstatusObject.assignpreprocessorcolourargumentsES2018fpsvariablespreserve-symlinkslintcircularlookfunctionalcloudformationrecursivejavascriptprivatediffcallboundtoobjectdotenvexecommandObject.iscompilercall-bindtypeoftostringtagshrinkwrapyupmake dirlazyArrayBuffer#slicees-abstractassertionamazondynamodbqueryeast-asian-widthYAMLi18npropertiesutilitiesparentsreadablecensortypeenvironmentslockfilebeanstalkownpackagefull-widthsymlinkfolderfastsigintwebserializecachecoercibleReactiveXlogrestencryptionwafECMAScript 6es7eslintconfigomitformsinvariantserializationtddmrugetteraccessibilityextensionelbdatainferencestyletypeslessava@@toStringTaggroupBypackage.jsonqueueelectronObject.getPrototypeOfperformant__proto__eventss3superstructchineseArrayBuffer.prototype.slicelook-upCSSobjectworkflow
2.9.115

11 months ago

2.9.114

11 months ago

2.8.114

11 months ago

2.8.113

11 months ago

2.8.112

11 months ago

2.8.111

11 months ago

2.8.110

11 months ago

2.8.109

11 months ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.30

1 year ago

1.8.69

1 year ago

1.6.46

1 year ago

1.6.48

1 year ago

1.6.47

1 year ago

1.6.49

1 year ago

1.1.31

1 year ago

2.8.100

11 months ago

1.8.70

12 months ago

1.8.71

12 months ago

1.8.72

12 months ago

1.8.73

12 months ago

1.8.74

12 months ago

1.6.51

1 year ago

1.8.75

12 months ago

1.6.50

1 year ago

1.8.76

12 months ago

1.6.53

1 year ago

1.8.77

12 months ago

1.6.52

1 year ago

1.8.78

12 months ago

1.6.55

1 year ago

1.8.79

12 months ago

1.6.54

1 year ago

1.6.57

1 year ago

1.6.56

1 year ago

1.6.59

1 year ago

1.6.58

1 year ago

1.4.37

1 year ago

1.4.36

1 year ago

1.4.39

1 year ago

1.4.38

1 year ago

1.3.35

1 year ago

1.3.36

1 year ago

1.3.34

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

1.0.21

1 year ago

1.5.43

1 year ago

1.7.67

1 year ago

1.5.42

1 year ago

1.7.68

1 year ago

1.5.45

1 year ago

1.7.69

1 year ago

1.5.44

1 year ago

1.5.46

1 year ago

2.8.92

11 months ago

2.8.96

11 months ago

2.8.95

11 months ago

2.8.94

11 months ago

2.8.93

11 months ago

1.8.80

12 months ago

1.8.81

12 months ago

1.8.82

12 months ago

1.8.83

12 months ago

1.6.60

1 year ago

1.8.84

12 months ago

1.8.85

12 months ago

1.6.62

1 year ago

1.8.86

12 months ago

1.6.61

1 year ago

1.8.87

12 months ago

1.6.64

1 year ago

1.4.40

1 year ago

1.8.88

12 months ago

1.6.63

1 year ago

1.8.89

12 months ago

1.6.66

1 year ago

1.4.42

1 year ago

1.6.65

1 year ago

1.4.41

1 year ago

1.6.67

1 year ago

2.8.107

11 months ago

2.8.108

11 months ago

2.8.99

11 months ago

2.8.105

11 months ago

2.8.98

11 months ago

2.8.106

11 months ago

2.8.97

11 months ago

2.8.103

11 months ago

2.8.104

11 months ago

2.8.101

11 months ago

2.8.102

11 months ago

1.8.90

11 months ago

1.8.91

11 months ago

1.8.92

11 months ago

1.2.31

1 year ago

1.2.34

1 year ago

1.2.32

1 year ago

1.2.33

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago