mavcunha / devcli Goto Github PK
View Code? Open in Web Editor NEWA command line tool to create command line tools.
License: MIT License
A command line tool to create command line tools.
License: MIT License
I'm trying to create a new cli, but the create command as described in the README is not working anymore
Steps
./devcli create -n mytool -d ~/Projects/myproject
Actual result: "'create' not found"
Extra information:
twin create
command, however, this command creates a symbolic link to the original devli executable.Problem
It requires a lot of effort to know how to use the devcli (read the code, read the examples). Even though the source code comes with examples of subcommands for connecting with a vpn, vagrant, or share git repositories; it is hard to differentiate what is part of the core functionality of devcli and what is merely part of the solution for the example.
Possible solutions
There are plenty things that can be done to improve documentation. Here are some from the top of my head:
I would like to suggest the last options as a viable solution to describe what things are important (part of the core) and what is part of a example.
Basically my vision is to create a documentation pretty similar as what jasminejs has https://jasmine.github.io/2.4/introduction.html, it is called literate programming and is meant to use the comments from the source code to generate the documentation https://en.wikipedia.org/wiki/Literate_programming.
I would like to know your comments, ideas. If we agree in some solution then later we can figure out "the how", by now I am more interested in "the what" (improve documentation).
The way to debug currently is by running the command with _DEBUG
but for some reason it was always being set to true
regardless of how we passed the command or even defined the variable.
We also noticed that it only happens in the else
of an if
that checks the bash version, which seems odd.
On our CLI we just removed the DEBUG
set line (devcli:31
) and used a plain env var to enable/disable debug logs, like DEBUG=true leave-cli test unit
.
If removing that line will cause trouble elsewhere, another option would be to check if the env var is already set and only execute the logic if it isn't, like this:
DEBUG=${DEBUG:-$(eval "[[ -n \${${MAIN_COMMAND^^}_DEBUG} ]] && echo 'true' ")}
Let us know what you think and we can make a PR with these changes.
Hi
devcli command was silently failing when I tried to create a new cli:
➜ fjunior:devcli[master]$ ./devcli create -n foo -d /tmp/foo
➜ fjunior:devcli[master]$
After some debugging I found out that the script returned after is_helper_function
execution:
➜ fjunior:devcli[master]$ bash -x ./devcli create -n foo -d /tmp/foo
(...)
++ is_help_mode
++ [[ -z '' ]]
++ return
+ [[ -n foo -d /tmp/foo == \h\e\l\p ]]
+ [[ -z -n foo -d /tmp/foo ]]
As far as I understood the function expands the arguments and check if there are empty:
function is_help_mode() {
[[ -z "${@}" || "${1}" == 'help' ]]
}
That works fine when you use it within the main command, devcli
. But as create
is invoked that reference does not work and the argument list is always empty:
➜ fjunior:devcli[master]$ ./devcli create -n foo -d /tmp/foo
On create script -n foo -d /tmp/foo
On is help
I've fixed it by explicitly passing the arguments to the function:
# skip if no argument was given or help needed.
is_help_mode "${@}" && return
I'm not sure if that's how it was meant to be used, specially after reading the previous discussion on this pull request.
Happy to help and/or open a PR with the fix, but I wanted to check with there was a better way to solve it first.
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.