Code Monkey home page Code Monkey logo

input-deno's Introduction

๐Ÿ‘‹๐Ÿผ ย  Hello and Welcome!

Principal Front-End Engineer at Kizen in Austin, Texas ยท keegan.codes

I like learning and making the web fast!

input-deno's People

Contributors

keegandonley avatar polymeilex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

input-deno's Issues

[Feature Request] Press any key to continue

While Deno offers alert(), that pauses execution until the Enter key is pressed, it would be nice to have an async alternative that also pauses until any key is pressed.

Error with Deno 1.6.0

Describe the bug
input-deno fails with latest Deno 1.6.0 (worked with previous 1.5.x releases)

To Reproduce
Steps to reproduce the behavior:

  1. Install Deno 1.6.0
  2. Run the sample code
    import InputLoop from 'https://deno.land/x/input/index.ts';
    const input = new InputLoop();
    const accepting = await input.choose(["Accepting node", "Non-accepting node"]);

Program Output

error: TS2345 [ERROR]: Argument of type 'string | undefined' is not assignable to parameter of type 'string | PromiseLike<string>'.
  Type 'undefined' is not assignable to type 'string | PromiseLike<string>'.
		return new Promise((resolve) => resolve(value));
		                                        ~~~~~
    at https://deno.land/x/[email protected]/index.ts:24:43

Versions (please complete the following information):

  • OS: Ubuntu Linux 20.04
  • Deno Version 1.6.0

input.choose returns false for all options

I am attempting to use the input.choose method but the result is always an array of false values. Here is what I am running

import InputLoop from "https://deno.land/x/input/index.ts";
const input = new InputLoop();
const weapon = await input.choose(["sword", "bow", "dagger"]);
console.log(weapon);

I am running this in Powershell 7 on Windows.

Input does not compile with latest version of std/async

Describe the bug
std/async removed deferred in denoland/deno_std#3852

Since input does not pin the version of std/async, this results in the following error when trying to import the input library:

Warning Implicitly using latest version (0.210.0) for https://deno.land/std/async/mod.tsiB (217/258)
error: Uncaught SyntaxError: The requested module 'https://deno.land/std/async/mod.ts' does not provide an export named 'deferred'
import { deferred } from "https://deno.land/std/async/mod.ts";
         ^
    at <anonymous> (https://deno.land/x/[email protected]/index.ts:5:10)

To Reproduce

Attempt to import the input package in deno

Expected behavior

The import succeeds

Program Output
n/a

Versions (please complete the following information):

  • OS: Mac OSX 14.2.1
  • Deno Version : 1.32.4

Additional context
Add any other context about the problem here.

Advanced Input History

Track the questions asked to the user and the answers given in order

TODO:

  • Store history
    • Save
  • Retrieve history
    • Shift
    • Pop
    • Length
    • Get all
  • Interact with history results
  • Tests
    • Test History Class
    • Test Printer Class
    • Test Main Class

Remove Reliance on Deferred

Describe the bug
Deferred has been removed from the standard lib, so we pin it to an older version. Reliance on deferred should be removed, so the latest version can be used.

[Feature Request] Input Highlighting

When asking a question(), it would be nice if an "interactive" mode could be implemented, so that after every keystroke, the library could report back to the program with the input currently written, and allow the program to change text/background color on the fly. Or perhaps an async interface that allows the library to collect input at the same time as the program applies text/background color to character positions.

Question method without printing newline

Is your feature request related to a problem? Please describe.
I've been trying to make a prompt that looks like a command line, so I tried using the question method.
Turns out I cannot avoid printing that output with a newline, so the prompt looks like this:

> 
InputHere

Instead of:

> InputHere

It might be a good idea to add an optional boolean argument to question, that defaults to true, to allow the user to enable or disable the printing of a final newline in a question.

Hidden (Password-Like) Input

I've been trying to get deno to receive command line input without showing it, kind of like when entering passwords.

It'd be nice to have an option to collect input in this kind of way

While I can technically run the 'stty' linux command to fix this, that solution wouldn't account for cross-platform usage.

TBH, I've been looking around the Deno Runtime API, and I don't think there is native support for this. Maybe a Deno plugin would work? Would that even be within the design goals of this project?

Easier Configuration Management

Let's use this issue for discussion around handling configuration in a cleaner and easier way than passing lots of parameters to each function call, but while maintaining backwards compatibility.

This is partially related to #6 as I'd like to use this model for setting that configuration option.

Failing tests

Describe the bug
Need to update deno version for CI tests

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Program Output
If applicable, add your program's output to help explain your problem.

Versions (please complete the following information):

  • OS: [e.g. Mac OSX 10.15.3]
  • Deno Version [e.g. 1.0.1]

Additional context
Add any other context about the problem here.

Hidden Input is Broken

Describe the bug
When using hidden input, it no longer works due to changes in the setRaw API

To Reproduce
Try to use hidden input

Expected behavior
Hidden input should not appear as you type

Additional context
We should look into removing the unstable flag as this is no longer an unsupported feature

[Feature Request] Single-Line and/or Multi-Line input editing.

When asking a question(), and typing in an answer, if one needs to go back and edit something already written (For example, when writing a parentheses pair, then trying to add text inside said parentheses), it would be useful to be able to use the arrow keys to go back in the string, without needing to delete the text already written.

A system similar to Deno's REPL would be desirable, and perhaps an option for multiline editing could be attempted, again, not unlike the Deno REPL.

Such a multiline system could, when a return is inputted, report back to the program with the currently written lines and current position of the cursor, and let the program decide whether to terminate input or continue, much like the Deno REPL. (That decides not to end input when braces are not closed). The user could then use the arrow keys not only to move left or right within the input, but also up and down. Another feature could be to allow the program to insert characters into the input when this choice is provided (which could allow for automatic indentation).

In any case, just the ability to seek back and forth within a single line is already pretty powerful, and I understand if this project decides it might not be wise to implement multiline editing.

Support more intuitive manual loop ending

Instead of

const input = new InputLoop();
const mainQuestions = ["Add a node", "Add an edge", "Set starting node", "Evaluate a string", "Quit"];

while (!input.done) {
	const result = await input.choose(mainQuestions);

	// Business logic...

	if (result[mainQuestions.length - 1]) {
		input.close();
	}
}

I'd like to be able to simply do

const input = new InputLoop();
const mainQuestions = ["Add a node", "Add an edge", "Set starting node", "Evaluate a string", "Quit"];

while (!input.done) {
	const result = await input.choose(mainQuestions);

	// Business logic...

	if (input.isDone()) {
		input.close();
	}
}

This could even be simplified further to

const input = new InputLoop();
const mainQuestions = ["Add a node", "Add an edge", "Set starting node", "Evaluate a string", "Quit"];

while (!input.done) {
	const result = await input.choose(mainQuestions);

	// Business logic...

	input.closeWhenDone();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.