vtex / findhelp Goto Github PK
View Code? Open in Web Editor NEWA simple and hackable lib to create modular CLI's
License: MIT License
A simple and hackable lib to create modular CLI's
License: MIT License
Show help, version, etc.
From doing the PR #3 and dealing a little bit with the library, I perceived one core problem, which is the use of maps everywhere. Maps, as we know, shouldn't have any order for their keys and values. That made me do a bit of a hack to get the namespace command represented before all others, and I believe more problems may arise from it.
So here I suggest that we switch from a map-based structure to arrays, switching from:
const tree = {
list: {
description: 'List apps',
handler: () => {}
},
settings: {
description: 'Get settings',
handler: () => {},
set: {
description: 'Set settings value',
handler: () => {}
},
unset: {
description: 'Unset settings value',
handler: () => {}
}
}
}
To:
const tree = [
{
name: 'list',
description: 'List apps',
handler: () => {}
},
{
name: 'settings',
description: 'Get settings',
handler: () => {},
children: [
{
name: 'set',
description: 'Set settings value',
handler: () => {}
},
{
name: 'unset',
description: 'Unset settings value',
handler: () => {}
},
]
}
]
Yes, I know it is not as pretty, but I think it is clearer, of easier maintenance and less error-prone. For instance, ambiguity between a field and a command name would never be an issue.
@firstdoit, @tamorim, what do you think?
findhelp
should have an API that allows the user to pass in names of modules, so it can lazily require commands and namespaces.
This should immensely improve start-up times for any non-trivial CLI application.
Suggestions on how to do it? I'd like to keep it simple. Maybe a module
property which has more priority than handler?
This error happens when the tree object has no options
value, and/or when none of its children have an options
value, from what I gather.
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.