drew-y / cliffy Goto Github PK
View Code? Open in Web Editor NEWNodeJS Framework for Interactive CLIs
License: ISC License
NodeJS Framework for Interactive CLIs
License: ISC License
Been playing around with this for a CLI client before building a full on GUI. Had some ideas:
compute networkID 'a b c'
currently gives a
compute networkID "a b c"
gives an a b c
compute
for as a namespace, if I type compute without a sub command following it, then I could show a list of sub commands help as if I typed help compute
Also curious, is it's possible to type while writing out text? I was playing with a CLI a few years ago and ran into that problem, but thinking it's probably some limitation in general. https://youtu.be/Q_E7ZFtoKY4 - I guess if that's the case then you wouldn't want to write anything to the console unless responding to a command.
I may do a PR for this if I have time - I imagine this should be relatively simple?
Basically, my feature request just an array of aliases - set as a property on addCommand. Then, you can use these to execute the command as well as the normal trigger.
(The aliases wouldn't have to show up in help
)
I am using chalk to print color, but it doesn't work with cliffy...
import { CLI } from "cliffy"
import chalk from "chalk"
const cli = new CLI()
.setDelimiter(chalk.bold.blue(" "))
.addCommand("run", {
description: "Run somewhere",
options: [{ label: "quickly", description: "Run quickly" }],
parameters: ["destination"],
action: (params, options) => {
if (options.quickly) {
console.log(chalk.yellow(`I ran to ${params.destination} quickly`))
return
}
console.log(`I ran to ${params.destination}`)
},
subcommands: {
to: {
description: "Run to a destination",
parameters: ["destination"],
action: (params) => console.log(`I ran to ${params.destination}`),
},
from: {
description: "Run from a destination",
parameters: ["location"],
action: (params) => console.log(`I ran from ${params.location}`),
},
},
})
.show()
... if possible. Thanks!
I would like to start off that the tool is exactly what I needed only I miss out on the following:
Hello,
Is it possible to set custom stdin
& stdout
streams in place of process.stdin
& process.stdout
?
Thanks
Hi, Thanks for this great library.
I was implementing this in my project and noticed that only console.log() from inside the CLI function is displayed on the prompt. Is there any way to show logs from other files in the project?
Hello,
How can I do the following using cliffy
?
--param2=foo --param1=bar --param3
Thanks
The example in the README uses the deprecated command
.command("run", {
and is missing a comma:
}
from: {
I just ran the example snippet and was surprised that this is accepted as input:
-->run foo bar
The command supports only one argument; if more are provided, I would expect that the CLI yields an error message that reminds the user of the correct syntax, but the CLI seems to ignore the superflous input silently and outputs this:
I ran to foo
-->
With these tsc option "noUnusedLocals": true,
TSC give console errors:
node_modules/cliffy/src/index.ts(4,19): error TS6133: 'Parameter' is declared but its value is never read.
node_modules/cliffy/src/index.ts(10,7): error TS6133: 'columnify' is declared but its value is never read.
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.