Alex Lambert

Alex Lambert

1610075220

Interactive Command-line Prompts for Deno

ask

Interactive command-line prompts for Deno.

Description

ask is a slick and dependency-free Deno module that allows you to create interactive command-line applications, similar to what you’d achieve with inquirer in Node.js. Right now this module is very early in development, so please don’t expect it to support everything inquirer does.

Overview

  • Supported prompts: input (text), confirm (yes/no response), number… and more to come!
  • Elegant output
  • Familiar, inquirer-like syntax
  • Easily configurable
  • Dependency-free

Basic Usage

It’s very easy to get started. Just create an Ask instance and use the prompt() method to enumerate your questions.

import Ask from 'https://deno.land/x/ask/mod.ts';

const ask = new Ask(); // global options are also supported! (see below)

const answers = await ask.prompt([
  {
    name: 'name',
    type: 'input',
    message: 'Name:'
  },
  {
    name: 'age',
    type: 'number',
    message: 'Age:'
  }
]);

console.log(answers); // { name: "Joe", age: 19 }

You can also just ask a single question:

const { name } = await ask.input({
  name: 'name',
  message: 'Name:'
});

console.log(name); // Joe

Options

ask has options that you can pass to individual prompts.

General Options

These options are available for all question types.

  • name (string, required) - the name of the key in the returned object file that will contain the response to the question
  • type (string) - one of the supported types, defaults to "input"
  • message (string) - the message that will be displayed in the prompt. If not provided, the value of the name option will be displayed.
  • prefix (string) - the prefix that will be displayed before the question. Defaults to a green question mark.
  • suffix (string) - the suffix that will be displayed after the question. If no message is provided, it defaults to a colon :. Otherwise it defaults to an empty string.
  • input (Deno.Reader & Deno.ReaderSync & Deno.Closer) - the input buffer to accept answers. Defaults to Deno.stdin.
  • output (Deno.Writer & Deno.WriterSync & Deno.Closer) - the output buffer used to display the questions. Defaults to Deno.stdout.
  • validate (val?: any) => Promise | boolean - a function that can be used to validate the user input. Defaults to a function that always returns true.

Global Options

These options will apply to every prompt in a given Ask instance, unless overwritten:

  • prefix (string)
  • suffix (string)
  • input (Deno.Reader & Deno.ReaderSync & Deno.Closer)
  • output (Deno.Writer & Deno.WriterSync & Deno.Closer)

Example:

import Ask from 'https://deno.land/x/ask';

const ask = new Ask({
  prefix: '>'
});

const answers = await ask.prompt([
  {
    name: 'name',
    message: 'Your name:',
    type: 'input'
  },
  {
    name: 'age',
    message: 'Your age:',
    type: 'number',
    prefix: '?'
  }
]);

// > Your name:
// ? Your age:

Confirm

  • accept (string) - the character/sequence used as the “yes” answer. This will also be the default value. The function will only return true if the user entered this string or nothing at all. Defaults to "Y".
  • deny (string) - the character/sequence used as the “no” answer. Doesn’t really matter what you put here, it’s mainly there for stylistic reasons. Defaults to "n".

Number

  • min (number) - the minimum value that the user can enter. Defaults to -Infinity.
  • max (number) - the maximum value that the user can enter. Defaults to Infinity.

Depending on which of these parameters are provided, the function will print different output:

// if none are provided:
'message'

// if `min` is provided, but `max` is not:
'message (>= min)'

// if `max` is provided, but `min` is not:
'message (<= max)'

// if both are provided:
'message [min-max]'

Right now, this behavior is not configurable, but if there’s popular demand for it, I could add it as a configuration option.

TODOs

  • [x] Global configuration
  • [ ] hidden type
  • [ ] masked type
  • [ ] list type
  • [ ] Unit tests

Download Details:

Author: jozsefsallai

Source Code: https://github.com/jozsefsallai/ask

#deno #nodejs #node #javascript

What is GEEK

Buddha Community

Interactive Command-line Prompts for Deno
Alex Lambert

Alex Lambert

1610075220

Interactive Command-line Prompts for Deno

ask

Interactive command-line prompts for Deno.

Description

ask is a slick and dependency-free Deno module that allows you to create interactive command-line applications, similar to what you’d achieve with inquirer in Node.js. Right now this module is very early in development, so please don’t expect it to support everything inquirer does.

Overview

  • Supported prompts: input (text), confirm (yes/no response), number… and more to come!
  • Elegant output
  • Familiar, inquirer-like syntax
  • Easily configurable
  • Dependency-free

Basic Usage

It’s very easy to get started. Just create an Ask instance and use the prompt() method to enumerate your questions.

import Ask from 'https://deno.land/x/ask/mod.ts';

const ask = new Ask(); // global options are also supported! (see below)

const answers = await ask.prompt([
  {
    name: 'name',
    type: 'input',
    message: 'Name:'
  },
  {
    name: 'age',
    type: 'number',
    message: 'Age:'
  }
]);

console.log(answers); // { name: "Joe", age: 19 }

You can also just ask a single question:

const { name } = await ask.input({
  name: 'name',
  message: 'Name:'
});

console.log(name); // Joe

Options

ask has options that you can pass to individual prompts.

General Options

These options are available for all question types.

  • name (string, required) - the name of the key in the returned object file that will contain the response to the question
  • type (string) - one of the supported types, defaults to "input"
  • message (string) - the message that will be displayed in the prompt. If not provided, the value of the name option will be displayed.
  • prefix (string) - the prefix that will be displayed before the question. Defaults to a green question mark.
  • suffix (string) - the suffix that will be displayed after the question. If no message is provided, it defaults to a colon :. Otherwise it defaults to an empty string.
  • input (Deno.Reader & Deno.ReaderSync & Deno.Closer) - the input buffer to accept answers. Defaults to Deno.stdin.
  • output (Deno.Writer & Deno.WriterSync & Deno.Closer) - the output buffer used to display the questions. Defaults to Deno.stdout.
  • validate (val?: any) => Promise | boolean - a function that can be used to validate the user input. Defaults to a function that always returns true.

Global Options

These options will apply to every prompt in a given Ask instance, unless overwritten:

  • prefix (string)
  • suffix (string)
  • input (Deno.Reader & Deno.ReaderSync & Deno.Closer)
  • output (Deno.Writer & Deno.WriterSync & Deno.Closer)

Example:

import Ask from 'https://deno.land/x/ask';

const ask = new Ask({
  prefix: '>'
});

const answers = await ask.prompt([
  {
    name: 'name',
    message: 'Your name:',
    type: 'input'
  },
  {
    name: 'age',
    message: 'Your age:',
    type: 'number',
    prefix: '?'
  }
]);

// > Your name:
// ? Your age:

Confirm

  • accept (string) - the character/sequence used as the “yes” answer. This will also be the default value. The function will only return true if the user entered this string or nothing at all. Defaults to "Y".
  • deny (string) - the character/sequence used as the “no” answer. Doesn’t really matter what you put here, it’s mainly there for stylistic reasons. Defaults to "n".

Number

  • min (number) - the minimum value that the user can enter. Defaults to -Infinity.
  • max (number) - the maximum value that the user can enter. Defaults to Infinity.

Depending on which of these parameters are provided, the function will print different output:

// if none are provided:
'message'

// if `min` is provided, but `max` is not:
'message (>= min)'

// if `max` is provided, but `min` is not:
'message (<= max)'

// if both are provided:
'message [min-max]'

Right now, this behavior is not configurable, but if there’s popular demand for it, I could add it as a configuration option.

TODOs

  • [x] Global configuration
  • [ ] hidden type
  • [ ] masked type
  • [ ] list type
  • [ ] Unit tests

Download Details:

Author: jozsefsallai

Source Code: https://github.com/jozsefsallai/ask

#deno #nodejs #node #javascript

Using the Linux Command Line to Convert PDF to Image

To use the pdftoppm  command-line tool, you need to first install pdftoppm  which is a part of the poppler  / poppler-utils  / poppler-tools  package. Install this package as follows depending on your Linux distribution

1. Convert PDF Document to Image

2. Convert Range of PDF Pages to Images

3. Convert First PDF Page to Image

4. Adjust DPI Quality to Conversion

#convert pdf #linux command line #linux #command line

Vincent Lab

Vincent Lab

1605178380

How to Create a Command Line (CLI) Tool in Node.js

In this video I will show you how to turn a Node.js application into a command line tool application.

#command line #node.js #cli #command line interface #template generator #node.js cli

Desmond Ivana

1595572272

What are the features of the Line clone messaging app?

The Line is a Japan-based text messaging app. It has over 250 million users worldwide, with around two-thirds of them based on Japan, Taiwan, Indonesia, and Thailand. The main perk of investing in the instant messaging app is that it gets popular within the few days of its launch. Here are the essential features of Line clone messaging app:

Profile: Users can customize their profiles, add a name, edit display picture, etc. Apart from that, an app like Line includes several privacy settings such as regulating the viewers for last seen, profile pic, status, etc.

Chat options: There are two kinds of chats available - individual chats and group chats. The individual conversations refer to one-on-one chat. A group chat allows upto 200 members in a single group. People can share videos, files, pictures, GIFs, stickers in addition to messages.

Video/voice calls: Line currently allows upto 200 members in a group call. Users can directly click on the video chat icon on the group they wish to connect and start the video call. It would be very beneficial for people as it allows conference calls with so many participants.

Security: The messages are protected so that any third party cannot view them. If the users do not feel safe with communicating with a particular user, they can block them. Then, they can send them messages.

Appdupe offers a messaging app script with all the above-mentioned salient features. Get the clone app from us, see the business growth it offers.

#line clone app development #app like line #line clone script #messaging app #line clone #line clone app

Aketch  Rachel

Aketch Rachel

1619659465

Command Line Arguments in C - Don't be Confused be Practical!

So far, we have seen that no arguments were passed in the main function. But the C programming language gives the programmer the provision to add parameters or arguments inside the main function to reduce the length of the code. These arguments are called command line arguments in C.

In this tutorial, we will discuss:

  • Command Line arguments
  • Components of command line arguments
  • C program to understand command line arguments

What are Command Line Arguments in C?

Command line arguments are nothing but simply arguments that are specified after the name of the program in the system’s command line, and these argument values are passed on to your program during program execution.

#c tutorials #arguments in c #c command line arguments #command line arguments