Principal Front-End Engineer at Kizen in Austin, Texas ยท keegan.codes
I like learning and making the web fast!
CLI user input handler for Deno
License: MIT License
Principal Front-End Engineer at Kizen in Austin, Texas ยท keegan.codes
I like learning and making the web fast!
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
Track the questions asked to the user and the answers given in order
TODO:
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.
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.
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.
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.
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):
Additional context
Add any other context about the problem here.
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.
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.
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();
}
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):
Additional context
Add any other context about the problem here.
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:
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):
Users may wish for the option ordering to start at 1, not 0. This should be supported as a flag passed to the class to allow the indexing to be shifted.
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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.