![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
interactive-cli
Advanced tools
Making it easy to create interactive command line scripts in Node.js
The Interactive CLI is a library that makes it easy to create interactive command line scripts in Node.js by utilizing promises.
Using npm:
npm i --save interactive-cli
$ node examples/basic-usage.js --example
Would you like to
a) Create a new user
b) Delete a user
q) Quit
?: a
Enter user's email
email: leonaro@dicaprio.com
What's the name for the user
firstname: Leonardo
lastname: DiCaprio
User Leonardo DiCaprio was created successfully!
All DONE!
Would you like to
a) Create a new user
b) Delete a user
q) Quit
?: b
Which user would you like to delete?
a) Leonardo DiCaprio
b) Jennifer Lopez
q) Quit
?: b
Are you absolutely sure?
continue? (y/n): y
User Jennifer Lopez was successfully deleted!
All DONE!
Would you like to
a) Create a new user
b) Delete a user
q) Quit
?: q
const { promptFields, promptToContinue, promptOptions, startWith, onFinalError, exit, DontContinue } = require('../')
new Promise((resolve, reject) => {
// Do some preparation, such as getting
// a reference to a database or authenticating
resolve({
createUser: () => Promise.resolve(),
listUsers: () =>
Promise.resolve({
'31725276-73a9-4830-aa77-a86fce4dd7f8': 'Leonardo DiCaprio',
'53bd3330-4bd7-47c5-a685-f1039e043eae': 'Jennifer Lopez',
}),
deleteUser: () => Promise.resolve(),
})
})
.then((api) => {
const initialOptions = {
createUser: 'Create a new user',
deleteUser: 'Delete a user',
}
const handler = (selection) => {
switch (selection) {
case 'createUser':
return createUser(api)
case 'deleteUser':
return deleteUser(api)
default: {
throw new ExitScript(`Unknown selection "${selection}"`)
}
}
}
return startWith('Would you like to', initialOptions, handler)
})
.catch(onFinalError)
.then(exit)
function createUser(api) {
const user = {}
return promptFields("Enter user's email", 'email')
.then((email) => {
user.email = email
})
.then(() => promptFields("What's the name for the user", ['firstname', 'lastname']))
.then((res) => {
user.firstname = res.firstname
user.lastname = res.lastname
})
.then(() => {
return api.createUser(user).catch((err) => {
throw DontContinue('User could not be created because of error: ' + err.message)
})
})
.then(() => {
console.log(`User ${user.firstname} ${user.lastname} was created successfully!`)
})
}
function deleteUser(api) {
const data = {}
return api
.listUsers()
.then((users) => {
data.users = users
return users
})
.then((users) => promptOptions('Which user would you like to delete?', users))
.then((selection) => {
data.selection = selection
return selection
})
.then((selection) => {
console.log('\n' + 'Are you absolutely sure?')
return promptToContinue(selection)
})
.then((selection) => {
api.deleteUser(selection)
})
.then(() => {
console.log(`User ${data.users[data.selection]} was successfully deleted!`)
})
}
MIT
FAQs
Making it easy to create interactive command line scripts in Node.js
The npm package interactive-cli receives a total of 1,082 weekly downloads. As such, interactive-cli popularity was classified as popular.
We found that interactive-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.